outaozhen 3 anos atrás
pai
commit
efb3d62dae
3 arquivos alterados com 16 adições e 20 exclusões
  1. 12 19
      src/pages/user/Login/index.tsx
  2. 2 0
      src/services/api/typings.d.ts
  3. 2 1
      src/utils/consts.ts

+ 12 - 19
src/pages/user/Login/index.tsx

@@ -5,7 +5,7 @@ import ProForm, { ProFormCheckbox, ProFormText } from '@ant-design/pro-form'
 import { useIntl, Link, history, FormattedMessage, SelectLang, useModel, useRequest } from 'umi'
 import { login } from '@/services/api/login'
 import { queryAcountList } from '@/services/api/institution'
-
+import consts from '@/utils/consts'
 import styles from './index.less'
 
 const LoginMessage: React.FC<{
@@ -22,14 +22,14 @@ const LoginMessage: React.FC<{
 )
 
 /** 此方法会跳转到 redirect 参数所在的位置 */
-// const goto = () => {
-//   if (!history) return
-//   setTimeout(() => {
-//     const { query } = history.location
-//     const { redirect } = query as { redirect: string }
-//     history.push(redirect || '/')
-//   }, 10)
-// }
+const goto = () => {
+  if (!history) return
+  setTimeout(() => {
+    const { query } = history.location
+    const { redirect } = query as { redirect: string }
+    history.push(redirect || '/')
+  }, 10)
+}
 
 const Login: React.FC = () => {
   // const { setAuthToken } = useModel('user')
@@ -44,7 +44,7 @@ const Login: React.FC = () => {
         ...initialState,
         currentUser: result.items
       })
-      // goto()
+      goto()
     }
   })
 
@@ -107,7 +107,7 @@ const Login: React.FC = () => {
     //   message.error(defaultLoginFailureMessage)
     // }
   }
-  const { status, type: loginType } = userLoginState
+  const { code } = userLoginState
 
   return (
     <div className={styles.container}>
@@ -160,14 +160,7 @@ const Login: React.FC = () => {
               />
             </Tabs>
 
-            {status === 'error' && loginType === 'account' && (
-              <LoginMessage
-                content={intl.formatMessage({
-                  id: 'pages.login.accountLogin.errorMessage',
-                  defaultMessage: '账户或密码错误(admin/ant.design)'
-                })}
-              />
-            )}
+            {code === consts.RET_CODE.ERROR && <LoginMessage content={'账户或密码错误'} />}
             {type === 'account' && (
               <>
                 <ProFormText

+ 2 - 0
src/services/api/typings.d.ts

@@ -207,5 +207,7 @@ declare namespace API {
   type LoginParams = {
     account: string
     password: string
+    autoLogin: boolean
+    type: string
   }
 }

+ 2 - 1
src/utils/consts.ts

@@ -1,5 +1,6 @@
 export default {
   RET_CODE: {
-    SUCCESS: 0
+    SUCCESS: 0,
+    ERROR: -1
   }
 }