yinshaojie před 9 měsíci
rodič
revize
f76c594d27
3 změnil soubory, kde provedl 44 přidání a 12 odebrání
  1. 11
    3
      RuoYi-App/App.vue
  2. 18
    9
      RuoYi-App/pages/login.vue
  3. 15
    0
      RuoYi-App/router/index.js

+ 11
- 3
RuoYi-App/App.vue Zobrazit soubor

@@ -21,6 +21,10 @@ import config from './config'
21 21
 import { getToken } from '@/utils/auth'
22 22
 
23 23
 export default {
24
+	mounted() {
25
+    // 确保方法名称正确
26
+    this.checkRouteAuth();
27
+	},
24 28
   name: 'App',
25 29
   provide() {
26 30
     return {
@@ -97,6 +101,12 @@ export default {
97 101
     }
98 102
   },
99 103
   methods: {
104
+	      checkRouteAuth() {
105
+	        const noAuthPaths = ['/', '/home', '/novel'];
106
+	        if (!noAuthPaths.includes(this.$route.path)) {
107
+	          // 需要登录的路径处理
108
+	        }
109
+	      },
100 110
       reload() {
101 111
       this.isRouterAlive = false
102 112
       this.$nextTick(() => {
@@ -220,9 +230,7 @@ export default {
220 230
       }
221 231
     }
222 232
   },
223
-    mounted() {
224
-      this.checkInitialRoute();
225
-    },
233
+
226 234
   watch: {
227 235
     '$route.path': {
228 236
       immediate: true,

+ 18
- 9
RuoYi-App/pages/login.vue Zobrazit soubor

@@ -94,15 +94,24 @@
94 94
       //   this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
95 95
       // },
96 96
       // 获取图形验证码
97
-      getCode() {
98
-        getCodeImg().then(res => {
99
-          this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
100
-          if (this.captchaEnabled) {
101
-            this.codeUrl = 'data:image/gif;base64,' + res.img
102
-            this.loginForm.uuid = res.uuid
103
-          }
104
-        })
105
-      },
97
+      // getCode() {
98
+      //   getCodeImg().then(res => {
99
+      //     this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
100
+      //     if (this.captchaEnabled) {
101
+      //       this.codeUrl = 'data:image/gif;base64,' + res.img
102
+      //       this.loginForm.uuid = res.uuid
103
+      //     }
104
+      //   })
105
+      // },
106
+	  // 获取验证码
107
+	  getCode() {
108
+	    this.$axios.get('/captchaImage').then(res => {
109
+	      this.codeUrl = 'data:image/png;base64,' + res.data.img;
110
+	      this.loginForm.uuid = res.data.uuid;
111
+	    }).catch(() => {
112
+	      this.$message.error("验证码获取失败");
113
+	    });
114
+	  },
106 115
       // 登录方法
107 116
       async handleLogin() {
108 117
         if (this.loginForm.username === "") {

+ 15
- 0
RuoYi-App/router/index.js Zobrazit soubor

@@ -41,6 +41,21 @@ const routes = [
41 41
     path: '/pages/book/list',
42 42
     name: 'BookList',
43 43
     component: () => import('@/pages/book/list')
44
+  },
45
+  {
46
+    path: '/bookshelf',
47
+    component: () => import('@/views/bookshelf'),
48
+    meta: { requiresAuth: true } // 需要登录
49
+  },
50
+  {
51
+    path: '/mine',
52
+    component: () => import('@/views/mine'),
53
+    meta: { requiresAuth: true } // 需要登录
54
+  },
55
+  {
56
+    path: '/',
57
+    component: () => import('@/views/home'),
58
+    meta: { requiresAuth: false } // 不需要登录
44 59
   }
45 60
 ]
46 61
 

Načítá se…
Zrušit
Uložit