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 'umi'; 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`, { data: { username: values.username, password: values.password, }, }) .then((data) => { if (data.code === 200) { next(); } else { message.error(data.message); } }) .finally(() => setLoading(false)); }; const submitNotification = (values: any) => { setLoading(true); request .put(`${config.apiPrefix}user/notification/init`, { data: { ...values, }, }) .then((_data: any) => { if (_data && _data.code === 200) { next(); } else { message.error(_data.message); } }) .finally(() => setLoading(false)); }; const notificationModeChange = (value: string) => { const _fields = (config.notificationModeMap as any)[value]; setFields(_fields || []); }; useEffect(() => { localStorage.removeItem(config.authKey); }, []); const steps = [ { title: '欢迎使用', content: (
欢迎使用青龙控制面板
), }, { title: '通知设置', content: (
{fields.map((x) => ( ))}
), }, { title: '账户设置', content: (
({ validator(_, value) { if (!value || getFieldValue('password') === value) { return Promise.resolve(); } return Promise.reject(new Error('您输入的两个密码不匹配!')); }, }), ]} >
), }, { title: '完成安装', content: (
恭喜安装完成! Github Telegram频道
), }, ]; return (
logo 初始化配置
{steps.map((item) => ( ))}
{steps[current].content}
); }; export default Initialization;