|
@@ -1,9 +1,8 @@
|
|
|
import router from './router';
|
|
|
-import { getSessionID } from '@/utils/auth';
|
|
|
+import { getSessionID, getConfig } from '@/utils/auth';
|
|
|
|
|
|
import NProgress from 'nprogress';
|
|
|
import 'nprogress/nprogress.css';
|
|
|
-
|
|
|
NProgress.configure({ showSpinner: false });
|
|
|
|
|
|
const whiteList = ['/login', '/EnterSys']; // 重定向白名单
|
|
@@ -12,8 +11,9 @@ const whiteList = ['/login', '/EnterSys']; // 重定向白名单
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
NProgress.start();
|
|
|
|
|
|
- const session_id = getSessionID();
|
|
|
- if (session_id) {
|
|
|
+ const { isHas } = getConfig();
|
|
|
+
|
|
|
+ if (getSessionID() && isHas) {
|
|
|
if (to.path === '/login') {
|
|
|
next({ path: '/' });
|
|
|
NProgress.done();
|
|
@@ -25,7 +25,11 @@ router.beforeEach(async (to, from, next) => {
|
|
|
next();
|
|
|
} else {
|
|
|
// 其他无权访问的页面将重定向到登录页面
|
|
|
- next('/login');
|
|
|
+ if (process.env.NODE_ENV === 'production') {
|
|
|
+ window.location.href = '/';
|
|
|
+ } else {
|
|
|
+ next('/login');
|
|
|
+ }
|
|
|
NProgress.done();
|
|
|
}
|
|
|
});
|