From 28e24390a4a4f350ea45d103674729175f39281e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BA=AE=E4=BA=AE?= Date: Mon, 15 Jan 2024 16:43:53 +0800 Subject: [PATCH] feat:add copyurl --- functions/rest/routes/index.ts | 4 ++++ functions/rest/type.ts | 1 + src/components/ImageBox.vue | 5 +++-- src/views/ManageImages.vue | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/functions/rest/routes/index.ts b/functions/rest/routes/index.ts index 0d6b97b..980a979 100644 --- a/functions/rest/routes/index.ts +++ b/functions/rest/routes/index.ts @@ -46,6 +46,7 @@ router.post('/checkToken', async (req: Request, env: Env) => { // list image router.post('/list', auth, async (req: Request, env: Env) => { + const COPY_URL = await env.XK.get('COPY_URL') const data = await req.json() as ImgReq if (!data.limit) { data.limit = 10 @@ -75,6 +76,7 @@ router.post('/list', auth, async (req: Request, env: Env) => { const urls = objs.map(it => { return { url: `/rest/${it.key}`, + copyUrl: `${COPY_URL}/${it.key}`, key: it.key, size: it.size } @@ -89,6 +91,7 @@ router.post('/list', auth, async (req: Request, env: Env) => { // batch upload file router.post('/upload', auth, async (req: Request, env: Env) => { + const COPY_URL = await env.XK.get('COPY_URL') const files = await req.formData() const images = files.getAll("files") const errs = [] @@ -111,6 +114,7 @@ router.post('/upload', auth, async (req: Request, env: Env) => { urls.push({ key: object.key, size: object.size, + copyUrl: `${COPY_URL}/${object.key}`, url: `/rest/${object.key}`, filename: item.name }) diff --git a/functions/rest/type.ts b/functions/rest/type.ts index 2428dc8..fa0068e 100644 --- a/functions/rest/type.ts +++ b/functions/rest/type.ts @@ -8,6 +8,7 @@ export interface ImgItem { key : string url : string size: number + copyUrl: string filename ?: string } diff --git a/src/components/ImageBox.vue b/src/components/ImageBox.vue index c473aa8..a5a39b4 100644 --- a/src/components/ImageBox.vue +++ b/src/components/ImageBox.vue @@ -38,10 +38,10 @@
- +
链接 @@ -83,6 +83,7 @@ import LoadingOverlay from '../components/LoadingOverlay.vue' const props = defineProps<{ src: string + copyUrl:string name: string size: number mode: 'converted' | 'uploaded' diff --git a/src/views/ManageImages.vue b/src/views/ManageImages.vue index fff7e35..c07d604 100644 --- a/src/views/ManageImages.vue +++ b/src/views/ManageImages.vue @@ -34,6 +34,7 @@ >