From b0b03a30e4edc01bfa48296ebadf16e89e3def52 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 18 Jul 2023 16:16:55 +0800 Subject: [PATCH 01/16] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96`transformI18n`?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E5=9B=BD=E9=99=85=E5=8C=96=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=97=A0=E9=99=90=E5=B5=8C=E5=A5=97=E7=BA=A7=E5=88=AB?= =?UTF-8?q?=EF=BC=88=E5=BD=93=E7=84=B6=E5=B9=B3=E5=8F=B0=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=B5=8C=E5=A5=97=E5=B1=82=E7=BA=A7=E8=B6=8A?= =?UTF-8?q?=E5=B0=91=E8=B6=8A=E5=A5=BD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/i18n.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 98fa6b803..ec53256b9 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -1,8 +1,8 @@ // 多组件库的国际化和本地项目国际化兼容 import { App, WritableComputedRef } from "vue"; -import { storageLocal } from "@pureadmin/utils"; import { type I18n, createI18n } from "vue-i18n"; import { responsiveStorageNameSpace } from "@/config"; +import { storageLocal, isObject } from "@pureadmin/utils"; // element-plus国际化 import enLocale from "element-plus/lib/locale/lang/en"; @@ -30,6 +30,30 @@ export const localesConfigs = { } }; +/** 获取对象中所有嵌套对象的key键,并将它们用点号分割组成字符串 */ +function getObjectKeys(obj) { + const stack = []; + const keys = []; + + stack.push({ obj, key: "" }); + + while (stack.length > 0) { + const { obj, key } = stack.pop(); + + for (const k in obj) { + const newKey = key ? `${key}.${k}` : k; + + if (obj[k] && isObject(obj[k])) { + stack.push({ obj: obj[k], key: newKey }); + } else { + keys.push(newKey); + } + } + } + + return keys; +} + /** * 国际化转换工具函数(自动读取根目录locales文件夹下文件进行国际化匹配) * @param message message @@ -47,8 +71,9 @@ export function transformI18n(message: any = "") { return message[locale?.value]; } - const key = message.match(/(\S*)\./)?.[1]; - if (key && Object.keys(siphonI18n("zh-CN")).includes(key)) { + const key = message.match(/(\S*)\./)?.input; + + if (key && getObjectKeys(siphonI18n("zh-CN")).find(item => item === key)) { return i18n.global.t.call(i18n.global.locale, message); } else if (!key && Object.keys(siphonI18n("zh-CN")).includes(message)) { // 兼容非嵌套形式的国际化写法 From 711504d5ac26737d2196704aa480ebec6651e116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E5=8F=AA=E5=89=8D=E7=AB=AF=E6=B1=AA?= <985313519@qq.com> Date: Tue, 18 Jul 2023 19:01:09 +0800 Subject: [PATCH 02/16] chore: fix typos (#641) --- CHANGELOG.en_US.md | 2 +- CHANGELOG.md | 2 +- CHANGELOG.zh_CN.md | 2 +- locales/en.yaml | 2 +- locales/zh-CN.yaml | 2 +- mock/list.ts | 2 +- src/router/modules/able.ts | 8 ++++---- src/views/able/{execl.vue => excel.vue} | 2 +- src/views/pure-table/high/list.tsx | 10 +++++----- 9 files changed, 16 insertions(+), 16 deletions(-) rename src/views/able/{execl.vue => excel.vue} (99%) diff --git a/CHANGELOG.en_US.md b/CHANGELOG.en_US.md index cfc5cde0c..887fc72af 100644 --- a/CHANGELOG.en_US.md +++ b/CHANGELOG.en_US.md @@ -465,7 +465,7 @@ - Add full routing configuration table type declaration - Add virtual listing page demo - Add `PDF` preview page demo -- Added export `execl` page demo +- Added export `excel` page demo - Added blank page demo without `Layout` ### ✔️ refactor diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc5cde0c..887fc72af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -465,7 +465,7 @@ - Add full routing configuration table type declaration - Add virtual listing page demo - Add `PDF` preview page demo -- Added export `execl` page demo +- Added export `excel` page demo - Added blank page demo without `Layout` ### ✔️ refactor diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 5c7f0fc5c..1feecc231 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -464,7 +464,7 @@ - 添加完整路由配置表类型声明 - 添加虚拟列表页面 demo - 添加 `PDF` 预览页面 demo -- 添加导出 `execl` 页面 demo +- 添加导出 `excel` 页面 demo - 添加无 `Layout` 的空白页面 demo ### ✔️ refactor diff --git a/locales/en.yaml b/locales/en.yaml index 3aa1465b3..3a6f0531f 100644 --- a/locales/en.yaml +++ b/locales/en.yaml @@ -100,7 +100,7 @@ menus: hsSwiper: Swiper Plugin hsVirtualList: Virtual List hsPdf: PDF Preview - hsExecl: Export Excel + hsExcel: Export Excel hsInfiniteScroll: Table Infinite Scroll hsSensitive: Sensitive Filter hsPinyin: PinYin diff --git a/locales/zh-CN.yaml b/locales/zh-CN.yaml index 1f3e12866..407970de3 100644 --- a/locales/zh-CN.yaml +++ b/locales/zh-CN.yaml @@ -100,7 +100,7 @@ menus: hsSwiper: Swiper插件 hsVirtualList: 虚拟列表 hsPdf: PDF预览 - hsExecl: 导出Excel + hsExcel: 导出Excel hsInfiniteScroll: 表格无限滚动 hsSensitive: 敏感词过滤 hsPinyin: 汉语拼音 diff --git a/mock/list.ts b/mock/list.ts index 805ef2a9a..08e6b10ca 100644 --- a/mock/list.ts +++ b/mock/list.ts @@ -609,7 +609,7 @@ export default [ { created_at: "2022-08-19T07:29:06Z", published_at: "2022-08-19T07:31:08Z", - body: "# 3.3.5 (2022-8-19)\r\n\r\n### 🎫 Feat\r\n\r\n- 将 `element-plus` 的 `Table` 二次封装到[@pureadmin/table](https://github.com/xiaoxian521/pure-admin-table),提供灵活的配置项并集成到平台里\r\n- 将 `element-plus` 的 `Descriptions` 二次封装到[@pureadmin/descriptions](https://github.com/xiaoxian521/pure-admin-descriptions),提供灵活的配置项并集成到平台里\r\n- 将平台的大部分工具以及 hooks 都集中到[@pureadmin/utils](https://pure-admin-utils-docs.vercel.app/),并删除集中到这个库里的代码,减少平台体积\r\n- 添加[unplugin-vue-define-options](https://www.npmjs.com/package/unplugin-vue-define-options)插件,页面可直接写 `defineOptions({name: 自定义名称})`\r\n- 添加项目文件、语言分析工具 [cloc](https://www.npmjs.com/package/cloc)\r\n- 添加登陆页国际化\r\n- 添加完整路由配置表类型声明\r\n- 添加虚拟列表页面 demo\r\n- 添加 `PDF` 预览页面 demo\r\n- 添加导出 `execl` 页面 demo\r\n- 添加无 `Layout` 的空白页面 demo\r\n\r\n### ✔️ refactor\r\n\r\n- 重构主题色,适配 `element-plus` 暗黑模式(同时也解决了 `3.3.0` 及更低版本中同样的元素 `css` 被多次覆盖,导致样式不好调试的问题)\r\n- 重构路由重置功能\r\n\r\n### 🍏 Perf\r\n\r\n- 兼容项目存放目录以中文命名,但我们真心不推荐中文命名,因为可能某个库没有对中文路径做转义处理,导致项目奔溃\r\n- 优化接口类型\r\n\r\n### 🐞 Bug fixes\r\n\r\n- 修复路由 `showlink` 为 `false` 的异步路由,刷新后不显示\r\n- 修复当没有 `icon` 时,垂直导航菜单折叠后文字被隐藏" + body: "# 3.3.5 (2022-8-19)\r\n\r\n### 🎫 Feat\r\n\r\n- 将 `element-plus` 的 `Table` 二次封装到[@pureadmin/table](https://github.com/xiaoxian521/pure-admin-table),提供灵活的配置项并集成到平台里\r\n- 将 `element-plus` 的 `Descriptions` 二次封装到[@pureadmin/descriptions](https://github.com/xiaoxian521/pure-admin-descriptions),提供灵活的配置项并集成到平台里\r\n- 将平台的大部分工具以及 hooks 都集中到[@pureadmin/utils](https://pure-admin-utils-docs.vercel.app/),并删除集中到这个库里的代码,减少平台体积\r\n- 添加[unplugin-vue-define-options](https://www.npmjs.com/package/unplugin-vue-define-options)插件,页面可直接写 `defineOptions({name: 自定义名称})`\r\n- 添加项目文件、语言分析工具 [cloc](https://www.npmjs.com/package/cloc)\r\n- 添加登陆页国际化\r\n- 添加完整路由配置表类型声明\r\n- 添加虚拟列表页面 demo\r\n- 添加 `PDF` 预览页面 demo\r\n- 添加导出 `excel` 页面 demo\r\n- 添加无 `Layout` 的空白页面 demo\r\n\r\n### ✔️ refactor\r\n\r\n- 重构主题色,适配 `element-plus` 暗黑模式(同时也解决了 `3.3.0` 及更低版本中同样的元素 `css` 被多次覆盖,导致样式不好调试的问题)\r\n- 重构路由重置功能\r\n\r\n### 🍏 Perf\r\n\r\n- 兼容项目存放目录以中文命名,但我们真心不推荐中文命名,因为可能某个库没有对中文路径做转义处理,导致项目奔溃\r\n- 优化接口类型\r\n\r\n### 🐞 Bug fixes\r\n\r\n- 修复路由 `showlink` 为 `false` 的异步路由,刷新后不显示\r\n- 修复当没有 `icon` 时,垂直导航菜单折叠后文字被隐藏" }, { created_at: "2022-05-11T07:51:38Z", diff --git a/src/router/modules/able.ts b/src/router/modules/able.ts index 35bbcdd64..cab42343e 100644 --- a/src/router/modules/able.ts +++ b/src/router/modules/able.ts @@ -149,11 +149,11 @@ export default { } }, { - path: "/able/execl", - name: "Execl", - component: () => import("@/views/able/execl.vue"), + path: "/able/excel", + name: "Excel", + component: () => import("@/views/able/excel.vue"), meta: { - title: $t("menus.hsExecl") + title: $t("menus.hsExcel") } }, { diff --git a/src/views/able/execl.vue b/src/views/able/excel.vue similarity index 99% rename from src/views/able/execl.vue rename to src/views/able/excel.vue index 17f4ab087..504dad8e8 100644 --- a/src/views/able/execl.vue +++ b/src/views/able/excel.vue @@ -72,7 +72,7 @@ const exportExcel = () => {