个人中心全部,模糊乱序搜索,类型筛选
Change-Id: Id635654fccccaea80bfbf4d1480abd55f7d12046
diff --git a/src/api/auth.js b/src/api/auth.js
index 4b569ef..c094a44 100644
--- a/src/api/auth.js
+++ b/src/api/auth.js
@@ -32,21 +32,25 @@
});
};
-
-export const getUserInfo = (token) => {
- return api.get('/user/info', { params: { token } });
+export const getUserInfo = async () => {
+ try {
+ const response = await api.get('/user/userInfo');
+ if (response.data.code === 200) {
+ return response.data.data;
+ }
+ throw new Error(response.data.message || '获取用户信息失败');
+ } catch (error) {
+ console.error('获取用户信息失败:', error);
+ throw error;
+ }
};
-// // 修改你的 API 请求
-// export const getUserInfo = () => {
-// const token = localStorage.getItem('token');
-// if (!token) {
-// throw new Error("Token 不存在");
-// }
-
-// return api.get('/user/info', {
-// headers: {
-// 'Authorization': `Bearer ${token}` // 必须带 Bearer 前缀
-// }
-// });
-// };
+export const isAdmin = async () => {
+ try {
+ const userInfo = await getUserInfo();
+ return userInfo.authority === 'ADMIN';
+ } catch (error) {
+ console.error('检查管理员权限失败:', error);
+ return false;
+ }
+};