mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 13:37:37 +00:00
feat: login redirect
This commit is contained in:
parent
dd769e4d04
commit
44633db5ff
@ -1,3 +1,4 @@
|
||||
import { Card } from 'antd';
|
||||
import React from 'react';
|
||||
import { useLocation, useHistory } from 'react-router-dom';
|
||||
|
||||
@ -5,7 +6,7 @@ export function AuthLayout({ children, route }: any) {
|
||||
const location = useLocation();
|
||||
const history = useHistory();
|
||||
return (
|
||||
<div style={{ maxWidth: 320, margin: '0 auto' }}>
|
||||
<div style={{ maxWidth: 320, margin: '0 auto', paddingTop: '20vh' }}>
|
||||
<h1>NocoBase</h1>
|
||||
{children}
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@ import { Helmet } from 'react-helmet';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { request, SchemaRenderer } from '../../schemas';
|
||||
import { useForm } from '@formily/react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
|
||||
function Div(props) {
|
||||
return <div {...props}></div>;
|
||||
@ -13,6 +13,9 @@ function Div(props) {
|
||||
export function useLogin() {
|
||||
const form = useForm();
|
||||
const history = useHistory();
|
||||
const location = useLocation<any>();
|
||||
const query = new URLSearchParams(location.search);
|
||||
const redirect = query.get('redirect');
|
||||
return {
|
||||
async run() {
|
||||
await form.submit();
|
||||
@ -20,9 +23,8 @@ export function useLogin() {
|
||||
method: 'post',
|
||||
data: form.values,
|
||||
});
|
||||
history.push('/admin');
|
||||
history.push(redirect || '/admin');
|
||||
localStorage.setItem('NOCOBASE_TOKEN', data?.data?.token);
|
||||
console.log('NOCOBASE_TOKEN', data?.data?.token);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user