Merge pull request #463 from lemori/dev
update Util.title to support i18n
This commit is contained in:
commit
cfe93bb7c2
|
|
@ -6,9 +6,12 @@ import packjson from '../../package.json';
|
|||
let util = {
|
||||
|
||||
};
|
||||
util.title = function (title) {
|
||||
title = title || 'iView admin';
|
||||
window.document.title = title;
|
||||
util.title = function (title, vm) {
|
||||
let iTitle = 'iView admin';
|
||||
if (title) {
|
||||
iTitle += ' - ' + (title.i18n ? vm.$t(title.i18n) : title);
|
||||
}
|
||||
window.document.title = iTitle;
|
||||
};
|
||||
|
||||
const ajaxUrl = env === 'development'
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export const router = new VueRouter(RouterConfig);
|
|||
|
||||
router.beforeEach((to, from, next) => {
|
||||
iView.LoadingBar.start();
|
||||
Util.title(to.meta.title);
|
||||
Util.title(to.meta.title, router.app);
|
||||
if (Cookies.get('locking') === '1' && to.name !== 'locking') { // 判断当前是否是锁定状态
|
||||
next({
|
||||
replace: true,
|
||||
|
|
@ -37,6 +37,9 @@ router.beforeEach((to, from, next) => {
|
|||
});
|
||||
} else {
|
||||
const curRouterObj = Util.getRouterObjByName([otherRouter, ...appRouter], to.name);
|
||||
if (curRouterObj && curRouterObj.title) {
|
||||
Util.title(curRouterObj.title, router.app);
|
||||
}
|
||||
if (curRouterObj && curRouterObj.access !== undefined) { // 需要判断权限的路由
|
||||
if (curRouterObj.access === parseInt(Cookies.get('access'))) {
|
||||
Util.toDefaultPage([otherRouter, ...appRouter], to.name, router, next); // 如果在地址栏输入的是一级菜单则默认打开其第一个二级菜单的页面
|
||||
|
|
|
|||
Loading…
Reference in New Issue