kn-cli 1.0.56 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.config.js +5 -0
- package/build/webpack.config.js +4 -3
- package/package.json +3 -1
- package/readme.md +8 -0
- package/src/build.js +1 -0
- package/templates/template_oa/.DS_Store +0 -0
- package/templates/template_oa/build.sh +2 -0
- package/templates/template_oa/cli.config.js +24 -0
- package/templates/template_oa/dev.sh +89 -0
- package/templates/template_oa/frontend_build.sh +83 -0
- package/templates/template_oa/init/prepare-commit-msg +5 -0
- package/templates/template_oa/init.sh +33 -0
- package/templates/template_oa/jsconfig.json +10 -0
- package/templates/template_oa/package-lock.json +1925 -0
- package/templates/template_oa/package.json +24 -0
- package/templates/template_oa/public/.DS_Store +0 -0
- package/templates/template_oa/public/404.html +26 -0
- package/templates/template_oa/public/favicon.ico +0 -0
- package/templates/template_oa/public/favicon.png +0 -0
- package/templates/template_oa/public/index.html +43 -0
- package/templates/template_oa/public/pluginjs/.DS_Store +0 -0
- package/templates/template_oa/public/src/.DS_Store +0 -0
- package/templates/template_oa/public/src/_antd.less +237 -0
- package/templates/template_oa/public/src/_reset.less +131 -0
- package/templates/template_oa/public/src/_variable.less +84 -0
- package/templates/template_oa/public/src/assets/.DS_Store +0 -0
- package/templates/template_oa/public/src/assets/iconfont/.DS_Store +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_oa/public/src/assets/images/.DS_Store +0 -0
- package/templates/template_oa/public/src/assets/images/avatar.png +0 -0
- package/templates/template_oa/public/src/assets/images/loading.svg +40 -0
- package/templates/template_oa/public/src/components/.DS_Store +0 -0
- package/templates/template_oa/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_oa/public/src/components/Alert/index.less +0 -0
- package/templates/template_oa/public/src/components/Auth/index.jsx +44 -0
- package/templates/template_oa/public/src/components/Footer/index.jsx +17 -0
- package/templates/template_oa/public/src/components/Footer/index.less +28 -0
- package/templates/template_oa/public/src/components/IFrame/index.jsx +37 -0
- package/templates/template_oa/public/src/components/IFrame/index.less +4 -0
- package/templates/template_oa/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_oa/public/src/components/IconFont/index.less +5 -0
- package/templates/template_oa/public/src/components/Layout/.DS_Store +0 -0
- package/templates/template_oa/public/src/components/Layout/Basic/index.jsx +31 -0
- package/templates/template_oa/public/src/components/Layout/Basic/index.less +74 -0
- package/templates/template_oa/public/src/components/Layout/CenterBody/index.jsx +15 -0
- package/templates/template_oa/public/src/components/Layout/CenterBody/index.less +36 -0
- package/templates/template_oa/public/src/components/Layout/FormBlock/index.jsx +23 -0
- package/templates/template_oa/public/src/components/Layout/FormBlock/index.less +34 -0
- package/templates/template_oa/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_oa/public/src/components/Layout/index.jsx +26 -0
- package/templates/template_oa/public/src/components/Layout/index.less +8 -0
- package/templates/template_oa/public/src/components/Link/index.jsx +24 -0
- package/templates/template_oa/public/src/components/Link/index.less +11 -0
- package/templates/template_oa/public/src/components/Loading/index.jsx +14 -0
- package/templates/template_oa/public/src/components/Loading/index.less +85 -0
- package/templates/template_oa/public/src/components/Nav/index.jsx +121 -0
- package/templates/template_oa/public/src/components/Nav/index.less +38 -0
- package/templates/template_oa/public/src/components/Page/.DS_Store +0 -0
- package/templates/template_oa/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_oa/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_oa/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_oa/public/src/components/Popup/index.less +18 -0
- package/templates/template_oa/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_oa/public/src/components/Toast/index.less +43 -0
- package/templates/template_oa/public/src/components/mask/index.jsx +47 -0
- package/templates/template_oa/public/src/components/mask/index.less +32 -0
- package/templates/template_oa/public/src/dictionary/index.js +39 -0
- package/templates/template_oa/public/src/hooks/.DS_Store +0 -0
- package/templates/template_oa/public/src/hooks/index.jsx +20 -0
- package/templates/template_oa/public/src/hooks/useDelay.jsx +29 -0
- package/templates/template_oa/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_oa/public/src/hooks/useLoading.jsx +42 -0
- package/templates/template_oa/public/src/hooks/useLogin.jsx +33 -0
- package/templates/template_oa/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_oa/public/src/hooks/useScrollTop.jsx +32 -0
- package/templates/template_oa/public/src/hooks/useSearch.jsx +137 -0
- package/templates/template_oa/public/src/hooks/useUpdate.jsx +11 -0
- package/templates/template_oa/public/src/index.jsx +50 -0
- package/templates/template_oa/public/src/mock/auth.js +91 -0
- package/templates/template_oa/public/src/mock/index.js +63 -0
- package/templates/template_oa/public/src/mock/user.js +70 -0
- package/templates/template_oa/public/src/mock/utils.js +33 -0
- package/templates/template_oa/public/src/pages/.DS_Store +0 -0
- package/templates/template_oa/public/src/pages/components/pageTitle/index.jsx +13 -0
- package/templates/template_oa/public/src/pages/components/pageTitle/index.less +20 -0
- package/templates/template_oa/public/src/pages/login/index.jsx +27 -0
- package/templates/template_oa/public/src/pages/login/index.less +44 -0
- package/templates/template_oa/public/src/pages/video/index.jsx +91 -0
- package/templates/template_oa/public/src/pages/video/index.less +12 -0
- package/templates/template_oa/public/src/provider/app.jsx +119 -0
- package/templates/template_oa/public/src/provider/menu.jsx +20 -0
- package/templates/template_oa/public/src/route.jsx +43 -0
- package/templates/template_oa/public/src/services/.DS_Store +0 -0
- package/templates/template_oa/public/src/services/auth.js +121 -0
- package/templates/template_oa/public/src/services/index.js +181 -0
- package/templates/template_oa/public/src/services/user.js +26 -0
- package/templates/template_oa/public/src/services/video.js +33 -0
- package/templates/template_oa/public/src/utils/.DS_Store +0 -0
- package/templates/template_oa/public/src/utils/index.js +66 -0
- package/templates/template_oa/public/static/.DS_Store +0 -0
- package/templates/template_oa/public/static/about.html +1 -0
- package/templates/template_oa/public/static/kssoLogin.html +22 -0
- package/templates/template_oa/readme.md +60 -0
- package/templates/template_oa/release/.DS_Store +0 -0
- package/templates/template_oa/report.sh +68 -0
- package/templates/template_oa/tools/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/dist/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_oa/tools/iconfont/package.json +20 -0
- package/templates/template_oa/tools/iconfont/run.sh +39 -0
- package/templates/template_oa/tools/iconfont/svg/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_oa/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_oa/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_oa/tools/iconfont/templates/index.html +56 -0
- package/templates/template_oa/tools/tinypng/.DS_Store +0 -0
- package/templates/template_oa/tools/tinypng/img/.DS_Store +0 -0
- package/templates/template_oa/tools/tinypng/package.json +11 -0
- package/templates/template_oa/tools/tinypng/run.sh +15 -0
- package/templates/template_oa/versionPublish.sh +27 -0
- package/templates/template_oa/webpack.api.js +62 -0
- package/templates/template_offcial/.gitignore +6 -0
- package/templates/template_offcial/build.sh +2 -0
- package/templates/template_offcial/cli.config.js +25 -0
- package/templates/template_offcial/dev.sh +89 -0
- package/templates/template_offcial/frontend_build.sh +83 -0
- package/templates/template_offcial/init/prepare-commit-msg +5 -0
- package/templates/template_offcial/init.sh +33 -0
- package/templates/template_offcial/jsconfig.json +10 -0
- package/templates/template_offcial/package.json +23 -0
- package/templates/template_offcial/public/404.html +26 -0
- package/templates/template_offcial/public/favicon.ico +0 -0
- package/templates/template_offcial/public/favicon.png +0 -0
- package/templates/template_offcial/public/index.html +52 -0
- package/templates/template_offcial/public/src/_antd.less +4 -0
- package/templates/template_offcial/public/src/_reset.less +130 -0
- package/templates/template_offcial/public/src/_variable.less +78 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_offcial/public/src/assets/images/avatar.png +0 -0
- package/templates/template_offcial/public/src/assets/images/loading.svg +40 -0
- package/templates/template_offcial/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_offcial/public/src/components/Alert/index.less +0 -0
- package/templates/template_offcial/public/src/components/Footer/index.jsx +32 -0
- package/templates/template_offcial/public/src/components/Footer/index.less +8 -0
- package/templates/template_offcial/public/src/components/Header/index.jsx +68 -0
- package/templates/template_offcial/public/src/components/Header/index.less +76 -0
- package/templates/template_offcial/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_offcial/public/src/components/IconFont/index.less +5 -0
- package/templates/template_offcial/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_offcial/public/src/components/Layout/index.jsx +20 -0
- package/templates/template_offcial/public/src/components/Layout/index.less +20 -0
- package/templates/template_offcial/public/src/components/Link/index.jsx +24 -0
- package/templates/template_offcial/public/src/components/Link/index.less +11 -0
- package/templates/template_offcial/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_offcial/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_offcial/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_offcial/public/src/components/Popup/index.less +18 -0
- package/templates/template_offcial/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_offcial/public/src/components/Toast/index.less +43 -0
- package/templates/template_offcial/public/src/hooks/index.jsx +12 -0
- package/templates/template_offcial/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_offcial/public/src/hooks/useInToView.jsx +55 -0
- package/templates/template_offcial/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_offcial/public/src/hooks/useScroll.jsx +66 -0
- package/templates/template_offcial/public/src/index.jsx +50 -0
- package/templates/template_offcial/public/src/mock/index.js +63 -0
- package/templates/template_offcial/public/src/mock/user.js +70 -0
- package/templates/template_offcial/public/src/mock/utils.js +33 -0
- package/templates/template_offcial/public/src/pages/index.jsx +23 -0
- package/templates/template_offcial/public/src/pages/index.less +0 -0
- package/templates/template_offcial/public/src/pages/mobile/index.jsx +11 -0
- package/templates/template_offcial/public/src/pages/mobile/index.less +0 -0
- package/templates/template_offcial/public/src/pages/pc/index.jsx +45 -0
- package/templates/template_offcial/public/src/pages/pc/index.less +42 -0
- package/templates/template_offcial/public/src/provider/app.jsx +26 -0
- package/templates/template_offcial/public/src/route.jsx +26 -0
- package/templates/template_offcial/public/src/services/index.js +182 -0
- package/templates/template_offcial/public/src/services/user.js +26 -0
- package/templates/template_offcial/public/src/utils/index.js +109 -0
- package/templates/template_offcial/public/static/about.html +1 -0
- package/templates/template_offcial/readme.md +59 -0
- package/templates/template_offcial/report.sh +68 -0
- package/templates/template_offcial/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_offcial/tools/iconfont/package.json +20 -0
- package/templates/template_offcial/tools/iconfont/run.sh +39 -0
- package/templates/template_offcial/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_offcial/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_offcial/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_offcial/tools/iconfont/templates/index.html +56 -0
- package/templates/template_offcial/tools/tinypng/package.json +11 -0
- package/templates/template_offcial/tools/tinypng/run.sh +15 -0
- package/templates/template_offcial/versionPublish.sh +27 -0
- package/templates/template_offcial/webpack.api.js +36 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Menu, Spin } from 'antd';
|
|
4
|
+
import {GET_LEFT_MENU} from '@/services/auth';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
SettingOutlined,
|
|
8
|
+
HddOutlined,
|
|
9
|
+
ProfileOutlined,
|
|
10
|
+
FileTextOutlined,
|
|
11
|
+
LineChartOutlined,
|
|
12
|
+
FundViewOutlined,
|
|
13
|
+
ProjectOutlined,
|
|
14
|
+
} from '@ant-design/icons';
|
|
15
|
+
|
|
16
|
+
import styles from './index.less';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export const LayoutByLeftNav = (props) => {
|
|
21
|
+
const [loading, setLoading] = useState(true);
|
|
22
|
+
const [menuInfo, setMenuInfo] = useState([]);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
GET_LEFT_MENU().then((ret) => {
|
|
26
|
+
setMenuInfo(ret.info);
|
|
27
|
+
setLoading(false);
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
function btnMenu(e) {
|
|
32
|
+
let link = e.item.props.link;
|
|
33
|
+
location.href = link;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createMenu() {
|
|
37
|
+
let openSubs = [];
|
|
38
|
+
menuInfo.forEach((sub) => {
|
|
39
|
+
if (sub.children && sub.children.length > 0) {
|
|
40
|
+
// 强行就展开
|
|
41
|
+
openSubs.push(sub.menu_name);
|
|
42
|
+
// 如果当前选中的是子目录则展开父级目录
|
|
43
|
+
// for (let i = 0; i < sub.children.length; i++) {
|
|
44
|
+
// if (props.selected.includes(sub.children[i].menu_name)) {
|
|
45
|
+
// openSubs.push(sub.menu_name);
|
|
46
|
+
// break;
|
|
47
|
+
// }
|
|
48
|
+
// }
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function getIcon(icon) {
|
|
53
|
+
switch (icon) {
|
|
54
|
+
case 'investproduct':
|
|
55
|
+
return <LineChartOutlined />;
|
|
56
|
+
case 'product':
|
|
57
|
+
return <HddOutlined />;
|
|
58
|
+
case 'manufacturer':
|
|
59
|
+
return <ProfileOutlined />;
|
|
60
|
+
case 'report':
|
|
61
|
+
return <FileTextOutlined />;
|
|
62
|
+
case 'system':
|
|
63
|
+
return <SettingOutlined />;
|
|
64
|
+
case 'ip_product':
|
|
65
|
+
return <FundViewOutlined />;
|
|
66
|
+
case 'ip_manage':
|
|
67
|
+
return <ProjectOutlined />;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<section>
|
|
75
|
+
<Menu
|
|
76
|
+
selectedKeys={[props.selected]}
|
|
77
|
+
defaultOpenKeys={openSubs}
|
|
78
|
+
className={styles.nav}
|
|
79
|
+
mode='inline'
|
|
80
|
+
onClick={btnMenu}
|
|
81
|
+
>
|
|
82
|
+
{menuInfo.map((sub, subIdx) => {
|
|
83
|
+
return sub.children && sub.children.length > 0 ? (
|
|
84
|
+
<Menu.SubMenu key={sub.menu_name} icon={getIcon(sub?.icon)} title={sub.menu_name}>
|
|
85
|
+
{sub.children
|
|
86
|
+
? sub.children.map((menu, idx) => {
|
|
87
|
+
return (
|
|
88
|
+
<Menu.Item key={menu.menu_name} link={menu.link_path}>
|
|
89
|
+
{menu.menu_name}
|
|
90
|
+
</Menu.Item>
|
|
91
|
+
);
|
|
92
|
+
})
|
|
93
|
+
: ''}
|
|
94
|
+
</Menu.SubMenu>
|
|
95
|
+
) : (
|
|
96
|
+
<Menu.Item key={sub.menu_name} icon={getIcon(sub?.icon)} link={sub.link_path}>
|
|
97
|
+
{sub.menu_name}
|
|
98
|
+
</Menu.Item>
|
|
99
|
+
);
|
|
100
|
+
})}
|
|
101
|
+
</Menu>
|
|
102
|
+
</section>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<section
|
|
108
|
+
className={styles.wrap}
|
|
109
|
+
>
|
|
110
|
+
{loading ? (
|
|
111
|
+
<section className={styles.loadingWrap} >
|
|
112
|
+
<Spin />
|
|
113
|
+
</section>
|
|
114
|
+
) : (
|
|
115
|
+
createMenu()
|
|
116
|
+
)}
|
|
117
|
+
</section>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default LayoutByLeftNav;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import '~@/_variable.less';
|
|
2
|
+
|
|
3
|
+
.wrap{
|
|
4
|
+
display: flex;
|
|
5
|
+
background:white;
|
|
6
|
+
margin-bottom: 20px;;
|
|
7
|
+
width: 160px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.nav{
|
|
11
|
+
width: 160px;
|
|
12
|
+
padding: 20px 0px;
|
|
13
|
+
height:100%;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
overflow-y: auto;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.loadingWrap{
|
|
20
|
+
padding:60px;
|
|
21
|
+
width: 130px;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
}
|
|
26
|
+
.contentWrap{
|
|
27
|
+
flex:1;
|
|
28
|
+
min-width: var(--min-width);
|
|
29
|
+
padding:10px;
|
|
30
|
+
overflow: auto;
|
|
31
|
+
}
|
|
32
|
+
.titleBar{
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
align-items: center;
|
|
36
|
+
padding-bottom: 10px;
|
|
37
|
+
border-bottom: 1px solid #e8e8e8;
|
|
38
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React,{useEffect, useState} from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import CSS from './index.less';
|
|
4
|
+
import Popup from '@/components/Popup';
|
|
5
|
+
import imgLoading from '@/assets/images/loading.svg';
|
|
6
|
+
|
|
7
|
+
const PageLoading = (props) => {
|
|
8
|
+
const {visible=true} = props;
|
|
9
|
+
if(!visible){
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
return (
|
|
13
|
+
<div className={CSS.wrap } >
|
|
14
|
+
<div className={CSS.box} data-show={visible}>
|
|
15
|
+
<img src={imgLoading} />
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ShowPageLoading=(props={canTouch:false})=>{
|
|
22
|
+
let popup = Popup(()=>{},{cantouch:props.canTouch});
|
|
23
|
+
ReactDOM.render(
|
|
24
|
+
<PageLoading visible={true} />,
|
|
25
|
+
popup.dom
|
|
26
|
+
);
|
|
27
|
+
return popup.destory;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default React.memo(PageLoading);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.wrap {
|
|
2
|
+
position: fixed;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
left: 0;
|
|
6
|
+
top: 0;
|
|
7
|
+
z-index: 99;
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
align-items: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.box {
|
|
14
|
+
|
|
15
|
+
width: 80px;
|
|
16
|
+
height: 80px;
|
|
17
|
+
background: rgba(0,0,0,.3);
|
|
18
|
+
border-radius: 12px;
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
img{
|
|
23
|
+
display: block;
|
|
24
|
+
width:80%;
|
|
25
|
+
}
|
|
26
|
+
&[data-show=false]{
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import styles from './index.less';
|
|
4
|
+
styles;
|
|
5
|
+
|
|
6
|
+
const Popup = (reslove,options) => {
|
|
7
|
+
let rootDom = document.createElement('div');
|
|
8
|
+
rootDom.className='popup-box';
|
|
9
|
+
if(options&&options.cantouch)rootDom.setAttribute('data-can-touch','1');
|
|
10
|
+
if(options&&options.transparent)rootDom.setAttribute('data-transparent','1');
|
|
11
|
+
|
|
12
|
+
let destory = (result) => {
|
|
13
|
+
ReactDOM.unmountComponentAtNode(rootDom);
|
|
14
|
+
rootDom.parentNode.removeChild(rootDom);
|
|
15
|
+
if (reslove) reslove(result);
|
|
16
|
+
};
|
|
17
|
+
document.body.appendChild(rootDom);
|
|
18
|
+
return { dom: rootDom, destory };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export default Popup;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React,{useEffect} from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import styles from './index.less';
|
|
4
|
+
import Popup from '@/components/Popup/index.jsx';
|
|
5
|
+
|
|
6
|
+
const toastList=[];
|
|
7
|
+
const runNext=()=>{
|
|
8
|
+
let props = toastList[0];
|
|
9
|
+
if(props){
|
|
10
|
+
const {message,delay,resolve,position}=props;
|
|
11
|
+
let popup = Popup(resolve,{cantouch:true});
|
|
12
|
+
ReactDOM.render(
|
|
13
|
+
<Toast destory={popup.destory} message={message} delay={delay} position={position}/>,
|
|
14
|
+
popup.dom
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Toast=props=>{
|
|
20
|
+
const {
|
|
21
|
+
message,
|
|
22
|
+
delay=1000*2,
|
|
23
|
+
destory,
|
|
24
|
+
position='top'
|
|
25
|
+
}=props;
|
|
26
|
+
useEffect(()=>{
|
|
27
|
+
setTimeout(()=>{
|
|
28
|
+
destory();
|
|
29
|
+
toastList.shift();
|
|
30
|
+
runNext();
|
|
31
|
+
},delay);
|
|
32
|
+
},[])
|
|
33
|
+
const ANITYPE={
|
|
34
|
+
'center':'animate__slideInDown',
|
|
35
|
+
'top':'animate__slideInDown',
|
|
36
|
+
'bottom':'animate__slideInUp'
|
|
37
|
+
}
|
|
38
|
+
return (
|
|
39
|
+
<section className={styles.wrap} data-position={position}>
|
|
40
|
+
<div className={styles.content+ ` ${ANITYPE[position]} animate__animated animate__fast`} dangerouslySetInnerHTML={{ __html:message }}>
|
|
41
|
+
</div>
|
|
42
|
+
</section>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const ShowToast=props=>{
|
|
48
|
+
if(typeof props === 'string'){
|
|
49
|
+
props = {message:props}
|
|
50
|
+
}
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
props.resolve = resolve;
|
|
53
|
+
toastList.push(props);
|
|
54
|
+
if(toastList.length===1){
|
|
55
|
+
runNext();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default ShowToast;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@import '~@/_variable.less';
|
|
2
|
+
|
|
3
|
+
.wrap{
|
|
4
|
+
position: fixed;
|
|
5
|
+
left:0;
|
|
6
|
+
top:0;
|
|
7
|
+
width:100%;
|
|
8
|
+
height:100%;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
align-items: center;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
z-index:var(--z-toast);
|
|
15
|
+
&[data-position=top]{
|
|
16
|
+
justify-content: flex-start;
|
|
17
|
+
padding-top:80px;
|
|
18
|
+
}
|
|
19
|
+
&[data-position=bottom]{
|
|
20
|
+
justify-content: flex-end;
|
|
21
|
+
padding-bottom:80px;
|
|
22
|
+
}
|
|
23
|
+
.content{
|
|
24
|
+
min-height:30px;
|
|
25
|
+
min-width:60px;
|
|
26
|
+
|
|
27
|
+
background: rgba(0,0,0,.8);
|
|
28
|
+
opacity:.8;
|
|
29
|
+
border-radius: var(--radius-default);
|
|
30
|
+
padding:var(--padding-default);
|
|
31
|
+
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
align-items: center;
|
|
36
|
+
|
|
37
|
+
font-size: 14px;
|
|
38
|
+
color: #FFFFFF;
|
|
39
|
+
text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.24);
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import styles from './index.less';
|
|
4
|
+
import Popup from '@/components/Popup/index.jsx';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const useToast = () => {
|
|
8
|
+
|
|
9
|
+
const ref = useRef();
|
|
10
|
+
|
|
11
|
+
const runNext = (props) => {
|
|
12
|
+
console.log(props.popup.dom);
|
|
13
|
+
ReactDOM.render(
|
|
14
|
+
<Toast {...props} />,
|
|
15
|
+
props.popup.dom
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Toast = ({ children }) => {
|
|
20
|
+
return (
|
|
21
|
+
<section className={styles.wrap}>
|
|
22
|
+
<div className={styles.content + ` animate__animated animate__fast`}>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
</section>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const hiddenToast = () => {
|
|
30
|
+
ref.current.destory();
|
|
31
|
+
}
|
|
32
|
+
const showToast = props => {
|
|
33
|
+
props = { children: props }
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let popup = Popup(resolve);
|
|
36
|
+
ref.current = popup;
|
|
37
|
+
props.popup = popup;
|
|
38
|
+
runNext(props);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
showToast, hiddenToast
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default useToast;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import '~@/_variable.less';
|
|
2
|
+
|
|
3
|
+
.wrap{
|
|
4
|
+
position: fixed;
|
|
5
|
+
left:0;
|
|
6
|
+
top:0;
|
|
7
|
+
width:100vw;
|
|
8
|
+
height:100vh;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
z-index: 1000;
|
|
14
|
+
.content{
|
|
15
|
+
position: fixed;
|
|
16
|
+
left:0;
|
|
17
|
+
top:0;
|
|
18
|
+
width:100vw;
|
|
19
|
+
height:100vh;
|
|
20
|
+
|
|
21
|
+
background: rgba(0,0,0,.8);
|
|
22
|
+
padding:var(--padding-default);
|
|
23
|
+
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
|
|
29
|
+
font-size: 14px;
|
|
30
|
+
color: #FFFFFF;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useState, useEffect,useMemo} from 'react';
|
|
3
|
+
import {GET_USER_TYPE} from '@/services/user';
|
|
4
|
+
import {useDictionary} from 'kn-hooks';
|
|
5
|
+
import ShowToast from '@/components/Toast';
|
|
6
|
+
export const SelectOption=(props)=>{
|
|
7
|
+
const {value}=props;
|
|
8
|
+
const name = props['data-keyname'];
|
|
9
|
+
const onClick=(e)=>{
|
|
10
|
+
ShowToast(`点击option name=${name},value=${value},label=${props.children}`)
|
|
11
|
+
if(props.onClick)props.onClick();
|
|
12
|
+
}
|
|
13
|
+
return <hgroup onClick={onClick} key={value} name={name} value={value}>{props.children}</hgroup>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
useDictionary.SetConfig({SelectOption})
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export const useUserType = useDictionary.createDictionary({
|
|
20
|
+
api:GET_USER_TYPE,
|
|
21
|
+
afterApi:(response)=>{
|
|
22
|
+
if(response?.code==0){
|
|
23
|
+
let req= response.data.map(item=>{
|
|
24
|
+
const {label,value:id,key:name}=item;
|
|
25
|
+
return {label,id,name}
|
|
26
|
+
});
|
|
27
|
+
return req;
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const useTaskState= useDictionary.createDictionary({
|
|
34
|
+
defaultTypes:[
|
|
35
|
+
{label:'进行中',id:'1',name:'run'},
|
|
36
|
+
{label:'已完成',id:'5',name:'complete'},
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import useImageLoader from './useImageLoader';
|
|
4
|
+
import useDelay from './useDelay';
|
|
5
|
+
import usePreload from './usePreload';
|
|
6
|
+
import useSearch from './useSearch';
|
|
7
|
+
import useUpdate from './useUpdate';
|
|
8
|
+
import useLoading from './useLoading';
|
|
9
|
+
import {usePagination,usePaginationWithForm} from 'kn-hooks';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
usePaginationWithForm,
|
|
13
|
+
usePagination,
|
|
14
|
+
useImageLoader,
|
|
15
|
+
useDelay,
|
|
16
|
+
usePreload,
|
|
17
|
+
useSearch,
|
|
18
|
+
useUpdate,
|
|
19
|
+
useLoading
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef,useState,useMemo, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useDelay=()=>{
|
|
4
|
+
const [loading,setLoading] = useState(false);
|
|
5
|
+
const refSet = useRef();
|
|
6
|
+
refSet.current = setLoading;
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
refSet.current = setLoading;
|
|
9
|
+
},[setLoading]);
|
|
10
|
+
|
|
11
|
+
const actions=useMemo(()=>{
|
|
12
|
+
const wait=(ms)=>{
|
|
13
|
+
refSet.current(true);
|
|
14
|
+
return new Promise(res=>{
|
|
15
|
+
setTimeout(()=>{
|
|
16
|
+
refSet.current(false);
|
|
17
|
+
res();
|
|
18
|
+
}, ms);
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
wait,
|
|
23
|
+
loading
|
|
24
|
+
};
|
|
25
|
+
},[loading]);
|
|
26
|
+
return actions;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default useDelay;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useEffect,useState,useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const useImageLoader=(img_src)=>{
|
|
6
|
+
const [src,setSrc] = useState('');
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if(img_src===src)return;
|
|
9
|
+
if(!img_src)return;
|
|
10
|
+
let img = new Image();
|
|
11
|
+
img.onload = () => {
|
|
12
|
+
setSrc(img_src);
|
|
13
|
+
};
|
|
14
|
+
img.onerror = () => {
|
|
15
|
+
setSrc('');
|
|
16
|
+
console.log(`图片加载失败:${img_src}`)
|
|
17
|
+
};
|
|
18
|
+
img.src = img_src;
|
|
19
|
+
}, [img_src]);
|
|
20
|
+
|
|
21
|
+
const actions=useMemo(()=>{
|
|
22
|
+
return src;
|
|
23
|
+
},[src]);
|
|
24
|
+
return actions;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default useImageLoader;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useRef,useState, useEffect } from 'react';
|
|
2
|
+
import {ShowPageLoading} from '@/components/Page/PageLoading';
|
|
3
|
+
|
|
4
|
+
const useLoading=(props={})=>{
|
|
5
|
+
const {canTouch=false} = props;
|
|
6
|
+
const [name] = useState(props?.name||'loading')
|
|
7
|
+
const [count,setCount] = useState(props?.loading?1:0);
|
|
8
|
+
const refPageLoading = useRef();
|
|
9
|
+
|
|
10
|
+
const setLoading=(state)=>{
|
|
11
|
+
if(state){
|
|
12
|
+
setCount(v=>v+1);
|
|
13
|
+
}else{
|
|
14
|
+
setCount(v=>v-1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const reset=()=>{
|
|
18
|
+
setCount(v=>0);
|
|
19
|
+
}
|
|
20
|
+
useEffect(()=>{
|
|
21
|
+
if(count > 0 ){
|
|
22
|
+
if(!refPageLoading.current){
|
|
23
|
+
refPageLoading.current = ShowPageLoading({canTouch:canTouch});
|
|
24
|
+
}
|
|
25
|
+
}else{
|
|
26
|
+
if(refPageLoading.current){
|
|
27
|
+
refPageLoading.current();//销毁
|
|
28
|
+
refPageLoading.current=null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},[count])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
reset,
|
|
37
|
+
setLoading,
|
|
38
|
+
loading:count
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default useLoading;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
4
|
+
import {IS_LOGIN,SET_TOKEN,LOGIN} from '@/services/wish';
|
|
5
|
+
import ShowLogin from '@/pages/components/dialog/alert/login';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const useLogin=(props)=>{
|
|
9
|
+
const [isLogin,setLogin] = useState(IS_LOGIN());
|
|
10
|
+
|
|
11
|
+
const login=async ()=>{
|
|
12
|
+
if(IS_LOGIN()){
|
|
13
|
+
setLogin(true);
|
|
14
|
+
return true;
|
|
15
|
+
}else{
|
|
16
|
+
setLogin(false);
|
|
17
|
+
const phone = await ShowLogin();
|
|
18
|
+
if(phone){
|
|
19
|
+
const loginReq = await LOGIN({phone});
|
|
20
|
+
if(loginReq?.code==0){
|
|
21
|
+
SET_TOKEN(loginReq.data.api_token);
|
|
22
|
+
setLogin(IS_LOGIN());
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {login,isLogin}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default useLogin;
|