|
|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
import { userAtom } from '@/atoms/user';
|
|
|
|
|
import { useIntl, useModel } from '@umijs/max';
|
|
|
|
|
import { useIntl, useModel, useSearchParams } from '@umijs/max';
|
|
|
|
|
import { Button, Divider, Form, Spin, message } from 'antd';
|
|
|
|
|
import { createStyles } from 'antd-style';
|
|
|
|
|
import { useAtom } from 'jotai';
|
|
|
|
|
import { useMemo, useState } from 'react';
|
|
|
|
|
import { useEffect, useMemo, useState } from 'react';
|
|
|
|
|
import { flushSync } from 'react-dom';
|
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
import { useLocalAuth } from '../hooks/use-local-auth';
|
|
|
|
|
@ -73,6 +73,7 @@ const useStyles = createStyles(({ token, css }) => ({
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const LoginForm = () => {
|
|
|
|
|
const [searchParams] = useSearchParams();
|
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
|
const { styles } = useStyles();
|
|
|
|
|
const [userInfo, setUserInfo] = useAtom(userAtom);
|
|
|
|
|
@ -151,6 +152,18 @@ const LoginForm = () => {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const token = searchParams.get('token');
|
|
|
|
|
if (token) {
|
|
|
|
|
try {
|
|
|
|
|
const decodedData = atob(token);
|
|
|
|
|
const [username, password] = decodedData.split(':');
|
|
|
|
|
handleLogin({ username, password });
|
|
|
|
|
// message.info('自动登录中...')
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// SSO hook
|
|
|
|
|
const SSOAuth = useSSOAuth({
|
|
|
|
|
fetchUserInfo,
|
|
|
|
|
|