diff --git a/src/features/auth/contexts/AuthContext.jsx b/src/features/auth/contexts/AuthContext.jsx
index 5f9b37e..b0afd8e 100644
--- a/src/features/auth/contexts/AuthContext.jsx
+++ b/src/features/auth/contexts/AuthContext.jsx
@@ -1,7 +1,13 @@
-import React, { createContext, useContext, useState, useEffect, useCallback } from 'react';
-import { loginUser, registerUser, getUserInfo, logoutUser } from '../services/authApi';
-import { message } from 'antd';
-import { useNavigate } from 'react-router-dom'; // 导入 useNavigate
+import React, {
+  createContext,
+  useContext,
+  useState,
+  useEffect,
+  useCallback,
+} from "react";
+import { userLogin, registerUser, logoutUser } from "@/api/auth";
+import { message } from "antd";
+import { useNavigate } from "react-router-dom"; // 导入 useNavigate
 
 const AuthContext = createContext(null);
 
@@ -14,22 +20,27 @@
   const loadAuthData = useCallback(() => {
     setLoading(true);
     try {
-      const storedToken = localStorage.getItem('authToken'); // 假设您使用token
-      const storedUser = localStorage.getItem('user');
+      const storedToken = localStorage.getItem("token");
+      const storedUser = localStorage.getItem("user");
+
+      console.log("Loading auth data - token:", !!storedToken, "user:", !!storedUser);
 
       if (storedToken && storedUser) {
-        setUser(JSON.parse(storedUser));
-        setIsAuthenticated(true);
-        // 调用API获取最新的用户信息
-        getUserInfo().then(response => { 
-          if (response.data && response.data.user) {
-            setUser(response.data.user);
-            localStorage.setItem('user', JSON.stringify(response.data.user));
-          }
-        }).catch(error => {
-          console.error("获取用户信息失败", error);
-        });
+        try {
+          const userData = JSON.parse(storedUser);
+          // console.log("Parsed user data:", userData);
+          setUser(userData);
+          setIsAuthenticated(true);
+        } catch (parseError) {
+          console.error("Failed to parse stored user data:", parseError);
+          // 如果解析失败，清除损坏的数据
+          localStorage.removeItem("token");
+          localStorage.removeItem("user");
+          setIsAuthenticated(false);
+          setUser(null);
+        }
       } else {
+        console.log("No stored auth data found");
         setIsAuthenticated(false);
         setUser(null);
       }
@@ -46,23 +57,32 @@
     loadAuthData();
   }, [loadAuthData]);
 
-  const login = async (credentials) => {
+  const login = async (params) => {
     setLoading(true);
     try {
-      const response = await loginUser(credentials);
-      const { token, user: userData } = response.data;
-      
-      localStorage.setItem('authToken', token);
-      localStorage.setItem('user', JSON.stringify(userData));
-      setUser(userData);
-      setIsAuthenticated(true);
-      message.success('登录成功');
-      return userData;
+      const response = await userLogin(params);
+      // 检查响应是否成功
+      if (response && response.data) {
+        const token = response.data.token;
+        const userData = response.data;
+        
+        console.log("Saving token:", token);
+        console.log("Saving user data:", userData);
+        
+        localStorage.setItem("token", token);
+        localStorage.setItem("user", JSON.stringify(userData));
+        
+        setUser(userData);
+        setIsAuthenticated(true);
+        
+        message.success(response?.message || "登录成功");
+        return userData;
+      }
     } catch (error) {
-      console.error("Login failed", error);
+      console.log("login error", error);
       setIsAuthenticated(false);
       setUser(null);
-      message.error(error.message || '登录失败，请检查用户名和密码');
+      message.error(error.message || "登录失败，请检查用户名和密码");
     } finally {
       setLoading(false);
     }
@@ -72,17 +92,23 @@
     setLoading(true);
     try {
       const response = await registerUser(userData);
-      const { token, user: newUser } = response.data;
 
-      localStorage.setItem('authToken', token);
-      localStorage.setItem('user', JSON.stringify(newUser));
-      setUser(newUser);
-      setIsAuthenticated(true);
-      message.success('注册成功');
-      return newUser;
+      // 检查响应是否成功
+      if (response.data && response.data.success) {
+        const { token, user: newUser } = response.data.data;
+
+        localStorage.setItem("token", token);
+        localStorage.setItem("user", JSON.stringify(newUser));
+        setUser(newUser);
+        setIsAuthenticated(true);
+        message.success("注册成功");
+        return newUser;
+      } else {
+        throw new Error(response.data?.message || "注册失败");
+      }
     } catch (error) {
       console.error("Registration failed", error);
-      message.error(error.message || '注册失败，请稍后再试');
+      message.error(error.message || "注册失败，请稍后再试");
     } finally {
       setLoading(false);
     }
@@ -91,24 +117,27 @@
   const logout = async () => {
     try {
       await logoutUser();
-      localStorage.removeItem('authToken');
-      localStorage.removeItem('user');
-      localStorage.removeItem('permissions'); // 移除旧的权限存储
+      localStorage.removeItem("token");
+      localStorage.removeItem("user");
+      localStorage.removeItem("permissions"); // 移除旧的权限存储
       setUser(null);
       setIsAuthenticated(false);
-      message.success('已成功退出登录');
-      navigate('/login');
+      message.success("已成功退出登录");
+      navigate("/login");
       return true;
     } catch (error) {
       console.error("登出失败", error);
-      message.error('登出失败');
+      message.error("登出失败");
       return false;
     }
   };
 
-  const hasRole = useCallback((roleName) => {
-    return user?.role === roleName;
-  }, [user]);
+  const hasRole = useCallback(
+    (roleName) => {
+      return user?.role === roleName;
+    },
+    [user]
+  );
 
   const value = {
     user,
@@ -118,7 +147,7 @@
     register,
     logout,
     hasRole,
-    reloadAuthData: loadAuthData // 暴露一个重新加载数据的方法
+    reloadAuthData: loadAuthData, // 暴露一个重新加载数据的方法
   };
 
   return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
@@ -126,8 +155,9 @@
 
 export const useAuth = () => {
   const context = useContext(AuthContext);
-  if (context === undefined || context === null) { // 增加了对 null 的检查
-    throw new Error('useAuth must be used within an AuthProvider');
+  if (context === undefined || context === null) {
+    // 增加了对 null 的检查
+    throw new Error("useAuth must be used within an AuthProvider");
   }
   return context;
-};
\ No newline at end of file
+};
