소스 검색

tj

master
yinshaojie 9 달 전
부모
커밋
f76c594d27
3개의 변경된 파일44개의 추가작업 그리고 12개의 파일을 삭제
  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 파일 보기

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

+ 18
- 9
RuoYi-App/pages/login.vue 파일 보기

94
       //   this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
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
       async handleLogin() {
116
       async handleLogin() {
108
         if (this.loginForm.username === "") {
117
         if (this.loginForm.username === "") {

+ 15
- 0
RuoYi-App/router/index.js 파일 보기

41
     path: '/pages/book/list',
41
     path: '/pages/book/list',
42
     name: 'BookList',
42
     name: 'BookList',
43
     component: () => import('@/pages/book/list')
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
 

Loading…
취소
저장