fix: 完善后台预览工具条翻译
This commit is contained in:
@@ -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`。
|
||||
|
||||
## 当前代码基准与注意事项
|
||||
|
||||
|
||||
@@ -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 `<svg viewBox="0 0 24 24" aria-hidden="true">${paths}</svg>`;
|
||||
}
|
||||
|
||||
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('<path d="M4 7v5h5"/><path d="M5.5 12a7 7 0 1 0 2-5"/><path d="M4 7l3.5-.2"/>'),
|
||||
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('<path d="M20 7v5h-5"/><path d="M18.5 12a7 7 0 1 1-2-5"/><path d="M20 7l-3.5-.2"/>'),
|
||||
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('<path d="M8 3h8v4"/><path d="M16 3l-9 9 5 5 9-9"/><path d="M5 19h14"/>'),
|
||||
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('<circle cx="11" cy="11" r="6"/><path d="M8.5 11h5"/><path d="M16 16l4 4"/>'),
|
||||
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('<circle cx="11" cy="11" r="6"/><path d="M8.5 11h5"/><path d="M11 8.5v5"/><path d="M16 16l4 4"/>'),
|
||||
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('<path d="M12 4v10"/><path d="M8 10l4 4 4-4"/><path d="M5 20h14"/>'),
|
||||
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('<path d="M6 6l12 12"/><path d="M18 6L6 18"/>'),
|
||||
onClick: (instance) => instance?.close?.(),
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -450,6 +450,15 @@
|
||||
"passwordMismatch": "两次密码不一致",
|
||||
"changed": "密码修改成功,请重新登录"
|
||||
},
|
||||
"mediaViewer": {
|
||||
"rotateLeft": "向左旋转",
|
||||
"rotateRight": "向右旋转",
|
||||
"reset": "还原",
|
||||
"zoomOut": "缩小",
|
||||
"zoomIn": "放大",
|
||||
"download": "下载",
|
||||
"close": "关闭"
|
||||
},
|
||||
"operationLog": {
|
||||
"keywordPlaceholder": "账号 / 摘要 / 路径 / 目标 ID",
|
||||
"module": "模块",
|
||||
|
||||
Reference in New Issue
Block a user