From e8e514f6ddaabc0f1ed820aca5572d3accc6fbdb Mon Sep 17 00:00:00 2001 From: Nixevol Date: Sun, 5 Jul 2026 04:14:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E4=B8=BB=E9=A2=98=E5=88=87=E6=8D=A2=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=AF=BC=E5=87=BA=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aidocs/project_context.md | 2 + apps/admin/src/components/TraceCodePanel.vue | 11 +- apps/admin/src/locales/en-US.json | 2 +- apps/admin/src/locales/zh-CN.json | 2 +- apps/client/src/components/ThemeSwitch.vue | 150 +++++++++++++++++++ apps/client/src/composables/useTheme.ts | 46 ++++++ apps/client/src/main.ts | 1 + apps/client/src/styles.css | 24 +++ apps/client/src/views/Home.vue | 13 +- apps/client/src/views/Trace.vue | 28 ++++ 10 files changed, 273 insertions(+), 6 deletions(-) create mode 100644 apps/client/src/components/ThemeSwitch.vue create mode 100644 apps/client/src/composables/useTheme.ts diff --git a/aidocs/project_context.md b/aidocs/project_context.md index e28fa25..8e09294 100644 --- a/aidocs/project_context.md +++ b/aidocs/project_context.md @@ -149,6 +149,8 @@ - 追溯码管理入口与筛选修正(2026-07-05):全局 `/trace-codes` 从隐藏页恢复为左侧独立导航“追溯码管理”,仍保留艺术品详情页的数据管理入口;艺术品档案列表中点击“档案编号”改为进入作品编辑/详情页,右侧“数据管理”图标继续进入该档案追溯码管理。追溯码管理搜索框加宽,后端关键词搜索扩展到追溯码、完整编码、链接、档案编号、名称、艺术家、批次编号、分组名称和备注。分组管理接口不带参数时仍返回全部分组;生成追溯码弹窗会预加载作品下拉,避免初次点开显示无数据,并在选择作品后按该作品已有追溯码使用过的分组加载分组选项。 - 追溯码搜索框宽度微调(2026-07-05):追溯码管理工具栏搜索框按扩展后的占位提示加宽,桌面端使用 `width: min(560px, 46vw)` 且最小 420px,小屏仍由媒体查询切换为 100% 宽,避免提示文案被过早截断。 - 追溯码导出按钮交互(2026-07-05):全局追溯码管理页和档案内追溯码管理页共用 `TraceCodePanel`,导出按钮由下拉菜单改为单击即导出;导出范围按“已勾选 > 当前筛选 > 全部”自动判断,按钮文案分别显示“导出(已选x项)”“导出(当前筛选)”或“导出”。固定档案页自身的 `artworkId` 不算用户筛选,全局页 URL/表头/关键词筛选会计入“当前筛选”。 +- 客户端主题切换与导出防重复(2026-07-05):客户端新增轻量主题状态 `apps/client/src/composables/useTheme.ts` 和 `ThemeSwitch.vue`,首页与溯源详情页均显示主题切换按钮;默认主题为 `auto` 跟随系统,手动选择浅色/深色时写入 `localStorage: artveris_client_theme` 并通过 `html[data-theme]` 覆盖 CSS 变量。追溯码管理导出按钮新增 `exporting` loading/禁用状态,下载处理过程中会阻止重复点击。 +- 溯源模板字段标识提示(2026-07-05):模板字段配置中“英文标识”输入框占位提示缩短为“英文唯一标识”(英文:`Unique English key`),避免窄输入框内示例文本过长导致显示不全。 ## 当前代码基准与注意事项 diff --git a/apps/admin/src/components/TraceCodePanel.vue b/apps/admin/src/components/TraceCodePanel.vue index da70fc8..12174d2 100644 --- a/apps/admin/src/components/TraceCodePanel.vue +++ b/apps/admin/src/components/TraceCodePanel.vue @@ -17,7 +17,7 @@ {{ t('pages.traceCode.manageGroups') }} - + {{ exportButtonText }} @@ -277,6 +277,7 @@ const qrModal = ref(false); const qrSrc = ref(''); const qrUrl = ref(''); let qrBlobUrl = ''; +const exporting = ref(false); const groupModal = ref(false); const groupForm = reactive<{ name: string }>({ name: '' }); @@ -577,6 +578,7 @@ const exportButtonText = computed(() => { }); async function onExport() { + if (exporting.value) return; const params: Record = {}; if (checkedKeys.value.length) { params.ids = checkedKeys.value.map(String).join(','); @@ -589,7 +591,12 @@ async function onExport() { if (query.outboundStatus) params.outboundStatus = query.outboundStatus; if (query.keyword) params.keyword = query.keyword; } - await downloadFile('/trace-codes/export', 'trace-codes.zip', params); + exporting.value = true; + try { + await downloadFile('/trace-codes/export', 'trace-codes.zip', params); + } finally { + exporting.value = false; + } } async function batchAssignGroup(key: string) { diff --git a/apps/admin/src/locales/en-US.json b/apps/admin/src/locales/en-US.json index f2a2cf3..8f1fd3f 100644 --- a/apps/admin/src/locales/en-US.json +++ b/apps/admin/src/locales/en-US.json @@ -204,7 +204,7 @@ "create": "New Template", "edit": "Edit Template", "namePlaceholder": "Enter template name", - "fieldKeyTip": "Unique key, e.g. craft", + "fieldKeyTip": "Unique English key", "sortHint": "Field order = display order on consumer page; use arrows to reorder", "defaultFields": { "craft": "Craft", diff --git a/apps/admin/src/locales/zh-CN.json b/apps/admin/src/locales/zh-CN.json index 90e5be1..56d497e 100644 --- a/apps/admin/src/locales/zh-CN.json +++ b/apps/admin/src/locales/zh-CN.json @@ -204,7 +204,7 @@ "create": "新建模板", "edit": "编辑模板", "namePlaceholder": "请输入模板名称", - "fieldKeyTip": "英文唯一标识,如 craft", + "fieldKeyTip": "英文唯一标识", "sortHint": "字段顺序即客户端展示顺序,可用上下箭头调整", "defaultFields": { "craft": "工艺", diff --git a/apps/client/src/components/ThemeSwitch.vue b/apps/client/src/components/ThemeSwitch.vue new file mode 100644 index 0000000..14138c4 --- /dev/null +++ b/apps/client/src/components/ThemeSwitch.vue @@ -0,0 +1,150 @@ + + + + + diff --git a/apps/client/src/composables/useTheme.ts b/apps/client/src/composables/useTheme.ts new file mode 100644 index 0000000..ffd0f7f --- /dev/null +++ b/apps/client/src/composables/useTheme.ts @@ -0,0 +1,46 @@ +import { computed, ref } from 'vue'; + +export type ThemeMode = 'light' | 'dark' | 'auto'; + +const KEY = 'artveris_client_theme'; +const modes: ThemeMode[] = ['light', 'dark', 'auto']; +const media = window.matchMedia('(prefers-color-scheme: dark)'); +const systemDark = ref(media.matches); + +media.addEventListener('change', (event) => { + systemDark.value = event.matches; +}); + +function getInitialMode(): ThemeMode { + const saved = localStorage.getItem(KEY) as ThemeMode | null; + return saved && modes.includes(saved) ? saved : 'auto'; +} + +const mode = ref(getInitialMode()); +const isDark = computed(() => mode.value === 'dark' || (mode.value === 'auto' && systemDark.value)); + +function applyTheme() { + const root = document.documentElement; + if (mode.value === 'auto') { + root.removeAttribute('data-theme'); + } else { + root.setAttribute('data-theme', mode.value); + } + root.style.colorScheme = isDark.value ? 'dark' : 'light'; +} + +export function setThemeMode(next: ThemeMode) { + mode.value = next; + localStorage.setItem(KEY, next); + applyTheme(); +} + +export function initTheme() { + applyTheme(); +} + +export function useTheme() { + return { mode, isDark, setThemeMode }; +} + +initTheme(); diff --git a/apps/client/src/main.ts b/apps/client/src/main.ts index 8223169..ea1fce6 100644 --- a/apps/client/src/main.ts +++ b/apps/client/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from 'vue'; import App from './App.vue'; import router from './router'; import { i18n } from './locales'; +import './composables/useTheme'; import './styles.css'; createApp(App).use(router).use(i18n).mount('#app'); diff --git a/apps/client/src/styles.css b/apps/client/src/styles.css index 8ee0d27..6f887bf 100644 --- a/apps/client/src/styles.css +++ b/apps/client/src/styles.css @@ -23,6 +23,30 @@ --shell-shadow: 0 0 24px rgba(0, 0, 0, 0.24); } } +:root[data-theme='light'] { + color-scheme: light; + --brand: #1f3864; + --brand-2: #2e5496; + --bg: #f3f5f9; + --card-bg: #fff; + --soft-bg: #f6f8fb; + --border: #d0d7e2; + --text: #1f2937; + --muted: #6b7280; + --shell-shadow: 0 0 24px rgba(0, 0, 0, 0.04); +} +:root[data-theme='dark'] { + color-scheme: dark; + --brand: #7dd3fc; + --brand-2: #5eead4; + --bg: #0f172a; + --card-bg: #111827; + --soft-bg: #1f2937; + --border: #334155; + --text: #e5e7eb; + --muted: #94a3b8; + --shell-shadow: 0 0 24px rgba(0, 0, 0, 0.24); +} * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; diff --git a/apps/client/src/views/Home.vue b/apps/client/src/views/Home.vue index 94f2d24..aa41188 100644 --- a/apps/client/src/views/Home.vue +++ b/apps/client/src/views/Home.vue @@ -3,7 +3,10 @@

{{ t('home.title') }}

{{ t('home.hint') }}

- +
+ + +