From b69af056aa1fa8aa497ad9d5f5394f5bb80fd731 Mon Sep 17 00:00:00 2001 From: keven1024 Date: Sun, 8 Mar 2026 14:57:46 +0800 Subject: [PATCH] feat: implement internationalization for share views and update UI text for better user experience --- .../components/Drawer/PasswallShareDrawer.vue | 11 ++++---- front/components/Drawer/QrCoreDrawer.vue | 25 +++++++++-------- front/components/Share/FileShareView.vue | 15 +++++----- front/components/Share/TextShareView.vue | 15 +++++----- front/i18n/locales/en.json | 28 +++++++++++++++++++ front/i18n/locales/zh-CN.json | 28 +++++++++++++++++++ front/pages/s/[id].vue | 5 ++-- 7 files changed, 94 insertions(+), 33 deletions(-) diff --git a/front/components/Drawer/PasswallShareDrawer.vue b/front/components/Drawer/PasswallShareDrawer.vue index 2785dc6..1ef2c36 100644 --- a/front/components/Drawer/PasswallShareDrawer.vue +++ b/front/components/Drawer/PasswallShareDrawer.vue @@ -4,6 +4,7 @@ import FormButton from '@/components/Field/FormButton.vue' import InputField from '@/components/Field/InputField.vue' import type { FormContext, GenericObject } from 'vee-validate' import { toast } from 'vue-sonner' +const { t } = useI18n() const props = defineProps<{ share_id: string hide: any @@ -15,14 +16,14 @@ const handleSubmit = async (form: FormContext) => const password = form.values.password const token = await getShareToken(props.share_id, { password }) if (!token) { - toast.error('密码错误') + toast.error(t('page.shareView.passwall.passwordError')) form.resetForm() return } props?.hide(token) return } catch (error) { - toast.error('密码错误') + toast.error(t('page.shareView.passwall.passwordError')) form.resetForm() } } @@ -31,9 +32,9 @@ const handleSubmit = async (form: FormContext) => diff --git a/front/components/Drawer/QrCoreDrawer.vue b/front/components/Drawer/QrCoreDrawer.vue index cca8361..453768b 100644 --- a/front/components/Drawer/QrCoreDrawer.vue +++ b/front/components/Drawer/QrCoreDrawer.vue @@ -1,20 +1,21 @@ diff --git a/front/components/Share/FileShareView.vue b/front/components/Share/FileShareView.vue index e9601a1..762f974 100644 --- a/front/components/Share/FileShareView.vue +++ b/front/components/Share/FileShareView.vue @@ -12,6 +12,7 @@ import PasswallShareDrawer from '~/components/Drawer/PasswallShareDrawer.vue' dayjs.extend(duration) dayjs.extend(relativeTime) +const { t } = useI18n() const props = defineProps<{ data: any }>() @@ -31,7 +32,7 @@ const handleDownload = async () => { token = await getShareToken(id) } if (!token) { - throw new Error('获取token失败') + throw new Error(t('page.shareView.fileShare.getTokenFailed')) } downloadFile(token) } catch (error: any) { @@ -53,19 +54,19 @@ onMounted(() => { const fileShareInfo = computed(() => { return [ - { label: '需要密码', value: props?.data?.has_password ?? false }, + { label: t('page.shareView.fileShare.needPassword'), value: props?.data?.has_password ?? false }, { - label: '过期时间', - value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`), + label: t('page.shareView.fileShare.expireTime'), + value: dayjs.duration(remaining.value, 'seconds').format(t('page.shareView.fileShare.durationFormat')), }, - { label: '剩余下载次数', value: props?.data?.download_nums ?? 0 }, + { label: t('page.shareView.fileShare.remainingDownloads'), value: props?.data?.download_nums ?? 0 }, ] }) diff --git a/front/components/Share/TextShareView.vue b/front/components/Share/TextShareView.vue index 2604afa..77879fc 100644 --- a/front/components/Share/TextShareView.vue +++ b/front/components/Share/TextShareView.vue @@ -17,6 +17,7 @@ import PasswallShareDrawer from '~/components/Drawer/PasswallShareDrawer.vue' dayjs.extend(duration) dayjs.extend(relativeTime) +const { t } = useI18n() const props = defineProps<{ data: any }>() @@ -37,12 +38,12 @@ onMounted(() => { const fileShareInfo = computed(() => { return [ - { label: '需要密码', value: props?.data?.has_password ?? false }, + { label: t('page.shareView.textShare.needPassword'), value: props?.data?.has_password ?? false }, { - label: '过期时间', - value: dayjs.duration(remaining.value, 'seconds').format(`D天 HH:mm:ss`), + label: t('page.shareView.textShare.expireTime'), + value: dayjs.duration(remaining.value, 'seconds').format(t('page.shareView.textShare.durationFormat')), }, - { label: '剩余浏览次数', value: props?.data?.download_nums ?? 0 }, + { label: t('page.shareView.textShare.remainingViews'), value: props?.data?.download_nums ?? 0 }, ] }) const previewText = ref(null) @@ -72,7 +73,7 @@ const handlePreview = async () => {