|
@@ -1,32 +1,54 @@
|
|
|
import { TitleComponent } from '@/components';
|
|
import { TitleComponent } from '@/components';
|
|
|
-import { Button, Collapse, Spin, Steps } from 'antd';
|
|
|
|
|
|
|
+import {Button, Collapse, Spin} from 'antd';
|
|
|
import styles from './index.less';
|
|
import styles from './index.less';
|
|
|
import Basis from './components/basis';
|
|
import Basis from './components/basis';
|
|
|
import Menu from './components/menu';
|
|
import Menu from './components/menu';
|
|
|
import Role from './components/role';
|
|
import Role from './components/role';
|
|
|
import Data from './components/data';
|
|
import Data from './components/data';
|
|
|
import Service from './service';
|
|
import Service from './service';
|
|
|
-import { useState } from 'react';
|
|
|
|
|
|
|
+import { useHistory } from 'umi'
|
|
|
|
|
+import {useState, useRef, useEffect} from 'react';
|
|
|
|
|
+import BaseMenu from '@/pages/system/Menu/Setting/baseMenu'
|
|
|
|
|
|
|
|
export const service = new Service();
|
|
export const service = new Service();
|
|
|
|
|
|
|
|
const InitHome = () => {
|
|
const InitHome = () => {
|
|
|
const [loadings, setLoadings] = useState<boolean>(false);
|
|
const [loadings, setLoadings] = useState<boolean>(false);
|
|
|
- const [current, setCurrent] = useState<number>(0);
|
|
|
|
|
|
|
+ const [, setCurrent] = useState<number>(0);
|
|
|
|
|
+ const history = useHistory()
|
|
|
|
|
+
|
|
|
|
|
+ const cacheRef = useRef<Set<string>>()
|
|
|
|
|
+
|
|
|
|
|
+ const baseRef = useRef<{ save: any }>()
|
|
|
|
|
+ const menuRef = useRef<{ save: any }>()
|
|
|
|
|
+ const roleRef = useRef<{ save: any }>()
|
|
|
|
|
+ const dataRef = useRef<{ save: any }>()
|
|
|
|
|
+
|
|
|
|
|
+ const jump = () => {
|
|
|
|
|
+ history.push(BaseMenu[0].url)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ service.getInit().then(res => {
|
|
|
|
|
+ if (res.status === 200 && res.result.length) {
|
|
|
|
|
+ jump()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }, [])
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.init}>
|
|
<div className={styles.init}>
|
|
|
<TitleComponent data={'系统初始化'} />
|
|
<TitleComponent data={'系统初始化'} />
|
|
|
<div className={styles.box}>
|
|
<div className={styles.box}>
|
|
|
<div className={styles.container}>
|
|
<div className={styles.container}>
|
|
|
- <div className={styles.left}>
|
|
|
|
|
- <Steps direction="vertical" current={current} percent={60} style={{ height: '100%' }}>
|
|
|
|
|
- <Steps.Step />
|
|
|
|
|
- <Steps.Step />
|
|
|
|
|
- <Steps.Step />
|
|
|
|
|
- <Steps.Step />
|
|
|
|
|
- </Steps>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ {/*<div className={styles.left}>*/}
|
|
|
|
|
+ {/* <Steps direction="vertical" current={current} percent={60} style={{ height: '100%' }}>*/}
|
|
|
|
|
+ {/* <Steps.Step />*/}
|
|
|
|
|
+ {/* <Steps.Step />*/}
|
|
|
|
|
+ {/* <Steps.Step />*/}
|
|
|
|
|
+ {/* <Steps.Step />*/}
|
|
|
|
|
+ {/* </Steps>*/}
|
|
|
|
|
+ {/*</div>*/}
|
|
|
<div className={styles.right}>
|
|
<div className={styles.right}>
|
|
|
<Spin spinning={loadings}>
|
|
<Spin spinning={loadings}>
|
|
|
<Collapse defaultActiveKey={['1', '2', '3', '4']}>
|
|
<Collapse defaultActiveKey={['1', '2', '3', '4']}>
|
|
@@ -41,7 +63,7 @@ const InitHome = () => {
|
|
|
}
|
|
}
|
|
|
key="1"
|
|
key="1"
|
|
|
>
|
|
>
|
|
|
- <Basis getData={() => {}} />
|
|
|
|
|
|
|
+ <Basis ref={baseRef} />
|
|
|
</Collapse.Panel>
|
|
</Collapse.Panel>
|
|
|
<Collapse.Panel
|
|
<Collapse.Panel
|
|
|
header={
|
|
header={
|
|
@@ -51,7 +73,7 @@ const InitHome = () => {
|
|
|
}
|
|
}
|
|
|
key="2"
|
|
key="2"
|
|
|
>
|
|
>
|
|
|
- <Menu />
|
|
|
|
|
|
|
+ <Menu ref={menuRef} />
|
|
|
</Collapse.Panel>
|
|
</Collapse.Panel>
|
|
|
<Collapse.Panel
|
|
<Collapse.Panel
|
|
|
header={
|
|
header={
|
|
@@ -61,7 +83,7 @@ const InitHome = () => {
|
|
|
}
|
|
}
|
|
|
key="3"
|
|
key="3"
|
|
|
>
|
|
>
|
|
|
- <Role />
|
|
|
|
|
|
|
+ <Role ref={roleRef} />
|
|
|
</Collapse.Panel>
|
|
</Collapse.Panel>
|
|
|
<Collapse.Panel
|
|
<Collapse.Panel
|
|
|
header={
|
|
header={
|
|
@@ -71,7 +93,7 @@ const InitHome = () => {
|
|
|
}
|
|
}
|
|
|
key="4"
|
|
key="4"
|
|
|
>
|
|
>
|
|
|
- <Data isTrigger={false} onChange={() => {}} />
|
|
|
|
|
|
|
+ <Data ref={dataRef} />
|
|
|
</Collapse.Panel>
|
|
</Collapse.Panel>
|
|
|
</Collapse>
|
|
</Collapse>
|
|
|
</Spin>
|
|
</Spin>
|
|
@@ -79,9 +101,38 @@ const InitHome = () => {
|
|
|
type="primary"
|
|
type="primary"
|
|
|
style={{ marginTop: 20 }}
|
|
style={{ marginTop: 20 }}
|
|
|
loading={loadings}
|
|
loading={loadings}
|
|
|
- onClick={() => {
|
|
|
|
|
|
|
+ onClick={async () => {
|
|
|
setLoadings(true);
|
|
setLoadings(true);
|
|
|
setCurrent(0);
|
|
setCurrent(0);
|
|
|
|
|
+ if (!cacheRef.current?.has('base')) {
|
|
|
|
|
+ const baseRes = await baseRef.current?.save()
|
|
|
|
|
+ if (!baseRes) { return setLoadings(false) }
|
|
|
|
|
+ cacheRef.current?.add('base')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!cacheRef.current?.has('menu')) {
|
|
|
|
|
+ const menuRes = await menuRef.current?.save()
|
|
|
|
|
+ if (!menuRes) { return setLoadings(false) }
|
|
|
|
|
+ cacheRef.current?.add('menu')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!cacheRef.current?.has('role')) {
|
|
|
|
|
+ const roleRes = await roleRef.current?.save()
|
|
|
|
|
+ if (!roleRes) { return setLoadings(false) }
|
|
|
|
|
+ cacheRef.current?.add('role')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!cacheRef.current?.has('data')) {
|
|
|
|
|
+ const dataRes = await dataRef.current?.save()
|
|
|
|
|
+ if (!dataRes) { return setLoadings(false) }
|
|
|
|
|
+ cacheRef.current?.add('data')
|
|
|
|
|
+ }
|
|
|
|
|
+ // 记录当前
|
|
|
|
|
+ service.saveInit().then(res => {
|
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
|
+ jump()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
确认
|
|
确认
|