Quellcode durchsuchen

携带token默认登陆并调整智能选址

maxiaoxiao vor 8 Monaten
Ursprung
Commit
d93750c415
1 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen
  1. 13 2
      src/router/index.js

+ 13 - 2
src/router/index.js

@@ -1,7 +1,7 @@
 import Vue from 'vue'
 import Router from 'vue-router'
 import { hidden_xzqh, hidden_wall } from "@/common/js/cockpit.js";
-
+import { setToken } from '@/utils/auth'
 Vue.use(Router)
 
 
@@ -152,6 +152,17 @@ const router = new Router({
     scrollBehavior: () => ({ y: 0 }),
     routes: constantRoutes
 })
-
+router.beforeEach(async (to, from, next) => {
+    // document.title = getPageTitle(to.meta.title)
+    var hrefs = to.path//window.location.href 
+    let hrefIdx = hrefs.indexOf('token=');
+    let token = hrefs.substring(hrefIdx + 10, hrefs.length);
+    if (hrefIdx > -1) {
+        setToken(token)
+        next('/siteselection');
+    } else {
+        next()
+    }
+})
 
 export default router;