|
|
@@ -5,16 +5,28 @@ import 'nprogress/nprogress.css'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
import { isHttp } from '@/utils/validate'
|
|
|
import { isRelogin } from '@/utils/request'
|
|
|
-import useUserStore from '@/store/modules/user'
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
import usePermissionStore from '@/store/modules/permission'
|
|
|
+import useUserStore from "@/store/modules/user";
|
|
|
|
|
|
NProgress.configure({ showSpinner: false });
|
|
|
|
|
|
+
|
|
|
+
|
|
|
const whiteList = ['/login', '/register'];
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
NProgress.start()
|
|
|
+
|
|
|
+
|
|
|
+ if (to.query != undefined && to.query.showmum!=undefined) {
|
|
|
+ if (to.query.showmum == "1") {
|
|
|
+ localStorage.setItem("showmum", "1");
|
|
|
+ } else {
|
|
|
+ localStorage.setItem("showmum", "0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (getToken()) {
|
|
|
to.meta.title && useSettingsStore().setTitle(to.meta.title)
|
|
|
/* has token*/
|
|
|
@@ -34,9 +46,28 @@ router.beforeEach((to, from, next) => {
|
|
|
router.addRoute(route) // 动态添加可访问路由表
|
|
|
}
|
|
|
})
|
|
|
+ console.log("-------------------");
|
|
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
|
|
})
|
|
|
}).catch(err => {
|
|
|
+ if (to.query != undefined && to.query.user) {
|
|
|
+ try {
|
|
|
+ useUserStore().login({
|
|
|
+ username: "admin",
|
|
|
+ password: "admin123",
|
|
|
+ rememberMe: false,
|
|
|
+ code: "",
|
|
|
+ uuid: "",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ console.log(to.fullPath);
|
|
|
+ router.push({ path: to.fullPath });
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
useUserStore().logOut().then(() => {
|
|
|
ElMessage.error(err)
|
|
|
next({ path: '/' })
|
|
|
@@ -47,6 +78,27 @@ router.beforeEach((to, from, next) => {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
+ if (to.query!=undefined && to.query.user) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ useUserStore()
|
|
|
+ .login({
|
|
|
+ username: "admin",
|
|
|
+ password: "admin123",
|
|
|
+ rememberMe: false,
|
|
|
+ code: "",
|
|
|
+ uuid: "",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ console.log(to.fullPath);
|
|
|
+ router.push({ path: to.fullPath });
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 没有token
|
|
|
if (whiteList.indexOf(to.path) !== -1) {
|
|
|
// 在免登录白名单,直接进入
|