Merge pull request #463 from lemori/dev

update  Util.title to support i18n
This commit is contained in:
Lison 2018-07-09 10:06:22 +08:00 committed by GitHub
commit cfe93bb7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -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'

View File

@ -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); // 如果在地址栏输入的是一级菜单则默认打开其第一个二级菜单的页面