From 9f8c08558e350dbae3881fb70ee06be8d5d1a754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com> Date: Fri, 11 Feb 2022 13:58:25 +0800 Subject: [PATCH] new document customization language pack --- example/src/layouts/Layout.vue | 12 +++++++----- example/src/locales/en_US.ts | 8 ++++++++ example/src/locales/zh_CN.ts | 8 ++++++++ example/src/router/zh-CN.ts | 6 +++--- example/src/view/{ecology.vue => environment.vue} | 0 src/component/avatar/index.vue | 4 +++- 6 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 example/src/locales/en_US.ts create mode 100644 example/src/locales/zh_CN.ts rename example/src/view/{ecology.vue => environment.vue} (100%) diff --git a/example/src/layouts/Layout.vue b/example/src/layouts/Layout.vue index cb49bc11..16684a22 100644 --- a/example/src/layouts/Layout.vue +++ b/example/src/layouts/Layout.vue @@ -17,13 +17,13 @@ {{ t('nav.home')}}
  • - 指南 + {{ t('nav.guide')}}
  • - 组件 + {{ t('nav.components') }}
  • - 生态 + {{ t('nav.environment') }}
  • @@ -73,6 +73,8 @@ import { ref, watch } from "vue"; import { useRouter, useRoute } from "vue-router"; import menu from "../view/utils/menus"; import { useI18n } from 'vue-i18n'; +import zh_CN from "../locales/zh_CN.ts"; +import en_US from "../locales/en_US.ts"; export default { setup() { @@ -85,8 +87,8 @@ export default { const locale = ref('zh_CN'); // 扩展语言包 const locales = [ - {name:'zh_CN',locale: {nav: { home: '首页' }}, merge: true}, - {name:'en_US',locale: {nav: { home: 'Home' }}, merge: true} + {name:'zh_CN',locale: zh_CN, merge: true}, + {name:'en_US',locale: en_US, merge: true} ] // 当前主题 const theme = "light"; diff --git a/example/src/locales/en_US.ts b/example/src/locales/en_US.ts new file mode 100644 index 00000000..2be5945e --- /dev/null +++ b/example/src/locales/en_US.ts @@ -0,0 +1,8 @@ +export default { + nav: { + home:"Home", + guide: "Guide", + components: "Components", + environment: "Environment" + } +} \ No newline at end of file diff --git a/example/src/locales/zh_CN.ts b/example/src/locales/zh_CN.ts new file mode 100644 index 00000000..bd2ecdd1 --- /dev/null +++ b/example/src/locales/zh_CN.ts @@ -0,0 +1,8 @@ +export default { + nav: { + home:"首页", + guide: "指南", + components: "组件", + environment: "生态" + } +} \ No newline at end of file diff --git a/example/src/router/zh-CN.ts b/example/src/router/zh-CN.ts index 05e8c87a..c9fba0e5 100644 --- a/example/src/router/zh-CN.ts +++ b/example/src/router/zh-CN.ts @@ -3,7 +3,7 @@ import Component from "../view/component.vue"; import Hooks from "../view/hooks.vue"; import Guide from "../view/guide.vue"; import Index from "../view/index.vue"; -import Ecology from "../view/ecology.vue"; +import Environment from "../view/environment.vue"; const zhCN = [ { @@ -18,8 +18,8 @@ const zhCN = [ meta: { title: "指南" }, }, { - path: "/zh-CN/ecology", - component: Ecology, + path: "/zh-CN/environment", + component: Environment, meta: { title: "生态" }, }, { diff --git a/example/src/view/ecology.vue b/example/src/view/environment.vue similarity index 100% rename from example/src/view/ecology.vue rename to example/src/view/environment.vue diff --git a/src/component/avatar/index.vue b/src/component/avatar/index.vue index b3b0c1c1..db7fb468 100644 --- a/src/component/avatar/index.vue +++ b/src/component/avatar/index.vue @@ -13,7 +13,9 @@ export interface LayAvatarProps { radius?: boolean; } -const props = withDefaults(defineProps(), {}); +const props = withDefaults(defineProps(), { + +});