fix: 首次访问获取客户端默认语言/静态路由title

This commit is contained in:
TsMask
2023-11-20 18:12:29 +08:00
parent 9fdd322757
commit e9054e320f
13 changed files with 142 additions and 35 deletions

View File

@@ -1,15 +1,16 @@
<script lang="ts" setup>
import { GlobalFooter } from '@ant-design-vue/pro-layout';
import { Modal, message } from 'ant-design-vue/lib';
import { reactive, toRaw } from 'vue';
import { onMounted, reactive, toRaw } from 'vue';
import { register } from '@/api/login';
import { regExpPasswd, regExpUserName } from '@/utils/regular-utils';
import { useRouter } from 'vue-router';
import { useRouter, useRoute } from 'vue-router';
import useAppStore from '@/store/modules/app';
import useI18n from '@/hooks/useI18n';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
const appStore = useAppStore();
let state = reactive({
@@ -68,6 +69,21 @@ function fnFinish() {
state.formClick = false;
});
}
/**
* 国际化翻译转换
*/
function fnLocale() {
let title = route.meta.title as string;
if (title.indexOf('router.') !== -1) {
title = t(title);
}
appStore.setTitle(title);
}
onMounted(() => {
fnLocale();
});
</script>
<template>