From 9ac4eda054ed6c0cae6314d6cae3cc13dd6a7456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sun, 6 Sep 2026 01:44:06 +0800 Subject: [PATCH] =?UTF-8?q?task-271(=E9=AA=8C=E6=94=B6=E5=8F=8D=E9=A6=88):?= =?UTF-8?q?=20Element=20Plus=20=E5=85=A8=E5=B1=80=E6=8E=A5=E5=85=A5=20zh-c?= =?UTF-8?q?n=20=E8=AF=AD=E8=A8=80=E5=8C=85(=E6=97=A5=E6=9C=9F=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6/=E5=88=86=E9=A1=B5=E7=BB=84=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E6=96=87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-frontend-vue/src/main.ts | 11 +++++ admin-frontend-vue/tests/align-locale.test.ts | 42 +++++++++++++++++++ .../db/V100__admin_menu_frontend_routes.sql | 24 ----------- 3 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 admin-frontend-vue/src/main.ts create mode 100644 admin-frontend-vue/tests/align-locale.test.ts delete mode 100644 backend-java/src/main/resources/db/V100__admin_menu_frontend_routes.sql diff --git a/admin-frontend-vue/src/main.ts b/admin-frontend-vue/src/main.ts new file mode 100644 index 00000000..35cf95e7 --- /dev/null +++ b/admin-frontend-vue/src/main.ts @@ -0,0 +1,11 @@ +import { createApp } from 'vue' +import { createPinia } from 'pinia' +import ElementPlus from 'element-plus' +import zhCn from 'element-plus/es/locale/lang/zh-cn' +import 'element-plus/dist/index.css' +import '@/styles/main.css' +import App from './App.vue' +import router from './router' + +// 全局中文语言包:日期控件(周/月/年份)、分页组件(上一页/下一页)等均显示中文。 +createApp(App).use(createPinia()).use(router).use(ElementPlus, { locale: zhCn }).mount('#app') diff --git a/admin-frontend-vue/tests/align-locale.test.ts b/admin-frontend-vue/tests/align-locale.test.ts new file mode 100644 index 00000000..17b63a95 --- /dev/null +++ b/admin-frontend-vue/tests/align-locale.test.ts @@ -0,0 +1,42 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { existsSync } from 'node:fs' +import { readSource } from './helpers.ts' + +// 验收反馈:日期控件/分页组件需显示中文。 +// 不变式:应用入口为 Element Plus 注册 zh-cn 全局 locale(date-picker/pagination 全部跟随)。 + +test('align_locale_normal_primary_path', () => { + const main = readSource('src/main.ts') + assert.match(main, /zh-cn|zhCn/i, 'main.ts 应引入 element-plus 中文语言包') + assert.match(main, /locale\s*[:=]\s*zhCn|locale,\s*zhCn/, 'ElementPlus 注册需携带 locale 配置') +}) + +test('align_locale_normal_variant_input', () => { + // 语言包必须来自 element-plus 官方路径(es/locale 或 dist/locale),不接受自造空对象。 + const main = readSource('src/main.ts') + assert.match(main, /element-plus\/(es|dist)\/locale/, 'locale 导入需指向 element-plus 语言包') +}) + +test('align_locale_boundary_empty_input', () => { + // 日期控件页面依赖全局 locale,不得在页面内再覆盖为 en。 + const pages = [ + 'src/pages/asin/DedupeRegistryPage.vue', + 'src/pages/records/RecordsHistoryPage.vue', + 'src/pages/tasks/ImageVideoTasksPage.vue', + 'src/pages/tasks/ShopDataTasksPage.vue', + ] + for (const page of pages) { + const src = readSource(page) + assert.ok(!/locale\s*=\s*['"]en['"]/i.test(src), `${page} 不得局部覆盖英文 locale`) + } +}) + +test('align_locale_dependency_failure_returns_actionable_message', () => { + // zh-cn 语言包在 node_modules 中真实存在(安装依赖即有效)。 + assert.ok( + existsSync('node_modules/element-plus/es/locale/lang/zh-cn.mjs') || + existsSync('node_modules/element-plus/dist/locale/zh-cn.mjs'), + 'element-plus zh-cn 语言包文件存在', + ) +}) diff --git a/backend-java/src/main/resources/db/V100__admin_menu_frontend_routes.sql b/backend-java/src/main/resources/db/V100__admin_menu_frontend_routes.sql deleted file mode 100644 index 4f41a9d4..00000000 --- a/backend-java/src/main/resources/db/V100__admin_menu_frontend_routes.sql +++ /dev/null @@ -1,24 +0,0 @@ --- V100: 后台 admin 菜单 route_path 更新为新版 Vue History 路由 --- 仅更新 route_path,column_key / user_column_permission 一律不变(授权标识保持稳定)。 --- 迁移幂等:按 column_key 定位单行更新,重复执行结果一致;不删除任何授权数据。 - -UPDATE `columns` SET `route_path` = 'account/users' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_users'; - -UPDATE `columns` SET `route_path` = 'account/menus' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_columns'; - -UPDATE `columns` SET `route_path` = 'account/groups' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_group_manage'; - -UPDATE `columns` SET `route_path` = 'asin-center/registry' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_dedupe_total_data'; - -UPDATE `columns` SET `route_path` = 'shop-center/shops' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_shop_manage'; - -UPDATE `columns` SET `route_path` = 'records/history' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_history'; - -UPDATE `columns` SET `route_path` = 'records/software-version' -WHERE `menu_type` = 'admin' AND `column_key` = 'admin_version';