import intl from 'react-intl-universal'; import React, { Fragment, useEffect, useState } from 'react'; import { Button, Row, Input, Form, message, Typography, Steps, Select, } from 'antd'; import config from '@/utils/config'; import { history } from '@umijs/max'; import styles from './index.less'; import { request } from '@/utils/http'; const FormItem = Form.Item; const { Step } = Steps; const { Option } = Select; const { Link } = Typography; const Initialization = () => { const [loading, setLoading] = useState(false); const [current, setCurrent] = React.useState(0); const [fields, setFields] = useState([]); const next = () => { setCurrent(current + 1); }; const prev = () => { setCurrent(current - 1); }; const submitAccountSetting = (values: any) => { setLoading(true); request .put(`${config.apiPrefix}user/init`, { username: values.username, password: values.password, }) .then(({ code, data }) => { if (code === 200) { next(); } }) .finally(() => setLoading(false)); }; const submitNotification = (values: any) => { setLoading(true); request .put(`${config.apiPrefix}user/notification/init`, values) .then(({ code, data }) => { if (code === 200) { next(); } }) .finally(() => setLoading(false)); }; const notificationModeChange = (value: string) => { const _fields = (config.notificationModeMap as any)[value]; setFields(_fields || []); }; useEffect(() => { localStorage.removeItem(config.authKey); }, []); const steps = [ { title: intl.get('欢迎使用'), content: (
{intl.get('欢迎使用青龙')} {intl.get( '支持python3、javascript、shell、typescript 的定时任务管理面板', )}
), }, { title: intl.get('账户设置'), content: (
({ validator(_, value) { if (!value || getFieldValue('password') === value) { return Promise.resolve(); } return Promise.reject( new Error(intl.get('您输入的两个密码不匹配!')), ); }, }), ]} >
), }, { title: intl.get('通知设置'), content: (
{fields.map((x) => ( ))}
), }, { title: intl.get('完成安装'), content: (
{intl.get('恭喜安装完成!')} Github {intl.get('Telegram频道')}
), }, ]; return (
logo {intl.get('初始化配置')}
{steps.map((item) => ( ))}
{steps[current].content}
); }; export default Initialization;