فهرست منبع

feat: 登录权限放开

mnisting 6 ماه پیش
والد
کامیت
a3591525ba
4فایلهای تغییر یافته به همراه15 افزوده شده و 19 حذف شده
  1. 3 4
      src/permission.js
  2. 0 3
      src/store/modules/permission.js
  3. 9 8
      src/store/modules/user.js
  4. 3 4
      src/views/login.vue

+ 3 - 4
src/permission.js

@@ -16,10 +16,7 @@ const isWhiteList = (path) => {
 };
 
 router.beforeEach((to, from, next) => {
-  // NProgress.start();
-  store.dispatch("GenerateRoutes");
-  next();
-  return;
+  NProgress.start();
   if (getToken()) {
     to.meta.title && store.dispatch("settings/setTitle", to.meta.title);
     /* has token*/
@@ -29,7 +26,9 @@ router.beforeEach((to, from, next) => {
     } else if (isWhiteList(to.path)) {
       next();
     } else {
+      console.log(1111);
       if (store.getters.roles.length === 0) {
+        console.log(2222);
         isRelogin.show = true;
         // 判断当前用户是否已拉取完user_info信息
         store

+ 0 - 3
src/store/modules/permission.js

@@ -32,9 +32,6 @@ const permission = {
     // 生成路由
     GenerateRoutes({ commit }) {
       return new Promise((resolve) => {
-        commit("SET_SIDEBAR_ROUTERS", constantRoutes);
-        resolve();
-        return;
         // 向后端请求路由数据
         getRouters().then((res) => {
           const sdata = JSON.parse(JSON.stringify(res.data));

+ 9 - 8
src/store/modules/user.js

@@ -42,14 +42,15 @@ const user = {
       const code = userInfo.code;
       const uuid = userInfo.uuid;
       return new Promise((resolve, reject) => {
-        // login(username, password, code, uuid).then(res => {
-        //   setToken(res.token)
-        //   commit('SET_TOKEN', res.token)
-        //   resolve()
-        // }).catch(error => {
-        //   reject(error)
-        // })
-        resolve();
+        login(username, password, code, uuid)
+          .then((res) => {
+            setToken(res.token);
+            commit("SET_TOKEN", res.token);
+            resolve();
+          })
+          .catch((error) => {
+            reject(error);
+          });
       });
     },
 

+ 3 - 4
src/views/login.vue

@@ -36,7 +36,7 @@
           />
         </el-input>
       </el-form-item>
-      <!-- <el-form-item prop="code" v-if="captchaEnabled">
+      <el-form-item prop="code" v-if="captchaEnabled">
         <el-input
           v-model="loginForm.code"
           auto-complete="off"
@@ -53,7 +53,7 @@
         <div class="login-code">
           <img :src="codeUrl" @click="getCode" class="login-code-img" />
         </div>
-      </el-form-item> -->
+      </el-form-item>
       <el-checkbox
         v-model="loginForm.rememberMe"
         style="margin: 0px 0px 25px 0px"
@@ -127,7 +127,7 @@ export default {
     },
   },
   created() {
-    // this.getCode();
+    this.getCode();
     this.getCookie();
   },
   methods: {
@@ -172,7 +172,6 @@ export default {
           this.$store
             .dispatch("Login", this.loginForm)
             .then(() => {
-              console.log(111);
               this.$router.push({ path: "/" }).catch(() => {});
             })
             .catch(() => {