feat:add copyurl

This commit is contained in:
李亮亮 2024-01-15 16:43:53 +08:00
parent dab0ff47a1
commit 28e24390a4
4 changed files with 9 additions and 2 deletions

View File

@ -46,6 +46,7 @@ router.post('/checkToken', async (req: Request, env: Env) => {
// list image // list image
router.post('/list', auth, async (req: Request, env: Env) => { 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 const data = await req.json() as ImgReq
if (!data.limit) { if (!data.limit) {
data.limit = 10 data.limit = 10
@ -75,6 +76,7 @@ router.post('/list', auth, async (req: Request, env: Env) => {
const urls = objs.map(it => { const urls = objs.map(it => {
return <ImgItem>{ return <ImgItem>{
url: `/rest/${it.key}`, url: `/rest/${it.key}`,
copyUrl: `${COPY_URL}/${it.key}`,
key: it.key, key: it.key,
size: it.size size: it.size
} }
@ -89,6 +91,7 @@ router.post('/list', auth, async (req: Request, env: Env) => {
// batch upload file // batch upload file
router.post('/upload', auth, async (req: Request, env: Env) => { router.post('/upload', auth, async (req: Request, env: Env) => {
const COPY_URL = await env.XK.get('COPY_URL')
const files = await req.formData() const files = await req.formData()
const images = files.getAll("files") const images = files.getAll("files")
const errs = [] const errs = []
@ -111,6 +114,7 @@ router.post('/upload', auth, async (req: Request, env: Env) => {
urls.push({ urls.push({
key: object.key, key: object.key,
size: object.size, size: object.size,
copyUrl: `${COPY_URL}/${object.key}`,
url: `/rest/${object.key}`, url: `/rest/${object.key}`,
filename: item.name filename: item.name
}) })

View File

@ -8,6 +8,7 @@ export interface ImgItem {
key : string key : string
url : string url : string
size: number size: number
copyUrl: string
filename ?: string filename ?: string
} }

View File

@ -38,10 +38,10 @@
<div v-if="mode === 'uploaded'"> <div v-if="mode === 'uploaded'">
<el-divider class="m-0" /> <el-divider class="m-0" />
<div class="w-full flex text-white h-9 text-center text-sm"> <div class="w-full flex text-white h-9 text-center text-sm">
<el-tooltip :content="src" placement="top-start"> <el-tooltip :content="copyUrl" placement="top-start">
<div <div
class="flex-1 flex items-center justify-center cursor-pointer" class="flex-1 flex items-center justify-center cursor-pointer"
@click="copyLink(src)" @click="copyLink(copyUrl)"
> >
<font-awesome-icon :icon="faCopy" class="mr-2" /> <font-awesome-icon :icon="faCopy" class="mr-2" />
链接 链接
@ -83,6 +83,7 @@ import LoadingOverlay from '../components/LoadingOverlay.vue'
const props = defineProps<{ const props = defineProps<{
src: string src: string
copyUrl:string
name: string name: string
size: number size: number
mode: 'converted' | 'uploaded' mode: 'converted' | 'uploaded'

View File

@ -34,6 +34,7 @@
> >
<image-box <image-box
:src="item.url" :src="item.url"
:copyUrl="item.copyUrl"
:name="item.key" :name="item.key"
:size="item.size" :size="item.size"
@delete="deleteImage(item.key)" @delete="deleteImage(item.key)"