This commit is contained in:
刘旋 2023-03-31 14:18:25 +08:00
parent c3b5dec7af
commit c8804abb43
6 changed files with 60 additions and 29 deletions

View File

@ -59,6 +59,22 @@
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<el-dropdown :show-timeout="70" :hide-timeout="50" trigger="click" @command="onLanguageChange">
<div class="layout-navbars-breadcrumb-user-icon">
<i
class="iconfont"
:class="state.disabledI18n === 'en' ? 'icon-fuhao-yingwen' : 'icon-fuhao-zhongwen'"
></i>
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="zh-cn" :disabled="state.disabledI18n === 'zh-cn'">English</el-dropdown-item>
<el-dropdown-item command="en" :disabled="state.disabledI18n === 'en'">简体中文</el-dropdown-item>
<!-- <el-dropdown-item command="zh-tw" :disabled="state.disabledI18n === 'zh-tw'">繁體中文</el-dropdown-item> -->
</el-dropdown-menu>
</template>
</el-dropdown>
<Search ref="searchRef" /> <Search ref="searchRef" />
</div> </div>
</template> </template>
@ -74,10 +90,22 @@ import { useThemeConfig } from '/@/stores/themeConfig';
import mittBus from '/@/utils/mitt'; import mittBus from '/@/utils/mitt';
import { Session, Local } from '/@/utils/storage'; import { Session, Local } from '/@/utils/storage';
import { refreshToken } from '/@/api/system/user.js' import { refreshToken } from '/@/api/system/user.js'
import { useTranslate } from '/@/stores/translate';
import other from '/@/utils/other';
// //
const UserNews = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/userNews.vue')); const UserNews = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/userNews.vue'));
const Search = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/search.vue')); const Search = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/search.vue'));
const useTranslateStore=useTranslate()
const onLanguageChange = (lang) => {
if(lang=="en"){
state.disabledI18n="en"
useTranslateStore.translate_control=0
}
else{
state.disabledI18n="zh-cn"
useTranslateStore.translate_control=1
}
};
// //
const router = useRouter(); const router = useRouter();
const stores = useUserInfo(); const stores = useUserInfo();
@ -89,7 +117,8 @@ const searchRef = ref();
const state = reactive({ const state = reactive({
isScreenfull: false, isScreenfull: false,
disabledSize: 'large', disabledSize: 'large',
setIntervalId: null setIntervalId: null,
disabledI18n:"en",
}); });
// //

View File

@ -11,7 +11,7 @@
<el-sub-menu :index="val.path" v-if="val.children && val.children.length > 0" :key="val.path"> <el-sub-menu :index="val.path" v-if="val.children && val.children.length > 0" :key="val.path">
<template #title> <template #title>
<SvgIcon :name="val.meta.icon" /> <SvgIcon :name="val.meta.icon" />
<span>{{ val.meta.title }}</span> <span v-text="useTranslateStore.translate_control===1?val.meta.title :val.meta.zh"></span>
</template> </template>
<SubItem :chil="val.children" /> <SubItem :chil="val.children" />
</el-sub-menu> </el-sub-menu>
@ -19,7 +19,7 @@
<el-menu-item :index="val.path" :key="val.path"> <el-menu-item :index="val.path" :key="val.path">
<SvgIcon :name="val.meta.icon" /> <SvgIcon :name="val.meta.icon" />
<template #title v-if="!val.meta.isLink || (val.meta.isLink && val.meta.isIframe)"> <template #title v-if="!val.meta.isLink || (val.meta.isLink && val.meta.isIframe)">
<span>{{ val.meta.title }}</span> <span v-text="useTranslateStore.translate_control===1?val.meta.title :val.meta.zh"></span>
</template> </template>
<template #title v-else> <template #title v-else>
<a class="w100" @click.prevent="onALinkClick(val)">{{ val.meta.title }}</a> <a class="w100" @click.prevent="onALinkClick(val)">{{ val.meta.title }}</a>
@ -36,7 +36,8 @@ import { useRoute, onBeforeRouteUpdate } from 'vue-router';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useThemeConfig } from '/@/stores/themeConfig'; import { useThemeConfig } from '/@/stores/themeConfig';
import other from '/@/utils/other'; import other from '/@/utils/other';
import { useTranslate } from '/@/stores/translate';
const useTranslateStore=useTranslate()
// //
const SubItem = defineAsyncComponent(() => import('/@/layout/navMenu/subItem.vue')); const SubItem = defineAsyncComponent(() => import('/@/layout/navMenu/subItem.vue'));

