fix: login 修改 添加redirect
This commit is contained in:
parent
d63fd0993c
commit
6df0b4e0cf
@ -3,6 +3,7 @@ import { useLoginStore } from '../store/login';
|
|||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { isObjectNull } from '@/utils/is-null';
|
import { isObjectNull } from '@/utils/is-null';
|
||||||
|
import { LockOutlined, UserOutlined } from '@ant-design/icons';
|
||||||
export const Login = () => {
|
export const Login = () => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const loginStore = useLoginStore(
|
const loginStore = useLoginStore(
|
||||||
@ -27,30 +28,38 @@ export const Login = () => {
|
|||||||
loginStore.login();
|
loginStore.login();
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className='flex w-full h-full bg-slate-200'>
|
<div className='bg-slate-200 text-slate-900 w-full h-full overflow-hidden'>
|
||||||
<div className='w-[600px] mx-auto mt-[10%] '>
|
<div className='w-full h-full absolute top-[10%] xl:top-[15%] 2xl:top-[18%] 3xl:top-[20%] '>
|
||||||
<h1 className='mb-4 tracking-widest'>Login</h1>
|
<div className='w-[400px] mx-auto'>
|
||||||
<div className='card border-t-2 pt-8 px-8'>
|
<h1 className='mb-4 tracking-widest text-center'>Login</h1>
|
||||||
<Form
|
<div className='card border-t-2 pt-8 px-8'>
|
||||||
form={form}
|
<Form
|
||||||
onFinish={onFinish}
|
className='mt-2'
|
||||||
labelCol={{
|
form={form}
|
||||||
span: 4,
|
onFinish={onFinish}
|
||||||
}}>
|
labelCol={{
|
||||||
<Form.Item label='username' name='username'>
|
span: 6,
|
||||||
<Input />
|
}}>
|
||||||
</Form.Item>
|
<Form.Item label='' name='username'>
|
||||||
<Form.Item label='password' name='password'>
|
<Input addonBefore={<UserOutlined />} placeholder='Username' />
|
||||||
<Input type='password' />
|
</Form.Item>
|
||||||
</Form.Item>
|
<Form.Item label='' name='password'>
|
||||||
<Form.Item label=' ' colon={false}>
|
<Input type='password' addonBefore={<LockOutlined />} placeholder='Password' />
|
||||||
<div className='flex gap-2'>
|
</Form.Item>
|
||||||
<Button type='primary' htmlType='submit'>
|
<Form.Item label='' colon={false}>
|
||||||
Login
|
<div className='flex gap-2'>
|
||||||
</Button>
|
<Button
|
||||||
</div>
|
type='primary'
|
||||||
</Form.Item>
|
htmlType='submit'
|
||||||
</Form>
|
style={{
|
||||||
|
background: '#84d5e8',
|
||||||
|
}}>
|
||||||
|
Login
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,9 +33,15 @@ export const useLoginStore = create<LoginStore>((set, get) => {
|
|||||||
const { token } = res.data;
|
const { token } = res.data;
|
||||||
message.success('Success');
|
message.success('Success');
|
||||||
set({ isLogin: true });
|
set({ isLogin: true });
|
||||||
localStorage.setItem('token', token);
|
query.saveToken(token);
|
||||||
// 跳到某一个页面,更新localStorage
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
history.push('/map');
|
const search = new URLSearchParams(window.location.search);
|
||||||
|
const redirect = search.get('redirect');
|
||||||
|
if (redirect) {
|
||||||
|
window.location.href = redirect;
|
||||||
|
} else {
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message.error(res.message || 'Request failed');
|
message.error(res.message || 'Request failed');
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* 提取 {{}} 中的 key
|
||||||
|
* @param text
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function extractKeysFromBraces(text: string) {
|
export function extractKeysFromBraces(text: string) {
|
||||||
const regex = /\{\{\s*(.*?)\s*\}\}/g;
|
const regex = /\{\{\s*(.*?)\s*\}\}/g;
|
||||||
const keys: string[] = [];
|
const keys: string[] = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user