kn-cli 1.0.130 → 1.0.133
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/vite.config.js +1 -1
- package/build/webpack.config.js +2 -1
- package/package.json +2 -1
- package/src/create.js +2 -0
- package/templates/template_admin_antd5/.vscode/settings.json +28 -0
- package/templates/template_admin_antd5/build.sh +8 -0
- package/templates/template_admin_antd5/cli.config.js +35 -0
- package/templates/template_admin_antd5/dev.sh +33 -0
- package/templates/template_admin_antd5/frontend_build.sh +48 -0
- package/templates/template_admin_antd5/init/prepare-commit-msg +5 -0
- package/templates/template_admin_antd5/init.sh +24 -0
- package/templates/template_admin_antd5/jsconfig.json +17 -0
- package/templates/template_admin_antd5/package.json +27 -0
- package/templates/template_admin_antd5/public/404.html +26 -0
- package/templates/template_admin_antd5/public/favicon.png +0 -0
- package/templates/template_admin_antd5/public/index.html +48 -0
- package/templates/template_admin_antd5/public/src/_antd.less +37 -0
- package/templates/template_admin_antd5/public/src/_mixin.module.less +79 -0
- package/templates/template_admin_antd5/public/src/_reset.module.less +134 -0
- package/templates/template_admin_antd5/public/src/_variable.module.less +85 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.module.less +109 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.svg +75 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_admin_antd5/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/arrow.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/avatar.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/icon-notice.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/icon-user.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/loadFail.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/loading.svg +40 -0
- package/templates/template_admin_antd5/public/src/assets/images/login/bg.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/login/logo.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/login/slogan.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-dep-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-dep.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-log-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-log.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-loginlog-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-loginlog.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-role-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-role.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-user-active.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/icon-user.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/nav-toggle.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/nav/slogan.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/noData.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/noSelect.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/permission/403.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/permission/404.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/permission/503.png +0 -0
- package/templates/template_admin_antd5/public/src/assets/images/play.png +0 -0
- package/templates/template_admin_antd5/public/src/components/_table/column.jsx +47 -0
- package/templates/template_admin_antd5/public/src/components/_table/column.module.less +12 -0
- package/templates/template_admin_antd5/public/src/components/_table/index.jsx +71 -0
- package/templates/template_admin_antd5/public/src/components/_table/index.module.less +15 -0
- package/templates/template_admin_antd5/public/src/components/antd/antProvider.jsx +21 -0
- package/templates/template_admin_antd5/public/src/components/antd/index.jsx +146 -0
- package/templates/template_admin_antd5/public/src/components/antd/select/index.jsx +296 -0
- package/templates/template_admin_antd5/public/src/components/antd/select/index.module.less +21 -0
- package/templates/template_admin_antd5/public/src/components/antd/theme.js +173 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/detail/index.jsx +70 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/detail/index.module.less +12 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/index.jsx +69 -0
- package/templates/template_admin_antd5/public/src/components/antd/tooltip/index.module.less +28 -0
- package/templates/template_admin_antd5/public/src/components/auth/index.jsx +123 -0
- package/templates/template_admin_antd5/public/src/components/auth/index.module.less +7 -0
- package/templates/template_admin_antd5/public/src/components/auth/navCheck.jsx +27 -0
- package/templates/template_admin_antd5/public/src/components/badge/index.jsx +47 -0
- package/templates/template_admin_antd5/public/src/components/badge/index.module.less +44 -0
- package/templates/template_admin_antd5/public/src/components/button/index.jsx +17 -0
- package/templates/template_admin_antd5/public/src/components/debug/index.jsx +28 -0
- package/templates/template_admin_antd5/public/src/components/debug/index.module.less +10 -0
- package/templates/template_admin_antd5/public/src/components/empty/index.jsx +28 -0
- package/templates/template_admin_antd5/public/src/components/empty/index.module.less +20 -0
- package/templates/template_admin_antd5/public/src/components/error/index.jsx +39 -0
- package/templates/template_admin_antd5/public/src/components/icon/index.jsx +128 -0
- package/templates/template_admin_antd5/public/src/components/icon/playVideo/index.jsx +21 -0
- package/templates/template_admin_antd5/public/src/components/icon/playVideo/index.module.less +16 -0
- package/templates/template_admin_antd5/public/src/components/iconFont/index.jsx +20 -0
- package/templates/template_admin_antd5/public/src/components/iconFont/index.module.less +5 -0
- package/templates/template_admin_antd5/public/src/components/image/index.jsx +73 -0
- package/templates/template_admin_antd5/public/src/components/image/index.module.less +117 -0
- package/templates/template_admin_antd5/public/src/components/image/preview.jsx +85 -0
- package/templates/template_admin_antd5/public/src/components/layout/basic/index.jsx +49 -0
- package/templates/template_admin_antd5/public/src/components/layout/basic/index.module.less +76 -0
- package/templates/template_admin_antd5/public/src/components/layout/index.jsx +39 -0
- package/templates/template_admin_antd5/public/src/components/layout/index.module.less +63 -0
- package/templates/template_admin_antd5/public/src/components/layout/provider/index.jsx +32 -0
- package/templates/template_admin_antd5/public/src/components/leftMenu/index.jsx +106 -0
- package/templates/template_admin_antd5/public/src/components/leftMenu/index.module.less +42 -0
- package/templates/template_admin_antd5/public/src/components/link/index.jsx +39 -0
- package/templates/template_admin_antd5/public/src/components/link/index.module.less +11 -0
- package/templates/template_admin_antd5/public/src/components/menuIcon/index.jsx +33 -0
- package/templates/template_admin_antd5/public/src/components/menuIcon/index.module.less +49 -0
- package/templates/template_admin_antd5/public/src/components/page/pageLoading/index.jsx +51 -0
- package/templates/template_admin_antd5/public/src/components/page/pageLoading/index.module.less +29 -0
- package/templates/template_admin_antd5/public/src/components/popup/index.jsx +60 -0
- package/templates/template_admin_antd5/public/src/components/popup/index.module.less +18 -0
- package/templates/template_admin_antd5/public/src/components/react/index.jsx +13 -0
- package/templates/template_admin_antd5/public/src/components/resizeBox/index.jsx +144 -0
- package/templates/template_admin_antd5/public/src/components/resizeBox/index.module.css +90 -0
- package/templates/template_admin_antd5/public/src/components/select/defaultServicesSelect/index.jsx +182 -0
- package/templates/template_admin_antd5/public/src/components/select/dictSelect/index.jsx +84 -0
- package/templates/template_admin_antd5/public/src/components/select/index.jsx +7 -0
- package/templates/template_admin_antd5/public/src/components/select/useSelectList.jsx +217 -0
- package/templates/template_admin_antd5/public/src/components/table/aliTable/index.jsx +250 -0
- package/templates/template_admin_antd5/public/src/components/table/aliTable/index.module.less +105 -0
- package/templates/template_admin_antd5/public/src/components/table/column.jsx +128 -0
- package/templates/template_admin_antd5/public/src/components/table/column.module.less +50 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/index.jsx +302 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/index.module.less +196 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/radio.jsx +15 -0
- package/templates/template_admin_antd5/public/src/components/table/imageTable/radio.module.less +18 -0
- package/templates/template_admin_antd5/public/src/components/table/index.jsx +475 -0
- package/templates/template_admin_antd5/public/src/components/table/index.module.less +133 -0
- package/templates/template_admin_antd5/public/src/components/text/index.jsx +98 -0
- package/templates/template_admin_antd5/public/src/components/text/index.module.less +13 -0
- package/templates/template_admin_antd5/public/src/components/toast/index.jsx +79 -0
- package/templates/template_admin_antd5/public/src/components/toast/index.module.less +43 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/index.jsx +102 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/index.module.less +89 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/topBar/index.jsx +81 -0
- package/templates/template_admin_antd5/public/src/components/topMenu/topBar/index.module.less +97 -0
- package/templates/template_admin_antd5/public/src/components/video/index.jsx +96 -0
- package/templates/template_admin_antd5/public/src/components/video/index.module.less +132 -0
- package/templates/template_admin_antd5/public/src/components/video/preview.jsx +38 -0
- package/templates/template_admin_antd5/public/src/config.js +31 -0
- package/templates/template_admin_antd5/public/src/declarations.d.ts +1 -0
- package/templates/template_admin_antd5/public/src/dictionary/dictionary.js +289 -0
- package/templates/template_admin_antd5/public/src/dictionary/index.jsx +64 -0
- package/templates/template_admin_antd5/public/src/enum.js +41 -0
- package/templates/template_admin_antd5/public/src/hooks/index.jsx +29 -0
- package/templates/template_admin_antd5/public/src/hooks/useDebounceFn.jsx +33 -0
- package/templates/template_admin_antd5/public/src/hooks/useDelay.jsx +34 -0
- package/templates/template_admin_antd5/public/src/hooks/useEsc.jsx +98 -0
- package/templates/template_admin_antd5/public/src/hooks/useImageLoader.jsx +26 -0
- package/templates/template_admin_antd5/public/src/hooks/useInToView.jsx +58 -0
- package/templates/template_admin_antd5/public/src/hooks/useLoading.jsx +46 -0
- package/templates/template_admin_antd5/public/src/hooks/usePreload.jsx +67 -0
- package/templates/template_admin_antd5/public/src/hooks/useRouteMenu.jsx +263 -0
- package/templates/template_admin_antd5/public/src/hooks/useScrollTop.jsx +44 -0
- package/templates/template_admin_antd5/public/src/hooks/useSearch.jsx +163 -0
- package/templates/template_admin_antd5/public/src/hooks/useTableRowSelect.jsx +310 -0
- package/templates/template_admin_antd5/public/src/hooks/useThrottole.jsx +68 -0
- package/templates/template_admin_antd5/public/src/hooks/useTimer.jsx +42 -0
- package/templates/template_admin_antd5/public/src/hooks/useUpdate.jsx +16 -0
- package/templates/template_admin_antd5/public/src/hooks/useWatchServices.jsx +124 -0
- package/templates/template_admin_antd5/public/src/index.jsx +89 -0
- package/templates/template_admin_antd5/public/src/menuConfig/auth.jsx +92 -0
- package/templates/template_admin_antd5/public/src/menuConfig/dashboard.jsx +25 -0
- package/templates/template_admin_antd5/public/src/menuConfig/dna.jsx +76 -0
- package/templates/template_admin_antd5/public/src/menuConfig/index.jsx +17 -0
- package/templates/template_admin_antd5/public/src/mock/auth.js +33 -0
- package/templates/template_admin_antd5/public/src/mock/demo.js +122 -0
- package/templates/template_admin_antd5/public/src/mock/index.js +65 -0
- package/templates/template_admin_antd5/public/src/mock/utils.js +33 -0
- package/templates/template_admin_antd5/public/src/pages/antdComponents/index.jsx +142 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/create/index.jsx +47 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/create/index.module.less +6 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/dialog/index.jsx +96 -0
- package/templates/template_admin_antd5/public/src/pages/auth/user/index.jsx +214 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/index.jsx +75 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/index.module.less +78 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/titleBar/index.jsx +28 -0
- package/templates/template_admin_antd5/public/src/pages/components/layout/titleBar/index.module.less +44 -0
- package/templates/template_admin_antd5/public/src/pages/components/select/user.jsx +18 -0
- package/templates/template_admin_antd5/public/src/pages/demo/page1.jsx +21 -0
- package/templates/template_admin_antd5/public/src/pages/demo/page2.jsx +21 -0
- package/templates/template_admin_antd5/public/src/pages/demo/page3.jsx +21 -0
- package/templates/template_admin_antd5/public/src/pages/error/403.jsx +15 -0
- package/templates/template_admin_antd5/public/src/pages/error/404.jsx +15 -0
- package/templates/template_admin_antd5/public/src/pages/error/503.jsx +15 -0
- package/templates/template_admin_antd5/public/src/pages/error/permission.jsx +40 -0
- package/templates/template_admin_antd5/public/src/pages/error/permission.module.less +16 -0
- package/templates/template_admin_antd5/public/src/pages/home.jsx +90 -0
- package/templates/template_admin_antd5/public/src/pages/home.module.less +6 -0
- package/templates/template_admin_antd5/public/src/pages/login/index.jsx +113 -0
- package/templates/template_admin_antd5/public/src/pages/login/index.module.less +153 -0
- package/templates/template_admin_antd5/public/src/pages/pageTemplate.jsx +28 -0
- package/templates/template_admin_antd5/public/src/provider/app.jsx +201 -0
- package/templates/template_admin_antd5/public/src/provider/loading.jsx +47 -0
- package/templates/template_admin_antd5/public/src/provider/menu.jsx +161 -0
- package/templates/template_admin_antd5/public/src/provider/menu.module.less +35 -0
- package/templates/template_admin_antd5/public/src/route.jsx +127 -0
- package/templates/template_admin_antd5/public/src/services/demo.js +85 -0
- package/templates/template_admin_antd5/public/src/services/excel.js +43 -0
- package/templates/template_admin_antd5/public/src/services/http/index.js +155 -0
- package/templates/template_admin_antd5/public/src/services/index.js +126 -0
- package/templates/template_admin_antd5/public/src/services/interceptor/index.js +67 -0
- package/templates/template_admin_antd5/public/src/services/login.js +37 -0
- package/templates/template_admin_antd5/public/src/services/socket/index.jsx +99 -0
- package/templates/template_admin_antd5/public/src/services/token/index.js +41 -0
- package/templates/template_admin_antd5/public/src/type.js +67 -0
- package/templates/template_admin_antd5/public/src/utils/event.js +58 -0
- package/templates/template_admin_antd5/public/src/utils/format.js +135 -0
- package/templates/template_admin_antd5/public/src/utils/index.js +727 -0
- package/templates/template_admin_antd5/public/src/utils/menu.js +33 -0
- package/templates/template_admin_antd5/public/src/utils/rule.js +277 -0
- package/templates/template_admin_antd5/public/src/utils/storage.js +30 -0
- package/templates/template_admin_antd5/public/static/about.html +1 -0
- package/templates/template_admin_antd5/public/static/kssoLogin.html +22 -0
- package/templates/template_admin_antd5/readme.md +84 -0
- package/templates/template_admin_antd5/renamejstojsx.js +45 -0
- package/templates/template_admin_antd5/renameless.js +53 -0
- package/templates/template_admin_antd5/report.sh +25 -0
- package/templates/template_admin_antd5/shellUtil.sh +110 -0
- package/templates/template_admin_antd5/versionPublish.sh +16 -0
- package/templates/template_admin_antd5/webpack.api.js +105 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styles from './index.module.less';
|
|
4
|
+
import { AntdTooltip } from "@/components/antd";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
|
|
8
|
+
import ShowDetail from './detail'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function countRenderableText(node) {
|
|
12
|
+
if (typeof node === 'string') {
|
|
13
|
+
return node.length;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (Array.isArray(node)) {
|
|
17
|
+
// 如果 node 是一个数组,递归统计所有子节点的文字数量
|
|
18
|
+
return node.reduce((acc, child) => acc + countRenderableText(child), 0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (React.isValidElement(node) && node.props.children) {
|
|
22
|
+
// 如果 node 是一个有效的 React 元素且有 children,则递归统计子节点
|
|
23
|
+
return countRenderableText(node.props.children);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return 0; // 非文本内容返回 0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const More=props=>{
|
|
31
|
+
const {children} = props;
|
|
32
|
+
|
|
33
|
+
const [len,setLen] = useState(0);
|
|
34
|
+
const onViewMore=(content)=>{
|
|
35
|
+
ShowDetail({content});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
useEffect(()=>{
|
|
39
|
+
if(!children){
|
|
40
|
+
setLen(0);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if( ['string','number'].includes(typeof children) ){
|
|
44
|
+
setLen(`${children}`.length);
|
|
45
|
+
}else{
|
|
46
|
+
let len = countRenderableText(children);
|
|
47
|
+
setLen(len);
|
|
48
|
+
}
|
|
49
|
+
},[children])
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className={styles.moreWrap}>
|
|
54
|
+
<div className={styles.text}>
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
<div className={styles.btnMoreWrap}>
|
|
58
|
+
{len>=100?<span className={styles.btnMore} onClick={onViewMore.bind(this,children)}>查看详情</span>:<></>}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
const TooltipMore=props=>{
|
|
64
|
+
const {title,children,...others}=props;
|
|
65
|
+
|
|
66
|
+
return <AntdTooltip {...others} title={<More>{title}</More>} >{children}</AntdTooltip>
|
|
67
|
+
}
|
|
68
|
+
export default TooltipMore;
|
|
69
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@import '~@/_mixin.module.less';
|
|
2
|
+
|
|
3
|
+
.moreWrap{
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
max-height: 300px;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
.text{
|
|
9
|
+
max-height: 240px;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
.scrollBarDark;
|
|
12
|
+
}
|
|
13
|
+
.btnMoreWrap{
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
|
|
17
|
+
.btnMore{
|
|
18
|
+
color:#479CFF;
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
font-weight: bold;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
&:hover{
|
|
23
|
+
color:#70A9FF;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
|
|
6
|
+
import ProviderApp from '@/provider/app';
|
|
7
|
+
|
|
8
|
+
import {useLoading} from '@/hooks/index';
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import styles from './index.module.less';
|
|
11
|
+
import { AUTH_DEBUG_OPEN } from '@/config';
|
|
12
|
+
import Page403 from '@/pages/error/403';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const AuthShowDebug=props=>{
|
|
16
|
+
return <div className={styles.authDebug} data-auth={props.auth}>
|
|
17
|
+
{props.children}
|
|
18
|
+
</div>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 检查用户是否带有某个权限
|
|
23
|
+
* @param {object} props
|
|
24
|
+
* @param {string|string[]} [props.name] - 权限的名称
|
|
25
|
+
* @param {JSX.Element} [props.children] - 子组件
|
|
26
|
+
* @param {JSX.Element} [props.noAuthComponent=<></>] - 没权限时展示的内容
|
|
27
|
+
* @param {boolean} [props.noDebugShow=false] - 禁止调试模式下的强制显示
|
|
28
|
+
* @param {import('@/provider/app').AppContaniner} [props.appProvider] - appProivder
|
|
29
|
+
*
|
|
30
|
+
* @returns {JSX.Element}
|
|
31
|
+
*/
|
|
32
|
+
export const AuthShow=(props)=>{
|
|
33
|
+
const {name,noAuthComponent=<></>,appProvider,noDebugShow} = props;
|
|
34
|
+
const app = appProvider||ProviderApp.useContainer();
|
|
35
|
+
|
|
36
|
+
let hasAuth = app.hasAuth(name);
|
|
37
|
+
if(AUTH_DEBUG_OPEN&&!noDebugShow){
|
|
38
|
+
return <AuthShowDebug auth={hasAuth}>{props.children}</AuthShowDebug>;
|
|
39
|
+
}
|
|
40
|
+
return hasAuth?props.children:noAuthComponent
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 检查用户是否带有某个权限
|
|
46
|
+
* @param {object} props
|
|
47
|
+
* @param {string|string[]} [props.name] - 权限的名称
|
|
48
|
+
* @param {JSX.Element} [props.children] - 子组件
|
|
49
|
+
* @param {JSX.Element} [props.noAuthComponent=<></>] - 没权限时展示的内容
|
|
50
|
+
* @param {import('@/provider/app').AppContaniner} [props.appProvider] - appProivder
|
|
51
|
+
*
|
|
52
|
+
* @returns {JSX.Element}
|
|
53
|
+
*/
|
|
54
|
+
export const AuthPage=(props)=>{
|
|
55
|
+
const {name,noAuthComponent=<Page403 />,appProvider} = props;
|
|
56
|
+
const app = appProvider||ProviderApp.useContainer();
|
|
57
|
+
|
|
58
|
+
let hasAuth = app.hasAuth(name);
|
|
59
|
+
// if(AUTH_DEBUG_OPEN){
|
|
60
|
+
// return <AuthShowDebug auth={hasAuth}>{props.children}</AuthShowDebug>;
|
|
61
|
+
// }
|
|
62
|
+
|
|
63
|
+
if(!hasAuth){
|
|
64
|
+
return noAuthComponent;
|
|
65
|
+
}
|
|
66
|
+
return props.children;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
export const AuthRoute=(props)=>{
|
|
71
|
+
const {name} = props;
|
|
72
|
+
const app = ProviderApp.useContainer();
|
|
73
|
+
if(Array.isArray(name)){
|
|
74
|
+
for(let i=0;i<name.length;i++){
|
|
75
|
+
let authName = name[i];
|
|
76
|
+
if(app?.auths?.includes(authName)){
|
|
77
|
+
return props.children;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if(app?.auths?.includes(name)){
|
|
82
|
+
return props.children;
|
|
83
|
+
}
|
|
84
|
+
return <>暂无权限</>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 用户登录态校验
|
|
89
|
+
* @param {object} props
|
|
90
|
+
* @param {JSX.Element} [props.children] - 当登录校验合法后显示的子组件
|
|
91
|
+
*
|
|
92
|
+
* @returns {JSX.Element}
|
|
93
|
+
*/
|
|
94
|
+
export const AuthLogin=(props)=>{
|
|
95
|
+
const navigate = useNavigate();
|
|
96
|
+
const [pass,setPass] = useState(false)
|
|
97
|
+
const app = ProviderApp.useContainer();
|
|
98
|
+
const loading = useLoading();
|
|
99
|
+
|
|
100
|
+
const check=async ()=>{
|
|
101
|
+
loading.setLoading(true);
|
|
102
|
+
console.log(`[Auth]检查用户登录态`)
|
|
103
|
+
const req =await app.isLogin();
|
|
104
|
+
loading.setLoading(false);
|
|
105
|
+
if(req){
|
|
106
|
+
console.log(`[Auth]检查用户登录态成功`)
|
|
107
|
+
setPass(true);
|
|
108
|
+
}else{
|
|
109
|
+
console.log(`[Auth]检查用户登录态失败`)
|
|
110
|
+
setPass(false);
|
|
111
|
+
navigate('/login');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
useEffect(()=>{check()},[]);
|
|
115
|
+
|
|
116
|
+
if(pass){
|
|
117
|
+
return props.children;
|
|
118
|
+
}
|
|
119
|
+
return <div className={styles.body}></div>
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
export default {AuthShow,AuthLogin};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { Navigate } from 'react-router-dom';
|
|
5
|
+
import ProviderMenu from '@/provider/menu';
|
|
6
|
+
import ProviderApp from '@/provider/app';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const NavCheck=(props)=>{
|
|
10
|
+
const {to} = props;
|
|
11
|
+
const providerMenu = ProviderMenu.useContainer();
|
|
12
|
+
const providerApp = ProviderApp.useContainer();
|
|
13
|
+
if(to=='/auth/user'){
|
|
14
|
+
debugger;
|
|
15
|
+
}
|
|
16
|
+
let menu = providerMenu.getMenuNavigateTo(to,providerApp.auths);
|
|
17
|
+
if(menu == 404){
|
|
18
|
+
return <Navigate to='/401'/>
|
|
19
|
+
}else if( menu == 403){
|
|
20
|
+
return <Navigate to='/403'/>
|
|
21
|
+
}
|
|
22
|
+
else if(menu){
|
|
23
|
+
return <Navigate to={menu.url||to} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
export default NavCheck;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import styles from './index.module.less';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const Badge=(props)=>{
|
|
8
|
+
const {dot=false,overflowCount=99,offset} = props;
|
|
9
|
+
/**
|
|
10
|
+
* @type {React.MutableRefObject<object>}
|
|
11
|
+
*/
|
|
12
|
+
const refDom = useRef();
|
|
13
|
+
|
|
14
|
+
const [myStyle,setStyle]=useState(()=>{
|
|
15
|
+
if(offset){
|
|
16
|
+
return {
|
|
17
|
+
marginLeft:`${offset[0]}px`,
|
|
18
|
+
marginTop:`${offset[1]}px`,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const [count,setCount] = useState(0);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
useEffect(()=>{
|
|
26
|
+
let _count = props.count;
|
|
27
|
+
if(_count != count){
|
|
28
|
+
setCount(+_count);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
const getCountText=()=>{
|
|
32
|
+
if(count > overflowCount){
|
|
33
|
+
return `${overflowCount}+`
|
|
34
|
+
}else{
|
|
35
|
+
let req = Math.max(0,count);
|
|
36
|
+
return `${req}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
let countLabel = getCountText();
|
|
40
|
+
return (
|
|
41
|
+
<div className={styles.wrap} data-hide={count <= 0}>
|
|
42
|
+
<div ref={refDom} style={myStyle} className={styles.badge} data-len={countLabel.length}>{countLabel}</div>
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Badge;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.wrap{
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
position: relative;
|
|
4
|
+
&[data-hide='true']{
|
|
5
|
+
display: none;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
.hideBadge,
|
|
9
|
+
.badge{
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
background-color: red;
|
|
12
|
+
border-radius: 100%;
|
|
13
|
+
color:white;
|
|
14
|
+
font-size: 12px;
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
line-height: 12px;
|
|
19
|
+
box-shadow: 0 0 0 1px #fff;
|
|
20
|
+
padding-bottom: 1px;
|
|
21
|
+
|
|
22
|
+
width: 16px;
|
|
23
|
+
height: 16px;
|
|
24
|
+
&[data-len='2']{
|
|
25
|
+
transform: scale(.9);
|
|
26
|
+
width: 26px;
|
|
27
|
+
height: 15px;
|
|
28
|
+
border-radius: 12px;
|
|
29
|
+
}
|
|
30
|
+
&[data-len='3']{
|
|
31
|
+
transform: scale(.9);
|
|
32
|
+
width: 34px;
|
|
33
|
+
height: 15px;
|
|
34
|
+
border-radius: 12px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
.hideBadge{
|
|
38
|
+
position: absolute;
|
|
39
|
+
left:0;
|
|
40
|
+
top:0;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
z-index: -1;
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {AntdButton} from "@/components/antd";
|
|
3
|
+
import useThrottole from '@/hooks/useThrottole';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 增加了节流的AntdButton
|
|
7
|
+
*/
|
|
8
|
+
const AsyncButton=props=>{
|
|
9
|
+
const {children,onClick:_onClick,throttle=100,disabled,...others} = props;
|
|
10
|
+
const _useThrottole = useThrottole({throttle})
|
|
11
|
+
const onClick=_useThrottole.makeThrottole( _onClick )
|
|
12
|
+
|
|
13
|
+
return <AntdButton onClick={onClick} disabled={_useThrottole.throttleing||disabled} {...others}>{children}</AntdButton>
|
|
14
|
+
}
|
|
15
|
+
AsyncButton.Group = AntdButton.Group;
|
|
16
|
+
|
|
17
|
+
export default AsyncButton;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import ReactJson from 'react18-json-view'
|
|
5
|
+
// import 'react18-json-view/src/style.css'
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import {Tooltip} from '@/components/antd';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import styles from './index.module.less';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 测试调试时用于点击对象后显示数据用
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @param {JSX.Element} props.children - 真正展示的对象
|
|
15
|
+
* @param {object} props.item - 需要被调试展示的对象数据
|
|
16
|
+
*
|
|
17
|
+
* @returns {JSX.Element}
|
|
18
|
+
*/
|
|
19
|
+
export const DebugTableItem=(props)=>{
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
if(BUILD_ENV==='prod'){
|
|
22
|
+
return props.children
|
|
23
|
+
}
|
|
24
|
+
const {children,item={}} = props;
|
|
25
|
+
return <Tooltip trigger='click' overlayClassName={styles.jsonView} color='white' title={<div className={styles.jsonView}><ReactJson src={item} /></div>}>
|
|
26
|
+
{children}
|
|
27
|
+
</Tooltip>
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React from "react";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import styles from './index.module.less';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import imgEmpty from '@/assets/images/noData.png';
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import imgEmptySelect from '@/assets/images/noSelect.png';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 当前没数据的占位图
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @param {string} [props.label='暂无数据 ,请稍后再试'] - 提示文案
|
|
15
|
+
* @param {string} [props.type='data'] - 图标类型 'data':无数据 , ‘select':没有选择提示
|
|
16
|
+
* @returns {JSX.Element}
|
|
17
|
+
*/
|
|
18
|
+
const EmptyData=(props)=>{
|
|
19
|
+
const {label='暂无数据 ,请稍后再试',type='data'}= props;
|
|
20
|
+
return (
|
|
21
|
+
<section className={styles.wrap}>
|
|
22
|
+
<img src={type=='select'?imgEmptySelect:imgEmpty} />
|
|
23
|
+
<span>{label}</span>
|
|
24
|
+
</section>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default EmptyData;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
.wrap{
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
row-gap: 16px;
|
|
11
|
+
img{
|
|
12
|
+
width: 96px;
|
|
13
|
+
}
|
|
14
|
+
span{
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
color: #8F959E;
|
|
18
|
+
line-height: 16px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
|
|
5
|
+
const ErrorBoundary = props => {
|
|
6
|
+
const {children}= props;
|
|
7
|
+
const [hasError, setHasError] = useState(false);
|
|
8
|
+
|
|
9
|
+
const onReload=()=>{
|
|
10
|
+
window.location.reload();
|
|
11
|
+
}
|
|
12
|
+
const handleError = (error, errorInfo) => {
|
|
13
|
+
if (error.name.toLowerCase() =='ChunkLoadError'.toLowerCase() ) {
|
|
14
|
+
setHasError(true);
|
|
15
|
+
onReload()
|
|
16
|
+
// ReactDOM.render(<h1>站点已更新,即将重新加载...</h1>, document.getElementById('main-view'));
|
|
17
|
+
// setTimeout(()=>{
|
|
18
|
+
// onReload()
|
|
19
|
+
// },2000)
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const errorListener = (event) => {
|
|
25
|
+
handleError(event.error, event.errorInfo);
|
|
26
|
+
};
|
|
27
|
+
window.addEventListener('error', errorListener);
|
|
28
|
+
return () => {
|
|
29
|
+
window.removeEventListener('error', errorListener);
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
if (hasError) {
|
|
34
|
+
return <></>;
|
|
35
|
+
}
|
|
36
|
+
return children;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
|
|
2
|
+
import PlayVideo from "@/components/icon/playVideo";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InfoCircleFilled,
|
|
6
|
+
PlusOutlined,
|
|
7
|
+
DeleteOutlined,
|
|
8
|
+
LockOutlined,
|
|
9
|
+
UnlockOutlined,
|
|
10
|
+
CaretDownOutlined,
|
|
11
|
+
EditOutlined,
|
|
12
|
+
InfoCircleOutlined,
|
|
13
|
+
CloseOutlined,
|
|
14
|
+
SearchOutlined,
|
|
15
|
+
CheckCircleFilled,
|
|
16
|
+
EditFilled,
|
|
17
|
+
DownOutlined,
|
|
18
|
+
ExclamationCircleOutlined,
|
|
19
|
+
EyeFilled,
|
|
20
|
+
LinkOutlined,
|
|
21
|
+
QuestionCircleOutlined,
|
|
22
|
+
CloseCircleFilled,
|
|
23
|
+
DownloadOutlined,
|
|
24
|
+
LoadingOutlined,
|
|
25
|
+
ArrowDownOutlined,
|
|
26
|
+
EyeOutlined,
|
|
27
|
+
UploadOutlined,
|
|
28
|
+
SyncOutlined,
|
|
29
|
+
PlayCircleOutlined,
|
|
30
|
+
PlayCircleFilled,
|
|
31
|
+
ExclamationCircleFilled,
|
|
32
|
+
DoubleLeftOutlined,
|
|
33
|
+
PlusSquareOutlined,
|
|
34
|
+
CaretUpOutlined,
|
|
35
|
+
DownCircleOutlined,
|
|
36
|
+
UpCircleOutlined,
|
|
37
|
+
LeftOutlined,
|
|
38
|
+
RightOutlined,
|
|
39
|
+
MenuOutlined,
|
|
40
|
+
ArrowUpOutlined,
|
|
41
|
+
LogoutOutlined,
|
|
42
|
+
CloseCircleOutlined,
|
|
43
|
+
CheckCircleOutlined,
|
|
44
|
+
EyeTwoTone,
|
|
45
|
+
DeleteFilled,
|
|
46
|
+
CheckOutlined,
|
|
47
|
+
EyeInvisibleOutlined,
|
|
48
|
+
CalendarOutlined,
|
|
49
|
+
MinusCircleOutlined,
|
|
50
|
+
FormOutlined,
|
|
51
|
+
QuestionCircleFilled,
|
|
52
|
+
CaretDownFilled,
|
|
53
|
+
FileTextFilled,
|
|
54
|
+
UserOutlined,
|
|
55
|
+
HolderOutlined,
|
|
56
|
+
StepBackwardOutlined,
|
|
57
|
+
SmallDashOutlined,
|
|
58
|
+
UpOutlined,
|
|
59
|
+
} from '@ant-design/icons';
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
InfoCircleFilled,
|
|
64
|
+
PlusOutlined,
|
|
65
|
+
DeleteOutlined,
|
|
66
|
+
LockOutlined,
|
|
67
|
+
UnlockOutlined,
|
|
68
|
+
CaretDownOutlined,
|
|
69
|
+
EditOutlined,
|
|
70
|
+
InfoCircleOutlined,
|
|
71
|
+
CloseOutlined,
|
|
72
|
+
SearchOutlined,
|
|
73
|
+
CheckCircleFilled,
|
|
74
|
+
EditFilled,
|
|
75
|
+
DownOutlined,
|
|
76
|
+
ExclamationCircleOutlined,
|
|
77
|
+
EyeFilled,
|
|
78
|
+
LinkOutlined,
|
|
79
|
+
QuestionCircleOutlined,
|
|
80
|
+
CloseCircleFilled,
|
|
81
|
+
DownloadOutlined,
|
|
82
|
+
LoadingOutlined,
|
|
83
|
+
ArrowDownOutlined,
|
|
84
|
+
EyeOutlined,
|
|
85
|
+
UploadOutlined,
|
|
86
|
+
SyncOutlined,
|
|
87
|
+
PlayCircleOutlined,
|
|
88
|
+
PlayCircleFilled,
|
|
89
|
+
ExclamationCircleFilled,
|
|
90
|
+
DoubleLeftOutlined,
|
|
91
|
+
CaretUpOutlined,
|
|
92
|
+
PlusSquareOutlined,
|
|
93
|
+
DownCircleOutlined,
|
|
94
|
+
UpCircleOutlined,
|
|
95
|
+
LeftOutlined,
|
|
96
|
+
RightOutlined,
|
|
97
|
+
MenuOutlined,
|
|
98
|
+
ArrowUpOutlined,
|
|
99
|
+
LogoutOutlined,
|
|
100
|
+
CloseCircleOutlined,
|
|
101
|
+
CheckCircleOutlined,
|
|
102
|
+
EyeTwoTone,
|
|
103
|
+
DeleteFilled,
|
|
104
|
+
CheckOutlined,
|
|
105
|
+
EyeInvisibleOutlined,
|
|
106
|
+
CalendarOutlined,
|
|
107
|
+
MinusCircleOutlined,
|
|
108
|
+
FormOutlined,
|
|
109
|
+
QuestionCircleFilled,
|
|
110
|
+
CaretDownFilled,
|
|
111
|
+
FileTextFilled,
|
|
112
|
+
UserOutlined,
|
|
113
|
+
HolderOutlined,
|
|
114
|
+
StepBackwardOutlined,
|
|
115
|
+
SmallDashOutlined,
|
|
116
|
+
UpOutlined,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @typedef IconProps
|
|
122
|
+
* @property {number} [size=24] - 尺寸,代表宽度的px值
|
|
123
|
+
* @property {function} [onClick] - 点击回调
|
|
124
|
+
* @property {string} [className]
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
export {PlayVideo};
|
|
128
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import iconPlay from '@/assets/images/play.png';
|
|
4
|
+
|
|
5
|
+
import styles from './index.module.less';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 播放按钮
|
|
9
|
+
* @param {import('@/components/icon').IconProps} props
|
|
10
|
+
* @returns {JSX.Element}
|
|
11
|
+
*/
|
|
12
|
+
const PlayVideo=props=>{
|
|
13
|
+
const {size=24,className='',onClick:_onClick}=props;
|
|
14
|
+
const onClick=(...args)=>{
|
|
15
|
+
if(_onClick)_onClick(...args);
|
|
16
|
+
}
|
|
17
|
+
return (
|
|
18
|
+
<i onClick={onClick} className={`${styles.icon} ${className}`} style={{width:`${size/100}rem`,height:`${size/100}rem`}}><img src={iconPlay}/></i>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
export default PlayVideo;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
.icon{
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
border-radius: 100%;
|
|
8
|
+
background-color: rgba(0,0,0,.5);
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
img{
|
|
11
|
+
display: inline-block;
|
|
12
|
+
width: 50%;
|
|
13
|
+
height:50%;
|
|
14
|
+
margin-left: 10%;
|
|
15
|
+
}
|
|
16
|
+
}
|