mjh před 3 roky
rodič
revize
d103a94efe

+ 5 - 8
src/router/index.js

@@ -135,6 +135,11 @@ const routes = [
     path: "/courseWare/:courseWareId/details",
     name: "courseWareDetails",
     component: ()=>import("../views/CourseWarePage/CourseWarePage")
+  },
+  {
+    path: "/root",
+    name: "Root",
+    component: ()=>import("../views/RootPage/index.vue")
   }
 ];
 
@@ -146,14 +151,6 @@ const router = createRouter({
 const unauthorizedRoutes = ["Portal", "Auth", "Course", "Test","Project", "CompletePhone"];
 
 router.beforeEach((to, from, next) => {
-  let token = localStorage.getItem("token");
-    // else if (token && to.name === "courseWareDetails") {
-    //   console.log(localStorage);
-    //   if (localStorage.s === "true") {
-    //     console.log(3);
-    //     next();
-    //   }
-    // }
     if (unauthorizedRoutes.indexOf(to.name) !== -1) {
       next();
     }

+ 5 - 3
src/views/AuthPage/components/AuthCard.vue

@@ -334,14 +334,12 @@ export default {
               this.$apis.loginAPI(params)
                 .then((res) => {
                   if (res.data.code === 0) {
-                    console.log(res);
                     if (this.rememberMe) {
                       localStorage.phone = this.cardForm.phone;
                       localStorage.password = this.cardForm.password;
                       localStorage.rememberMe = this.rememberMe;
                       this.st="true";//修改登录状态为true
                       localStorage.setItem("s",this.st);
-                      console.log(localStorage);
                     } else {
                       localStorage.removeItem("rememberMe");
                       localStorage.removeItem("phone");
@@ -362,7 +360,11 @@ export default {
                         if (this.$route.params.login_to) {
                           this.$router.push(String(this.$route.params.login_to));
                         } else {
-                          this.$router.push("/portal");
+                          if(res.data.data.user.role === "ADMIN"){
+                            this.$router.push("/root");
+                          }else{
+                            this.$router.push("/portal");
+                          }
                         }
                       } else {
                         let p = new Promise(function (resolve, reject) {

+ 13 - 0
src/views/RootPage/index.vue

@@ -0,0 +1,13 @@
+<template>
+  <div>root</div>
+</template>
+
+<script>
+export default {
+  name: "RootPage"
+};
+</script>
+
+<style scoped>
+
+</style>