/**
- 创建全局路由钩子
*/
router.beforeEach((to, from, next) => {
let workspaceId = _.get(to, 'params.workId') || _.get(to, 'params.workspaceId');
if (workspaceId) {
_tool.setCookie('workId', _.get(to, 'params.workId'), 1);
}
if (to.path.includes('emailView') || to.path.includes('snapshotDisplay') || to.path.includes('saveSnapshotWithUrl') || to.path.includes('newSaveSnapshotWithUrl') || to.path.includes('repoDisplay') || to.path.includes('/huaxiang/projectAbility') || to.path.includes('/huaxiang/instituteAbility') || to.path.includes('/savaSnapShotUrlToIcenter') || to.path.includes('/snapshotDisplayToIcenter') || to.path.includes('/toIcenterApplicationDisplay')) {
_tool.setCookie('userId', 1, 1);
next();
} else if (!to.path.includes('login') && !_tool.getCookie('userId')) {
if (confirm('自定义视图是大数据分析平台的子系统。您在自定义视图的登陆已超时。请返回大数据分析平台重新登陆。')) {
if (isProduction) {
const name = window.location.hostname;
const protocol = 'https:';
window.location.href =${protocol}//${name}/index
;
} else {
next({
path: '/login'
});
}
} else {
if (isProduction) {
next({
path: '/page404'
});
} else {
next({
path: '/login'
});
}
}
} else {
next();
}
})