fix(front): update success message for copy action in CopyButton and refactor token handling in FileShareView

This commit is contained in:
keven1024
2026-04-28 08:20:01 +08:00
parent a14628718c
commit 2273c589f6
2 changed files with 14 additions and 12 deletions

View File

@@ -21,7 +21,7 @@ const { t } = useI18n()
async () => { async () => {
await copy(props?.value) await copy(props?.value)
isCopy = true isCopy = true
toast.success(t('page.result.text.copySuccess')) toast.success(t('common.copySuccess'))
await asyncWait(3000) await asyncWait(3000)
isCopy = false isCopy = false
} }

View File

@@ -19,22 +19,24 @@ const props = defineProps<{
const queryClient = useQueryClient() const queryClient = useQueryClient()
const { downloadFile, getShareToken } = useMyAppShare() const { downloadFile, getShareToken } = useMyAppShare()
const token = ref<string>()
const handleDownload = async () => { const handleDownload = async () => {
const { id } = props?.data || {} const { id } = props?.data || {}
try { try {
let token = null if (!token.value) {
if (props?.data?.has_password) { if (props?.data?.has_password) {
token = await showDrawer({ token.value = await showDrawer({
render: ({ ...rest }) => h(PasswallShareDrawer, { ...rest, share_id: id }), render: ({ ...rest }) => h(PasswallShareDrawer, { ...rest, share_id: id }),
}) })
} else { } else {
token = await getShareToken(id) token.value = await getShareToken(id)
}
if (!token.value) {
throw new Error(t('page.shareView.fileShare.getTokenFailed'))
}
} }
if (!token) { downloadFile(token.value)
throw new Error(t('page.shareView.fileShare.getTokenFailed'))
}
downloadFile(token)
} catch (error: any) { } catch (error: any) {
toast.error(error?.data?.message || error?.message || error) toast.error(error?.data?.message || error?.message || error)
} finally { } finally {