View File

@ -41,6 +41,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin', 'chief'], roles: ['admin', 'chief'],
icon: 'iconfont icon-shouye', icon: 'iconfont icon-shouye',
zh:"控制台"
}, },
}, },
{ {
@ -57,6 +58,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin'], roles: ['admin'],
icon: 'iconfont icon-xitongshezhi', icon: 'iconfont icon-xitongshezhi',
zh:"响应管理"
}, },
children: [ children: [
{ {
@ -72,6 +74,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin'], roles: ['admin'],
icon: 'iconfont icon-caidan', icon: 'iconfont icon-caidan',
zh:"用户响应管理"
}, },
}, },
{ {
@ -87,6 +90,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin'], roles: ['admin'],
icon: 'ele-ColdDrink', icon: 'ele-ColdDrink',
zh:"管理员管理"
}, },
}, },
{ {
@ -102,6 +106,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin', 'chief'], roles: ['admin', 'chief'],
icon: 'iconfont icon-icon-', icon: 'iconfont icon-icon-',
zh:"数据上传管理"
}, },
}, },
], ],
@ -120,6 +125,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin', 'chief'], roles: ['admin', 'chief'],
icon: 'iconfont icon-xitongshezhi', icon: 'iconfont icon-xitongshezhi',
zh:"数据服务"
}, },
children: [ children: [
{ {
@ -135,6 +141,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin', 'chief'], roles: ['admin', 'chief'],
icon: 'iconfont icon-caidan', icon: 'iconfont icon-caidan',
zh:"多媒体数据"
}, },
}, },
{ {
@ -150,6 +157,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin', 'chief'], roles: ['admin', 'chief'],
icon: 'ele-ColdDrink', icon: 'ele-ColdDrink',
zh:"遥感数据"
}, },
}, },
{ {
@ -165,6 +173,7 @@ export const dynamicRoutes = [
isIframe: false, isIframe: false,
roles: ['admin', 'chief'], roles: ['admin', 'chief'],
icon: 'ele-ColdDrink', icon: 'ele-ColdDrink',
zh:"其他数据服务"
}, },
}, },
], ],
@ -326,6 +335,7 @@ export const notFoundAndNoPower = [
meta: { meta: {
title: '页面找不到', title: '页面找不到',
isHide: true, isHide: true,
zh:"页面找不到"
}, },
}, },
{ {
@ -335,6 +345,7 @@ export const notFoundAndNoPower = [
meta: { meta: {
title: '页面无权限', title: '页面无权限',
isHide: true, isHide: true,
zh:"页面无权限"
}, },
}, },
]; ];
@ -352,6 +363,7 @@ export const staticRoutes = [
component: () => import('/@/views/login/index.vue'), component: () => import('/@/views/login/index.vue'),
meta: { meta: {
title: '登录', title: '登录',
zh:"登录"
}, },
}, },
]; ];

View File

@ -1,19 +0,0 @@
import { defineStore } from "pinia";
import { Names } from "./store_name";
export const useVariableStore = defineStore(Names.TEST, {
state: () => {
return {
}
},
getters: {
},
actions: {
}
})

View File

@ -1,4 +0,0 @@
export const enum Names {
TEST = "TEST"
}

12
src/stores/translate.js Normal file
View File

@ -0,0 +1,12 @@
import { defineStore } from 'pinia';
export const useTranslate = defineStore('themeConfig',{
state: () => ({
translate_control:0
}),
getters: {
},
actions:{
}
})