From 4305eb3fe6018c06c01f70f407a54ceab9fd91e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=8C=E7=B3=96=E5=8C=85=E5=AD=90?= Date: Tue, 2 Jun 2026 09:52:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A5=E5=85=A5=20vue-i18n=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=85=A8=E7=AB=99=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 引入 vue-i18n,支持简体中文、繁体中文、英文三种语言。 提取所有页面硬编码中文为国际化词条,Header 右上角新增语言切换下拉菜单。 语言偏好存储于 localStorage,首次访问根据 navigator.language 自动检测。 同步切换 Element Plus 组件语言,校验规则改为 computed 保证切换后实时更新。 --- components.d.ts | 1 - package-lock.json | 83 +++++ package.json | 1 + src/App.vue | 15 +- src/components/CaptchaPanel.vue | 5 +- src/config/menu.ts | 32 +- src/i18n/index.ts | 49 +++ src/i18n/locales/en.ts | 343 +++++++++++++++++++ src/i18n/locales/zh-CN.ts | 343 +++++++++++++++++++ src/i18n/locales/zh-TW.ts | 343 +++++++++++++++++++ src/main.ts | 9 +- src/router.ts | 20 +- src/utils/http.ts | 14 +- src/views/Home.vue | 88 +++-- src/views/Login.vue | 38 +- src/views/Welcome.vue | 11 +- src/views/api/Hitokoto.vue | 51 +-- src/views/api/HitokotoAdd.vue | 23 +- src/views/api/Music.vue | 150 ++++---- src/views/api/PhotoWall.vue | 63 ++-- src/views/api/SourceImage.vue | 43 +-- src/views/api/aplayer/music-player-panel.vue | 29 +- src/views/debug/CaptchaSandbox.vue | 31 +- src/views/system/Article.vue | 58 ++-- src/views/system/Statistics.vue | 39 ++- src/views/system/SystemConfig.vue | 44 +-- src/views/system/SystemConfigAdd.vue | 25 +- src/views/system/SystemRole.vue | 54 +-- src/views/system/SystemUser.vue | 56 +-- src/vite-env.d.ts | 8 +- 30 files changed, 1662 insertions(+), 407 deletions(-) create mode 100644 src/i18n/index.ts create mode 100644 src/i18n/locales/en.ts create mode 100644 src/i18n/locales/zh-CN.ts create mode 100644 src/i18n/locales/zh-TW.ts diff --git a/components.d.ts b/components.d.ts index 65b1657..03d8e9c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -31,7 +31,6 @@ declare module '@vue/runtime-core' { ElIcon: typeof import('element-plus/es')['ElIcon'] ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] ElInput: typeof import('element-plus/es')['ElInput'] - ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElMain: typeof import('element-plus/es')['ElMain'] ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] diff --git a/package-lock.json b/package-lock.json index cf02ad7..8c7929a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "moment": "^2.30.1", "pretty-bytes": "^5.6.0", "vue": "^3.5.30", + "vue-i18n": "^11.4.4", "vue-router": "^4.6.4", "vuex": "^4.1.0" }, @@ -153,6 +154,67 @@ "@floating-ui/core": "^1.0.5" } }, + "node_modules/@intlify/core-base": { + "version": "11.4.4", + "resolved": "http://192.168.102.20:28080/repository/npm/@intlify/core-base/-/core-base-11.4.4.tgz", + "integrity": "sha512-w/vItlylrAmhebkIbVl5YY8XMCtj8Mb2g70ttxktMYuf5AuRahgEHL2iLgLIsZBIbTSgs4hkUo7ucCL0uTJvOg==", + "license": "MIT", + "dependencies": { + "@intlify/devtools-types": "11.4.4", + "@intlify/message-compiler": "11.4.4", + "@intlify/shared": "11.4.4" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/devtools-types": { + "version": "11.4.4", + "resolved": "http://192.168.102.20:28080/repository/npm/@intlify/devtools-types/-/devtools-types-11.4.4.tgz", + "integrity": "sha512-PcBLmGmDQsTSVV911P8upzpcLJO1CNVYi/IH6bGnLR2nA+0L963+kXN1ZrisTEnbtw2ewN6HMMSldqzjronA0Q==", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "11.4.4", + "@intlify/shared": "11.4.4" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "11.4.4", + "resolved": "http://192.168.102.20:28080/repository/npm/@intlify/message-compiler/-/message-compiler-11.4.4.tgz", + "integrity": "sha512-vn0OAV9pYkJlPPmgnsSm5eAG3mL0+9C/oaded2JY9jmxBbhmUXT3TcAUY8WRgLY9Hte7lkUJKpXrVlYjMXBD2w==", + "license": "MIT", + "dependencies": { + "@intlify/shared": "11.4.4", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/shared": { + "version": "11.4.4", + "resolved": "http://192.168.102.20:28080/repository/npm/@intlify/shared/-/shared-11.4.4.tgz", + "integrity": "sha512-QRUCHqda1U6aR14FR0vvXD4+4gj6+fm0AhAozvSuRCw0fCvrmCugWpgiR4xH2NI6s8am6N9p5OhirplsX8ZS3g==", + "license": "MIT", + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -2737,6 +2799,27 @@ } } }, + "node_modules/vue-i18n": { + "version": "11.4.4", + "resolved": "http://192.168.102.20:28080/repository/npm/vue-i18n/-/vue-i18n-11.4.4.tgz", + "integrity": "sha512-gIbXVSFQV4jcSJxfwdZ5zSZmZ+12CnX0K3vBkRSd6Zn+HSzCp+QwUgPwpD/uN0oKNKI9RzlUXPKVedEuMgNG0A==", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "11.4.4", + "@intlify/devtools-types": "11.4.4", + "@intlify/shared": "11.4.4", + "@vue/devtools-api": "^6.5.0" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, "node_modules/vue-router": { "version": "4.6.4", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.6.4.tgz", diff --git a/package.json b/package.json index 4d10562..24fb838 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "moment": "^2.30.1", "pretty-bytes": "^5.6.0", "vue": "^3.5.30", + "vue-i18n": "^11.4.4", "vue-router": "^4.6.4", "vuex": "^4.1.0" }, diff --git a/src/App.vue b/src/App.vue index 479bcf5..78b2b6a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,13 +1,24 @@