update 菜单国际化
This commit is contained in:
@@ -3,6 +3,7 @@ import Router from 'vue-router'
|
||||
import http from '@/utils/request'
|
||||
import { isURL } from '@/utils/validate'
|
||||
import Cookies from 'js-cookie'
|
||||
import i18n from '@/i18n'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
@@ -104,6 +105,13 @@ router.beforeEach((to, from, next) => {
|
||||
http.get(http.adornUrl('/sys/menu/nav')).then(({ data: res }) => {
|
||||
/** axios 的拦截器已经拦截出错情况,此处只考虑正确情况即可 */
|
||||
window.SITE_CONFIG['menuList'] = res.data
|
||||
// .map(item => {
|
||||
// if (item.name === '产品池') {
|
||||
// console.log('Got you')
|
||||
// item.name =
|
||||
// }
|
||||
// return item
|
||||
// })
|
||||
fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
|
||||
next({ ...to, replace: true })
|
||||
}).catch((err) => {
|
||||
@@ -139,6 +147,8 @@ function fnAddDynamicMenuRoutes(menuList = [], routes = []) {
|
||||
|
||||
for (var i = 0; i < menuList.length; i++) {
|
||||
if (menuList[i].children && menuList[i].children.length >= 1) {
|
||||
// 菜单的国际化
|
||||
menuList[i].name = i18n.t(`routes["${menuList[i].name}"]`)
|
||||
temp = temp.concat(menuList[i].children)
|
||||
continue
|
||||
}
|
||||
@@ -150,9 +160,15 @@ function fnAddDynamicMenuRoutes(menuList = [], routes = []) {
|
||||
meta: {
|
||||
...window.SITE_CONFIG['contentTabDefault'],
|
||||
menuId: menuList[i].id,
|
||||
title: menuList[i].name
|
||||
// 菜单的国际化
|
||||
title: i18n.t(`routes["${menuList[i].name}"]`)
|
||||
}
|
||||
}
|
||||
|
||||
// 菜单的国际化
|
||||
menuList[i].name = i18n.t(`routes["${menuList[i].name}"]`)
|
||||
|
||||
console.log('route ===', route.meta.title)
|
||||
// eslint-disable-next-line
|
||||
let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2)) // URL支持{{ window.xxx }}占位符变量
|
||||
if (isURL(URL)) {
|
||||
|
||||
Reference in New Issue
Block a user