fix: i18n (#110)

This commit is contained in:
hb0730
2021-11-16 09:53:46 +08:00
committed by GitHub
parent aa8005a982
commit 44a4c9346b
7 changed files with 26 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
import { getMessage } from "/@/utils/i18n";
import { transformI18n } from "/@/utils/i18n";
const levelList = ref([]);
const route = useRoute();
@@ -38,9 +38,6 @@ watch(
() => route.path,
() => getBreadcrumb()
);
const getI18nMessage = meta => {
return getMessage(meta.title, meta.i18n);
};
const handleLink = (item: RouteLocationMatched): any => {
const { redirect, path } = item;
@@ -59,10 +56,10 @@ const handleLink = (item: RouteLocationMatched): any => {
<span
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
class="no-redirect"
>{{ getI18nMessage(item.meta) }}</span
>{{ transformI18n(item.meta.title, item.meta.i18n) }}</span
>
<a v-else @click.prevent="handleLink(item)">
{{ getI18nMessage(item.meta) }}
{{ transformI18n(item.meta.title, item.meta.i18n) }}
</a>
</el-breadcrumb-item>
</transition-group>

View File

@@ -4,7 +4,7 @@ import { PropType, ref, nextTick, getCurrentInstance } from "vue";
import { childrenType } from "../../types";
import { useAppStoreHook } from "/@/store/modules/app";
import Icon from "/@/components/ReIcon/src/Icon.vue";
import { getMessage } from "/@/utils/i18n";
import { transformI18n } from "/@/utils/i18n";
import { findIconReg } from "/@/components/ReIcon";
const instance = getCurrentInstance().appContext.app.config.globalProperties;
const menuMode = instance.$storage.layout?.layout === "vertical";
@@ -111,7 +111,7 @@ function resolvePath(routePath) {
}"
>
<span v-if="!menuMode">{{
getMessage(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
}}</span>
<el-tooltip
v-else
@@ -120,7 +120,9 @@ function resolvePath(routePath) {
:disabled="!onlyOneChild.showTooltip"
>
<template #content>
{{ getMessage(onlyOneChild.meta.title, onlyOneChild.meta.i18n) }}
{{
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
}}
</template>
<span
ref="menuTextRef"
@@ -131,7 +133,9 @@ function resolvePath(routePath) {
}"
@mouseover="hoverMenu(onlyOneChild)"
>
{{ getMessage(onlyOneChild.meta.title, onlyOneChild.meta.i18n) }}
{{
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
}}
</span>
</el-tooltip>
<Icon
@@ -157,7 +161,7 @@ function resolvePath(routePath) {
></component>
</el-icon>
<span v-if="!menuMode">{{
getMessage(props.item.meta.title, props.item.meta.i18n)
transformI18n(props.item.meta.title, props.item.meta.i18n)
}}</span>
<el-tooltip
v-else
@@ -166,7 +170,7 @@ function resolvePath(routePath) {
:disabled="!pureApp.sidebar.opened || !props.item.showTooltip"
>
<template #content>
{{ getMessage(props.item.meta.title, props.item.meta.i18n) }}
{{ transformI18n(props.item.meta.title, props.item.meta.i18n) }}
</template>
<div
ref="menuTextRef"
@@ -179,7 +183,7 @@ function resolvePath(routePath) {
@mouseover="hoverMenu(props.item)"
>
<span style="overflow: hidden; text-overflow: ellipsis">
{{ getMessage(props.item.meta.title, props.item.meta.i18n) }}
{{ transformI18n(props.item.meta.title, props.item.meta.i18n) }}
</span>
</div>
</el-tooltip>