BaiLuoYan 4 недель назад
Родитель
Сommit
f6079d3109
3 измененных файлов с 23 добавлено и 10 удалено
  1. 4 4
      src/components/LoginForm/useAction.ts
  2. 15 4
      src/pages/featureDemo/index.tsx
  3. 4 2
      src/services/login/typings.d.ts

+ 4 - 4
src/components/LoginForm/useAction.ts

@@ -33,12 +33,12 @@ export function useAction({ setToken, setUserConfig, onSuccess }: UseActionParam
             setErrorMessage(null);
             setErrorMessage(null);
             setErrorKey(null);
             setErrorKey(null);
             setLoading(true);
             setLoading(true);
-            fetchLogin({ username: username.trim(), password }, { skipErrorHandler: true })
+            fetchLogin({ account: username.trim(), password }, { skipErrorHandler: true })
                 .then((res) => {
                 .then((res) => {
                     const data = res?.data;
                     const data = res?.data;
-                    if (!data) return;
-                    setToken(data);
-                    setUserConfig(data);
+                    if (!data || !data.userConfig) return;
+                    setToken(data.userConfig);
+                    setUserConfig(data.userConfig);
                     onSuccess?.();
                     onSuccess?.();
                 })
                 })
                 .catch((err) => {
                 .catch((err) => {

+ 15 - 4
src/pages/featureDemo/index.tsx

@@ -104,7 +104,7 @@ const Home: React.FC = () => {
         setLoading(true);
         setLoading(true);
         try {
         try {
             const result = await fetchLogin({
             const result = await fetchLogin({
-                username: 'test',
+                account: 'test',
                 password: '123456',
                 password: '123456',
                 captchaId: 'test-captcha',
                 captchaId: 'test-captcha',
                 captchaCode: '1234',
                 captchaCode: '1234',
@@ -222,7 +222,8 @@ const Home: React.FC = () => {
         openDialog({
         openDialog({
             icon: infoIcon,
             icon: infoIcon,
             title: 'Important Notice',
             title: 'Important Notice',
-            content: 'This dialog cannot be closed by clicking the mask. You must click the button to close it.',
+            content:
+                'This dialog cannot be closed by clicking the mask. You must click the button to close it.',
             maskClosable: false,
             maskClosable: false,
             buttons: [
             buttons: [
                 {
                 {
@@ -248,7 +249,8 @@ const Home: React.FC = () => {
                         openDialog({
                         openDialog({
                             icon: infoIcon,
                             icon: infoIcon,
                             title: 'Nested Dialog',
                             title: 'Nested Dialog',
-                            content: 'This is a nested dialog opened from the first dialog. Notice how the z-index is automatically managed.',
+                            content:
+                                'This is a nested dialog opened from the first dialog. Notice how the z-index is automatically managed.',
                             buttons: [
                             buttons: [
                                 {
                                 {
                                     label: 'Close Nested',
                                     label: 'Close Nested',
@@ -318,7 +320,16 @@ const Home: React.FC = () => {
                     <Space wrap className="mt-4">
                     <Space wrap className="mt-4">
                         <Button
                         <Button
                             onClick={() => {
                             onClick={() => {
-                                const names = ['张三', '李四', '王五', '赵六', '钱七', '孙八', '周九', '吴十'];
+                                const names = [
+                                    '张三',
+                                    '李四',
+                                    '王五',
+                                    '赵六',
+                                    '钱七',
+                                    '孙八',
+                                    '周九',
+                                    '吴十',
+                                ];
                                 const randomName = names[Math.floor(Math.random() * names.length)];
                                 const randomName = names[Math.floor(Math.random() * names.length)];
                                 user.updateName(randomName);
                                 user.updateName(randomName);
                             }}
                             }}

+ 4 - 2
src/services/login/typings.d.ts

@@ -53,13 +53,15 @@ declare namespace API {
     };
     };
 
 
     type LoginParams = {
     type LoginParams = {
-        username: string;
+        account: string;
         password: string;
         password: string;
         captchaId?: string; // 新的登录接口不用验证码
         captchaId?: string; // 新的登录接口不用验证码
         captchaCode?: string; // 新的登录接口不用验证码
         captchaCode?: string; // 新的登录接口不用验证码
     };
     };
 
 
-    type LoginResult = Result<UserInfo>;
+    type LoginResult = Result<{
+        userConfig: UserInfo;
+    }>;
 
 
     type RefreshTokenInfo = {
     type RefreshTokenInfo = {
         /** token */
         /** token */