diff --git a/front/components/Result/ImageCompressResult.vue b/front/components/Result/ImageCompressResult.vue index 9f01520..d290918 100644 --- a/front/components/Result/ImageCompressResult.vue +++ b/front/components/Result/ImageCompressResult.vue @@ -1,193 +1,166 @@ - - 上传成功 - - - - - - - - - - - - {{ props?.data?.file?.name }} - - {{ - filesize(item.new_file.size ?? 0) - }} - - - {{ - ((1 - item.new_file.size / item.old_file.size) * 100).toFixed( - 2, - ) - }}% - - + + 上传成功 + + + + - { - const data = await createFileShare({ - file_id: item.new_file.id, - config: { - download_nums: 1, - expire_time: 60, - has_pickup_code: false, - has_password: false, - }, - file_name: props?.data?.file?.name, - }); - const { id } = data?.data || {}; - if (!id) { - return; - } - await downloadFile(id); - } - " - > - - - - - - - - + + + + + + + {{ props?.data?.file?.name }} + + {{ filesize(item.new_file.size ?? 0) }} + + + {{ ((1 - item.new_file.size / item.old_file.size) * 100).toFixed(2) }}% + + + + { + const data = await createFileShare({ + file_id: item.new_file.id, + config: { + download_nums: 1, + expire_time: 60, + has_pickup_code: false, + has_password: false, + }, + file_name: props?.data?.file?.name, + }) + const { id } = data?.data || {} + if (!id) { + return + } + try { + await downloadFileByShareId(id) + } catch (error) { + toast.error((error as any)?.data?.message || error) + } + } + " + > + + + - - {{ - `经过 ${taskData?.err?.retry} 次重试后任务处理失败: ${taskData?.err?.message}` - }} + + + + + + + {{ `经过 ${taskData?.err?.retry} 次重试后任务处理失败: ${taskData?.err?.message}` }} + + + + 返回首页 + - - - 返回首页 - - - - + + + - diff --git a/front/components/Share/FileShareView.vue b/front/components/Share/FileShareView.vue index 853d493..4e464c6 100644 --- a/front/components/Share/FileShareView.vue +++ b/front/components/Share/FileShareView.vue @@ -1,69 +1,81 @@ - - 下载文件 - - - - {{ item?.label }} - - {{ item?.value }} - + + 下载文件 + + + + {{ item?.label }} + + {{ item?.value }} + + + + 下载 + - - 下载 - - diff --git a/front/composables/useMyAppShare.ts b/front/composables/useMyAppShare.ts index 038f0c4..cecc599 100644 --- a/front/composables/useMyAppShare.ts +++ b/front/composables/useMyAppShare.ts @@ -36,16 +36,16 @@ const getShareToken = async ( return token } -const downloadFile = async (share_id: string) => { - try { - const token = await getShareToken(share_id) - if (!token) { - throw new Error('获取token失败') - } - window?.open(`/api/download?token=${token}`) - } catch (e) { - toast.error((e as any)?.data?.message || e) +const downloadFile = (token: string) => { + window?.open(`/api/download?token=${token}`) +} + +const downloadFileByShareId = async (share_id: string) => { + const token = await getShareToken(share_id) + if (!token) { + throw new Error('获取token失败') } + return downloadFile(token) } const createShare = async (data: any) => { @@ -98,6 +98,7 @@ const createTextShare = async (data: { text: string; config: any }) => { const useMyAppShare = () => { return { downloadFile, + downloadFileByShareId, createShare, createFileShare, createTextShare,