diff --git a/src/pages/user/login/Login.tsx b/src/pages/user/login/Login.tsx index 7a1a99c..04b2154 100644 --- a/src/pages/user/login/Login.tsx +++ b/src/pages/user/login/Login.tsx @@ -3,6 +3,7 @@ import { useLoginStore } from '../store/login'; import { useShallow } from 'zustand/react/shallow'; import { useEffect } from 'react'; import { isObjectNull } from '@/utils/is-null'; +import { LockOutlined, UserOutlined } from '@ant-design/icons'; export const Login = () => { const [form] = Form.useForm(); const loginStore = useLoginStore( @@ -27,30 +28,38 @@ export const Login = () => { loginStore.login(); }; return ( -
-
-

Login

-
-
- - - - - - - -
- -
-
-
+
+
+
+

Login

+
+
+ + } placeholder='Username' /> + + + } placeholder='Password' /> + + +
+ +
+
+
+
diff --git a/src/pages/user/store/login.ts b/src/pages/user/store/login.ts index 047dc1a..8258533 100644 --- a/src/pages/user/store/login.ts +++ b/src/pages/user/store/login.ts @@ -33,9 +33,15 @@ export const useLoginStore = create((set, get) => { const { token } = res.data; message.success('Success'); set({ isLogin: true }); - localStorage.setItem('token', token); - // 跳到某一个页面,更新localStorage - history.push('/map'); + query.saveToken(token); + await new Promise((resolve) => setTimeout(resolve, 1000)); + const search = new URLSearchParams(window.location.search); + const redirect = search.get('redirect'); + if (redirect) { + window.location.href = redirect; + } else { + window.location.href = '/'; + } } else { message.error(res.message || 'Request failed'); } diff --git a/src/utils/extra.ts b/src/utils/extra.ts index 70727c0..6128de0 100644 --- a/src/utils/extra.ts +++ b/src/utils/extra.ts @@ -1,3 +1,8 @@ +/** + * 提取 {{}} 中的 key + * @param text + * @returns + */ export function extractKeysFromBraces(text: string) { const regex = /\{\{\s*(.*?)\s*\}\}/g; const keys: string[] = [];