hookehuyr

refactor(router): 修改用户信息接口路径并模拟测试接口

将 `getUserInfoAPI` 的路径从 `@/api/user` 更改为 `@/api/users`,并暂时注释掉异步逻辑以模拟测试接口
1 /* 1 /*
2 * @Date: 2025-03-20 20:36:36 2 * @Date: 2025-03-20 20:36:36
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-03-26 09:45:57 4 + * @LastEditTime: 2025-03-26 09:55:40
5 * @FilePath: /mlaj/src/router/guards.js 5 * @FilePath: /mlaj/src/router/guards.js
6 * @Description: 路由守卫逻辑 6 * @Description: 路由守卫逻辑
7 */ 7 */
8 import { getAuthInfoAPI } from '@/api/auth' 8 import { getAuthInfoAPI } from '@/api/auth'
9 -import { getUserInfoAPI } from '@/api/user' 9 +import { getUserInfoAPI } from '@/api/users'
10 import { wxInfo } from "@/utils/tools" 10 import { wxInfo } from "@/utils/tools"
11 11
12 // 需要登录才能访问的路由 12 // 需要登录才能访问的路由
...@@ -53,18 +53,20 @@ export const checkWxAuth = async () => { ...@@ -53,18 +53,20 @@ export const checkWxAuth = async () => {
53 } 53 }
54 54
55 // 登录权限检查 55 // 登录权限检查
56 -export const checkAuth = async (to) => { 56 +export const checkAuth = (to) => {
57 - try { 57 + // TODO: 模拟测试接口
58 - // 先请求用户信息接口 58 + // export const checkAuth = async (to) => {
59 - const { code, data } = await getUserInfoAPI(); 59 + // try {
60 - if (code) { 60 + // // 先请求用户信息接口
61 - // 如果成功获取用户信息,更新currentUser并允许访问 61 + // const { code, data } = await getUserInfoAPI();
62 - localStorage.setItem('currentUser', JSON.stringify(data)); 62 + // if (code) {
63 - return true; 63 + // // 如果成功获取用户信息,更新currentUser并允许访问
64 - } 64 + // localStorage.setItem('currentUser', JSON.stringify(data));
65 - } catch (error) { 65 + // return true;
66 - console.error('获取用户信息失败:', error); 66 + // }
67 - } 67 + // } catch (error) {
68 + // console.error('获取用户信息失败:', error);
69 + // }
68 70
69 // 如果接口请求失败或返回401,继续原有的本地存储判断逻辑 71 // 如果接口请求失败或返回401,继续原有的本地存储判断逻辑
70 const currentUser = JSON.parse(localStorage.getItem('currentUser')) 72 const currentUser = JSON.parse(localStorage.getItem('currentUser'))
......