Skip to content

Commit

Permalink
Merge pull request #463 from lemori/dev
Browse files Browse the repository at this point in the history
update  Util.title to support i18n
  • Loading branch information
Lison committed Jul 9, 2018
2 parents 57afa62 + 0e393e1 commit cfe93bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/libs/util.js
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion src/router/index.js
Expand Up @@ -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,
Expand All @@ -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); // 如果在地址栏输入的是一级菜单则默认打开其第一个二级菜单的页面
Expand Down

0 comments on commit cfe93bb

Please sign in to comment.