Skip to content

Commit

Permalink
update document.title supports i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
lemorili committed Jan 25, 2018
1 parent 5b3de41 commit 0e393e1
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 0e393e1

Please sign in to comment.