From 764ce2f8b55b0179088da0512e0e703489dadbb3 Mon Sep 17 00:00:00 2001 From: Nixevol Date: Sun, 5 Jul 2026 05:44:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=B7=A5=E5=85=B7=E6=9D=A1=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aidocs/project_context.md | 1 + apps/admin/src/composables/openMediaViewer.ts | 19 ++++++++++++------- apps/admin/src/locales/en-US.json | 9 +++++++++ apps/admin/src/locales/zh-CN.json | 9 +++++++++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/aidocs/project_context.md b/aidocs/project_context.md index a0341a5..7a87aa1 100644 --- a/aidocs/project_context.md +++ b/aidocs/project_context.md @@ -160,6 +160,7 @@ - 后台排序媒体预览分流(2026-07-05):`MediaSorter` 用于作品主图和溯源节点媒体排序上传;点击图片时现在只把图片项传入 PhotoSwipe 预览队列,打开样式与认证文件等图片预览保持一致,避免混入视频项影响图片查看体验。点击视频仍沿用原有媒体预览逻辑。 - 后台详情页图片预览统一(2026-07-05):艺术品详情页中溯源时间轴图片和认证文件封面不再使用 Naive UI `n-image` 预览层,统一改为普通缩略图点击后调用后台 `openMediaViewer`。这样打开样式与后台其他图片预览一致,并能使用 PhotoSwipe 的鼠标滚轮缩放兜底;视频仍保持原页面内原生 video 控件。 - 后台图片预览工具条(2026-07-05):后台 `openMediaViewer` 在 PhotoSwipe 中注册底部工具条,保留 Naive Image 预览常用的向左旋转、向右旋转、还原、缩小、放大、下载、关闭按钮;默认 PhotoSwipe 顶栏关闭/缩放/计数被关闭,避免重复。工具条按钮通过 `appendTo: root` 创建后再用微任务移动到自建 `.artveris-pswp-toolbar`,避免 PhotoSwipe 默认 append 时机把按钮重新挂回根节点导致不可见。图片按钮在视频项自动置灰,视频仍使用现有 video 控件。已用 Codex 内置浏览器验证:作品图片和认证文件预览均显示 7 个底部按钮,放大按钮和鼠标滚轮缩放均生效。 +- 后台图片预览工具条国际化(2026-07-05):`openMediaViewer` 不再硬编码工具条 title,统一从 `pages.mediaViewer.*` 读取翻译;`zh-CN/en-US` 已覆盖旋转、还原、缩放、下载、关闭。已用 Codex 内置浏览器切换英文后台验证,预览工具条按钮 title 为 `Rotate left / Rotate right / Reset / Zoom out / Zoom in / Download / Close`。 ## 当前代码基准与注意事项 diff --git a/apps/admin/src/composables/openMediaViewer.ts b/apps/admin/src/composables/openMediaViewer.ts index dea0c38..b4784b1 100644 --- a/apps/admin/src/composables/openMediaViewer.ts +++ b/apps/admin/src/composables/openMediaViewer.ts @@ -1,6 +1,7 @@ import PhotoSwipe from 'photoswipe'; import PhotoSwipeLightbox from 'photoswipe/lightbox'; import 'photoswipe/style.css'; +import { i18n } from '@/locales'; export interface MediaViewerItem { url?: string; @@ -194,6 +195,10 @@ function icon(paths: string): string { return ``; } +function translate(key: string): string { + return i18n.global.t(key); +} + function registerToolbarButton( lightbox: PhotoSwipeLightbox, options: { @@ -244,7 +249,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { lightbox.on('uiRegister', () => { registerToolbarButton(lightbox, { name: 'rotate-left', - title: '向左旋转', + title: translate('pages.mediaViewer.rotateLeft'), order: 41, html: icon(''), imageOnly: true, @@ -252,7 +257,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { }); registerToolbarButton(lightbox, { name: 'rotate-right', - title: '向右旋转', + title: translate('pages.mediaViewer.rotateRight'), order: 42, html: icon(''), imageOnly: true, @@ -260,7 +265,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { }); registerToolbarButton(lightbox, { name: 'reset', - title: '还原', + title: translate('pages.mediaViewer.reset'), order: 43, html: icon(''), imageOnly: true, @@ -268,7 +273,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { }); registerToolbarButton(lightbox, { name: 'zoom-out', - title: '缩小', + title: translate('pages.mediaViewer.zoomOut'), order: 44, html: icon(''), imageOnly: true, @@ -276,7 +281,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { }); registerToolbarButton(lightbox, { name: 'zoom-in', - title: '放大', + title: translate('pages.mediaViewer.zoomIn'), order: 45, html: icon(''), imageOnly: true, @@ -284,7 +289,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { }); registerToolbarButton(lightbox, { name: 'download', - title: '下载', + title: translate('pages.mediaViewer.download'), order: 46, html: icon(''), imageOnly: true, @@ -292,7 +297,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void { }); registerToolbarButton(lightbox, { name: 'bottom-close', - title: '关闭', + title: translate('pages.mediaViewer.close'), order: 47, html: icon(''), onClick: (instance) => instance?.close?.(), diff --git a/apps/admin/src/locales/en-US.json b/apps/admin/src/locales/en-US.json index 4d2d14b..cdb97f6 100644 --- a/apps/admin/src/locales/en-US.json +++ b/apps/admin/src/locales/en-US.json @@ -450,6 +450,15 @@ "passwordMismatch": "Passwords do not match", "changed": "Password changed, please log in again" }, + "mediaViewer": { + "rotateLeft": "Rotate left", + "rotateRight": "Rotate right", + "reset": "Reset", + "zoomOut": "Zoom out", + "zoomIn": "Zoom in", + "download": "Download", + "close": "Close" + }, "operationLog": { "keywordPlaceholder": "Account / summary / path / target ID", "module": "Module", diff --git a/apps/admin/src/locales/zh-CN.json b/apps/admin/src/locales/zh-CN.json index 9a483b5..9ccedf0 100644 --- a/apps/admin/src/locales/zh-CN.json +++ b/apps/admin/src/locales/zh-CN.json @@ -450,6 +450,15 @@ "passwordMismatch": "两次密码不一致", "changed": "密码修改成功,请重新登录" }, + "mediaViewer": { + "rotateLeft": "向左旋转", + "rotateRight": "向右旋转", + "reset": "还原", + "zoomOut": "缩小", + "zoomIn": "放大", + "download": "下载", + "close": "关闭" + }, "operationLog": { "keywordPlaceholder": "账号 / 摘要 / 路径 / 目标 ID", "module": "模块",