task-271(验收反馈): Element Plus 全局接入 zh-cn 语言包(日期控件/分页组件中文)

This commit is contained in:
2026-09-06 01:44:06 +08:00
parent c381527528
commit 9ac4eda054
3 changed files with 53 additions and 24 deletions
+11
View File
@@ -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')
@@ -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 全局 localedate-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 语言包文件存在',
)
})
@@ -1,24 +0,0 @@
-- V100: 后台 admin 菜单 route_path 更新为新版 Vue History 路由
-- 仅更新 route_pathcolumn_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';