kn-cli 1.0.64 → 1.0.66

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.
Files changed (136) hide show
  1. package/package.json +2 -1
  2. package/readme.md +6 -0
  3. package/src/create.js +2 -0
  4. package/templates/template_admin/public/src/mock/index.js +0 -2
  5. package/templates/template_app/public/src/mock/index.js +0 -2
  6. package/templates/template_oa/public/src/components/IFrame/index.jsx +3 -0
  7. package/templates/template_oa/public/src/mock/index.js +0 -2
  8. package/templates/template_oa/webpack.api.js +7 -3
  9. package/templates/template_oa_jwt/build.sh +7 -0
  10. package/templates/template_oa_jwt/cli.config.js +30 -0
  11. package/templates/template_oa_jwt/dev.sh +89 -0
  12. package/templates/template_oa_jwt/frontend_build.sh +88 -0
  13. package/templates/template_oa_jwt/init/prepare-commit-msg +5 -0
  14. package/templates/template_oa_jwt/init.sh +33 -0
  15. package/templates/template_oa_jwt/jsconfig.json +10 -0
  16. package/templates/template_oa_jwt/package.json +25 -0
  17. package/templates/template_oa_jwt/public/404.html +26 -0
  18. package/templates/template_oa_jwt/public/favicon.ico +0 -0
  19. package/templates/template_oa_jwt/public/index.html +44 -0
  20. package/templates/template_oa_jwt/public/src/_antd.less +216 -0
  21. package/templates/template_oa_jwt/public/src/_reset.less +134 -0
  22. package/templates/template_oa_jwt/public/src/_variable.less +84 -0
  23. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.eot +0 -0
  24. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.less +57 -0
  25. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.svg +36 -0
  26. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.ttf +0 -0
  27. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff +0 -0
  28. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff2 +0 -0
  29. package/templates/template_oa_jwt/public/src/assets/images/NY-pop-bg.png +0 -0
  30. package/templates/template_oa_jwt/public/src/assets/images/avatar.png +0 -0
  31. package/templates/template_oa_jwt/public/src/assets/images/loading.svg +40 -0
  32. package/templates/template_oa_jwt/public/src/components/Alert/index.jsx +0 -0
  33. package/templates/template_oa_jwt/public/src/components/Alert/index.less +0 -0
  34. package/templates/template_oa_jwt/public/src/components/Auth/index.jsx +44 -0
  35. package/templates/template_oa_jwt/public/src/components/Dialog/index.jsx +150 -0
  36. package/templates/template_oa_jwt/public/src/components/Dialog/index.less +123 -0
  37. package/templates/template_oa_jwt/public/src/components/Empty/index.jsx +23 -0
  38. package/templates/template_oa_jwt/public/src/components/Empty/index.less +6 -0
  39. package/templates/template_oa_jwt/public/src/components/Footer/index.jsx +17 -0
  40. package/templates/template_oa_jwt/public/src/components/Footer/index.less +28 -0
  41. package/templates/template_oa_jwt/public/src/components/FormRow/index.jsx +39 -0
  42. package/templates/template_oa_jwt/public/src/components/FormRow/index.less +67 -0
  43. package/templates/template_oa_jwt/public/src/components/FormTable/index.jsx +137 -0
  44. package/templates/template_oa_jwt/public/src/components/FormTable/index.less +18 -0
  45. package/templates/template_oa_jwt/public/src/components/IFrame/index.jsx +44 -0
  46. package/templates/template_oa_jwt/public/src/components/IFrame/index.less +4 -0
  47. package/templates/template_oa_jwt/public/src/components/IconFont/index.jsx +10 -0
  48. package/templates/template_oa_jwt/public/src/components/IconFont/index.less +5 -0
  49. package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.jsx +52 -0
  50. package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.less +82 -0
  51. package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.jsx +15 -0
  52. package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.less +36 -0
  53. package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.jsx +23 -0
  54. package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.less +37 -0
  55. package/templates/template_oa_jwt/public/src/components/Layout/Provider/index.jsx +12 -0
  56. package/templates/template_oa_jwt/public/src/components/Layout/index.jsx +27 -0
  57. package/templates/template_oa_jwt/public/src/components/Layout/index.less +8 -0
  58. package/templates/template_oa_jwt/public/src/components/Link/index.jsx +24 -0
  59. package/templates/template_oa_jwt/public/src/components/Link/index.less +11 -0
  60. package/templates/template_oa_jwt/public/src/components/Loading/index.jsx +16 -0
  61. package/templates/template_oa_jwt/public/src/components/Loading/index.less +96 -0
  62. package/templates/template_oa_jwt/public/src/components/Nav/index.jsx +184 -0
  63. package/templates/template_oa_jwt/public/src/components/Nav/index.less +38 -0
  64. package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.jsx +30 -0
  65. package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.less +29 -0
  66. package/templates/template_oa_jwt/public/src/components/Popup/index.jsx +22 -0
  67. package/templates/template_oa_jwt/public/src/components/Popup/index.less +18 -0
  68. package/templates/template_oa_jwt/public/src/components/Select/DepSelect/index.jsx +47 -0
  69. package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.jsx +97 -0
  70. package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.less +24 -0
  71. package/templates/template_oa_jwt/public/src/components/Toast/index.jsx +60 -0
  72. package/templates/template_oa_jwt/public/src/components/Toast/index.less +43 -0
  73. package/templates/template_oa_jwt/public/src/components/Upload/index.jsx +358 -0
  74. package/templates/template_oa_jwt/public/src/components/title/index.jsx +12 -0
  75. package/templates/template_oa_jwt/public/src/components/title/index.less +21 -0
  76. package/templates/template_oa_jwt/public/src/dictionary/index.js +20 -0
  77. package/templates/template_oa_jwt/public/src/hooks/index.jsx +21 -0
  78. package/templates/template_oa_jwt/public/src/hooks/useDelay.jsx +29 -0
  79. package/templates/template_oa_jwt/public/src/hooks/useImageLoader.jsx +27 -0
  80. package/templates/template_oa_jwt/public/src/hooks/useLoading.jsx +42 -0
  81. package/templates/template_oa_jwt/public/src/hooks/useLogin.jsx +33 -0
  82. package/templates/template_oa_jwt/public/src/hooks/usePreload.jsx +66 -0
  83. package/templates/template_oa_jwt/public/src/hooks/useScrollTop.jsx +32 -0
  84. package/templates/template_oa_jwt/public/src/hooks/useSearch.jsx +137 -0
  85. package/templates/template_oa_jwt/public/src/hooks/useUpdate.jsx +11 -0
  86. package/templates/template_oa_jwt/public/src/index.jsx +50 -0
  87. package/templates/template_oa_jwt/public/src/mock/common.js +484 -0
  88. package/templates/template_oa_jwt/public/src/mock/index.js +61 -0
  89. package/templates/template_oa_jwt/public/src/mock/user.js +70 -0
  90. package/templates/template_oa_jwt/public/src/mock/utils.js +33 -0
  91. package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.jsx +13 -0
  92. package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.less +20 -0
  93. package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.jsx +21 -0
  94. package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.less +16 -0
  95. package/templates/template_oa_jwt/public/src/pages/demo/detail/index.jsx +14 -0
  96. package/templates/template_oa_jwt/public/src/pages/demo/index.jsx +399 -0
  97. package/templates/template_oa_jwt/public/src/pages/demo/index.less +15 -0
  98. package/templates/template_oa_jwt/public/src/pages/login/index.jsx +29 -0
  99. package/templates/template_oa_jwt/public/src/pages/login/index.less +44 -0
  100. package/templates/template_oa_jwt/public/src/pages/redirect/index.jsx +31 -0
  101. package/templates/template_oa_jwt/public/src/provider/app.jsx +66 -0
  102. package/templates/template_oa_jwt/public/src/route.jsx +45 -0
  103. package/templates/template_oa_jwt/public/src/services/common.js +133 -0
  104. package/templates/template_oa_jwt/public/src/services/demo.js +41 -0
  105. package/templates/template_oa_jwt/public/src/services/index.js +266 -0
  106. package/templates/template_oa_jwt/public/src/services/token.js +132 -0
  107. package/templates/template_oa_jwt/public/src/utils/index.js +115 -0
  108. package/templates/template_oa_jwt/public/static/about.html +1 -0
  109. package/templates/template_oa_jwt/public/static/kssoLogin.html +22 -0
  110. package/templates/template_oa_jwt/public/static/noAuth.html +217 -0
  111. package/templates/template_oa_jwt/public/static/noAuth.png +0 -0
  112. package/templates/template_oa_jwt/readme.md +71 -0
  113. package/templates/template_oa_jwt/report.sh +68 -0
  114. package/templates/template_oa_jwt/tools/iconfont/gulpfile.js +70 -0
  115. package/templates/template_oa_jwt/tools/iconfont/package.json +20 -0
  116. package/templates/template_oa_jwt/tools/iconfont/run.sh +39 -0
  117. package/templates/template_oa_jwt/tools/iconfont/svg/arrowBack.svg +1 -0
  118. package/templates/template_oa_jwt/tools/iconfont/svg/check.svg +1 -0
  119. package/templates/template_oa_jwt/tools/iconfont/svg/close.svg +1 -0
  120. package/templates/template_oa_jwt/tools/iconfont/svg/down.svg +1 -0
  121. package/templates/template_oa_jwt/tools/iconfont/svg/image.svg +1 -0
  122. package/templates/template_oa_jwt/tools/iconfont/svg/play.svg +1 -0
  123. package/templates/template_oa_jwt/tools/iconfont/svg/refresh.svg +1 -0
  124. package/templates/template_oa_jwt/tools/iconfont/svg/warn.svg +1 -0
  125. package/templates/template_oa_jwt/tools/iconfont/templates/_icons.css +26 -0
  126. package/templates/template_oa_jwt/tools/iconfont/templates/_icons.less +29 -0
  127. package/templates/template_oa_jwt/tools/iconfont/templates/index.html +56 -0
  128. package/templates/template_oa_jwt/tools/tinypng/package.json +11 -0
  129. package/templates/template_oa_jwt/tools/tinypng/run.sh +15 -0
  130. package/templates/template_oa_jwt/versionPublish.sh +27 -0
  131. package/templates/template_oa_jwt/webpack.api.js +61 -0
  132. package/templates/template_offcial/public/src/mock/index.js +0 -2
  133. package/templates/template_admin/.gitignore +0 -6
  134. package/templates/template_app/.gitignore +0 -6
  135. package/templates/template_oa/.gitignore +0 -6
  136. package/templates/template_offcial/.gitignore +0 -6
@@ -0,0 +1,52 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Outlet } from 'react-router-dom';
3
+ import Iframe from '@/components/IFrame';
4
+ import PageLoading from '@/components/Page/PageLoading';
5
+ import ProviderApp from '@/provider/app';
6
+ import { toHref, isNoAuth } from '@/utils';
7
+ import styles from './index.less';
8
+
9
+
10
+ const LayoutBasic = (props) => {
11
+ const providerApp = ProviderApp.useContainer();
12
+
13
+
14
+ const onClick = () => {
15
+ toHref('/#/cases');
16
+ }
17
+
18
+ const { nav = "" } = props;
19
+ return (
20
+ <section className={styles.htmlWrap}>
21
+ {
22
+ window?.knFeishu?.IS_FEISHU()
23
+ ? null
24
+ : <>
25
+
26
+ <Iframe name='header' url={OA_MENU_HOST} className={styles.iframeHeader} />
27
+ <section className={styles.headerSpace}></section>
28
+ </>
29
+ }
30
+
31
+ <section className={styles.bodyWrap}>
32
+ <section className={styles.centerWrap}>
33
+ <div className={styles.crumbs}>
34
+ <b>当前位置:</b>
35
+ <span>部门</span>
36
+ <span style={{ margin: '0 4px' }}>{'>'}</span>
37
+ <a onClick={onClick}>{document.title}</a>
38
+ </div>
39
+ <section className={styles.content}>
40
+ {nav}
41
+ <section className={styles.body}>
42
+ <Outlet />
43
+ </section>
44
+ </section>
45
+ </section>
46
+ </section>
47
+
48
+ </section>
49
+ )
50
+ }
51
+
52
+ export default LayoutBasic;
@@ -0,0 +1,82 @@
1
+ @import '~@/_variable.less';
2
+
3
+ .htmlWrap{
4
+ width:100%;
5
+ height:100%;
6
+ overflow: hidden;
7
+ display: block;
8
+ display: flex;
9
+ flex-direction: column;
10
+ }
11
+ .bodyWrap{
12
+ flex:1;
13
+ width: 100%;
14
+ overflow: auto;
15
+ overflow: scroll;
16
+ -webkit-overflow-scrolling: touch;
17
+ }
18
+ .centerWrap {
19
+ min-width: 1200px;
20
+ max-width: 1600px;
21
+ position: relative;
22
+ margin: 0 auto;
23
+ padding: 0 20px;
24
+ z-index:0;
25
+ // padding-bottom: var(--height-footer);
26
+
27
+ }
28
+
29
+ .iframeHeader{
30
+ min-width: 100%;
31
+ width: 1200px;
32
+ height: var(--height-header);
33
+ min-height: var(--height-header);
34
+ position: fixed;
35
+ left:0;
36
+ top:0;
37
+ z-index: 2;
38
+ font-size: 60px;
39
+ overflow: hidden;
40
+ }
41
+ .headerSpace{
42
+ width: 100%;
43
+ height: var(--height-header);
44
+ }
45
+
46
+ .crumbs{
47
+ height: 36px;
48
+ width: 100%;
49
+ max-width: 1600px;
50
+ font-size: 14px;
51
+ color: #666;
52
+ margin-bottom: 2px;
53
+ display: flex;
54
+ align-items: center;
55
+ p,
56
+ span {
57
+ font-size: inherit;
58
+ color: inherit;
59
+ }
60
+ span {
61
+ color: rgba(0, 0, 0, 0.65);
62
+ }
63
+ }
64
+
65
+ .content{
66
+ display: flex;
67
+ box-shadow: 0 0 5px 0 rgba(0,0,0,.15);
68
+ .body {
69
+ overflow: auto;
70
+ flex:1;
71
+ height:100%;
72
+ position: relative;
73
+ &::-webkit-scrollbar {
74
+ display: none;
75
+ }
76
+ }
77
+
78
+ }
79
+
80
+
81
+
82
+
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ import styles from './index.less';
4
+
5
+
6
+ const LayoutCenterBody=(props)=>{
7
+ const {className,layout='normal'} = props;
8
+
9
+ return (
10
+ <section data-layout={layout} className={ className?`${styles.contentBody} ${className}`:styles.contentBody }>
11
+ {props.children}
12
+ </section>
13
+ )
14
+ }
15
+ export default LayoutCenterBody;
@@ -0,0 +1,36 @@
1
+ @import '~@/_variable.less';
2
+
3
+
4
+ .contentBody{
5
+ width:100%;
6
+ height:100%;
7
+ overflow: auto;
8
+ overflow: scroll;
9
+ -webkit-overflow-scrolling: touch;
10
+
11
+
12
+ &[data-layout='xy-center']{
13
+ display: flex;
14
+ flex-direction: column;
15
+ justify-content: center;
16
+ align-items: center;
17
+ }
18
+ &[data-layout='x-center']{
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ flex-wrap: wrap;
23
+ }
24
+ &[data-layout='y-center']{
25
+ display: flex;
26
+ flex-direction: column;
27
+ justify-content: center;
28
+ }
29
+ }
30
+
31
+ body[data-debug-layout]{
32
+ .contentBody{
33
+ border:1px solid red;
34
+ }
35
+ }
36
+
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import styles from './index.less';
3
+
4
+
5
+
6
+ export const FormBlockByTitle = (props) => {
7
+ const {className=''}=props;
8
+ return (
9
+ <section id={props.title} className={`${styles.blockByTitle} ${className}`}>
10
+ {props.title || props.rightBtns ? (
11
+ <div className={styles.titleLine}>
12
+ <div>{props.title ? <div className={styles.title}>{props.title}</div> : ''}</div>
13
+ <div className={styles.rightBtns}>{props.rightBtns}</div>
14
+ </div>
15
+ ) : (
16
+ <div className={styles.titleNone} />
17
+ )}
18
+ {props.children}
19
+ </section>
20
+ );
21
+ };
22
+
23
+ export default FormBlockByTitle;
@@ -0,0 +1,37 @@
1
+
2
+ .blockByTitle {
3
+ border: 1px solid #eaeaea;
4
+ padding: 0 19px 15px;
5
+ background: white;
6
+ border-radius: 3px;
7
+ margin-bottom: 20px;
8
+ &:last-child {
9
+ margin-bottom: 0;
10
+ }
11
+ }
12
+ .titleLine {
13
+ width: 100%;
14
+ height: 50px;
15
+ display: flex;
16
+ justify-content: space-between;
17
+ }
18
+ .title {
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ height: 26px;
23
+ min-width: 78px;
24
+ padding: 0 6px;
25
+ color: #fffefe;
26
+ border-radius: 0 0 4px 4px;
27
+ background-color: #2a96fc;
28
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
29
+ }
30
+ .titleNone{
31
+ height: 15px;
32
+ width: 100%;
33
+ }
34
+
35
+ .rightBtns{
36
+ margin-top: 10px;
37
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import {Outlet} from 'react-router-dom';
3
+ import ProviderApp from '@/provider/app';
4
+
5
+ const LayoutProvider=(props)=>{
6
+ return (
7
+ <ProviderApp.Provider>
8
+ <Outlet />
9
+ </ProviderApp.Provider>
10
+ )
11
+ }
12
+ export default LayoutProvider;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import ProviderApp from '@/provider/app';
3
+
4
+
5
+ import {Outlet} from 'react-router-dom';
6
+ import { ConfigProvider } from 'antd';
7
+ import LayoutBasic from './Basic';
8
+ import LayoutCenterBody from './CenterBody';
9
+ import zhCN from 'antd/lib/locale/zh_CN';
10
+
11
+ import styles from './index.less';
12
+ styles;
13
+
14
+ // 站点最基础的layout,用于控制一些全局环境变量
15
+ const Layout = (props) => {
16
+ return (
17
+ <ProviderApp.Provider>
18
+ <ConfigProvider locale={zhCN} autoInsertSpaceInButton={false}>
19
+ <Outlet />
20
+ </ConfigProvider>
21
+ </ProviderApp.Provider>
22
+ );
23
+ };
24
+
25
+
26
+
27
+ export { Layout,LayoutCenterBody,LayoutBasic };
@@ -0,0 +1,8 @@
1
+ @import '~@/_variable.less';
2
+
3
+
4
+ body[data-debug-layout]{
5
+ .layout .center{
6
+ border:4px solid #4366a0;
7
+ }
8
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { openLink,jumpUrl } from '@/utils';
3
+ import styles from './index.less';
4
+
5
+ const Link=(props)=>{
6
+ const {children,className='',onClick,href='',target=''} = props;
7
+
8
+ const onLink=()=>{
9
+ if(href){
10
+ if(target=='_blank'){
11
+ openLink(href);
12
+ // window.open(href);
13
+ }else{
14
+ jumpUrl(href);
15
+ }
16
+ return;
17
+ }
18
+ if(onClick)onClick();
19
+ }
20
+ return (
21
+ <span onClick={onLink} className={`${styles.linkWrap} ${className}`}>{children}</span>
22
+ )
23
+ }
24
+ export default React.memo(Link);
@@ -0,0 +1,11 @@
1
+ @import '~@/_variable.less';
2
+
3
+
4
+ .linkWrap{
5
+ color: var(--color-primary);
6
+ font-size: 14px;
7
+ &:hover{
8
+ color: var(--color-primary-hover);
9
+ cursor: pointer;
10
+ }
11
+ }
@@ -0,0 +1,16 @@
1
+
2
+
3
+ import React,{useMemo} from 'react';
4
+ import styles from './index.less';
5
+ styles;
6
+ export const Loading=()=>{
7
+ return (
8
+ <div className='loading-container'>
9
+ <div className="ldio-2oha7mxue8v">
10
+ <div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>
11
+ </div>
12
+ </div>
13
+ )
14
+ }
15
+
16
+ export default React.memo(Loading);
@@ -0,0 +1,96 @@
1
+
2
+ :global{
3
+ @color:#000;
4
+ @keyframes ldio-2oha7mxue8v {
5
+ 0% { opacity: 1 }
6
+ 100% { opacity: 0 }
7
+ }
8
+ .ldio-2oha7mxue8v div:local {
9
+ left:0px;
10
+ top:0px;
11
+ position: absolute;
12
+ animation: ldio-2oha7mxue8v linear 1s infinite;
13
+ background: @color;
14
+ width: 12px;
15
+ height: 24px;
16
+ border-radius: 6px / 12px;
17
+ transform-origin: 40px 40px;
18
+ }
19
+ .ldio-2oha7mxue8v div:nth-child(1) {
20
+ transform: rotate(0deg);
21
+ animation-delay: -0.9166666666666666s;
22
+ background: @color;
23
+ }.ldio-2oha7mxue8v div:nth-child(2) {
24
+ transform: rotate(30deg);
25
+ animation-delay: -0.8333333333333334s;
26
+ background: @color;
27
+ }.ldio-2oha7mxue8v div:nth-child(3) {
28
+ transform: rotate(60deg);
29
+ animation-delay: -0.75s;
30
+ background: @color;
31
+ }.ldio-2oha7mxue8v div:nth-child(4) {
32
+ transform: rotate(90deg);
33
+ animation-delay: -0.6666666666666666s;
34
+ background: @color;
35
+ }.ldio-2oha7mxue8v div:nth-child(5) {
36
+ transform: rotate(120deg);
37
+ animation-delay: -0.5833333333333334s;
38
+ background: @color;
39
+ }.ldio-2oha7mxue8v div:nth-child(6) {
40
+ transform: rotate(150deg);
41
+ animation-delay: -0.5s;
42
+ background: @color;
43
+ }.ldio-2oha7mxue8v div:nth-child(7) {
44
+ transform: rotate(180deg);
45
+ animation-delay: -0.4166666666666667s;
46
+ background: @color;
47
+ }.ldio-2oha7mxue8v div:nth-child(8) {
48
+ transform: rotate(210deg);
49
+ animation-delay: -0.3333333333333333s;
50
+ background: @color;
51
+ }.ldio-2oha7mxue8v div:nth-child(9) {
52
+ transform: rotate(240deg);
53
+ animation-delay: -0.25s;
54
+ background: @color;
55
+ }.ldio-2oha7mxue8v div:nth-child(10) {
56
+ transform: rotate(270deg);
57
+ animation-delay: -0.16666666666666666s;
58
+ background: @color;
59
+ }.ldio-2oha7mxue8v div:nth-child(11) {
60
+ transform: rotate(300deg);
61
+ animation-delay: -0.08333333333333333s;
62
+ background: @color;
63
+ }.ldio-2oha7mxue8v div:nth-child(12) {
64
+ transform: rotate(330deg);
65
+ animation-delay: 0s;
66
+ background: @color;
67
+ }
68
+ .loadingio-spinner-spinner-vviroavveu {
69
+ width: 200px;
70
+ height: 200px;
71
+ display: inline-block;
72
+ overflow: hidden;
73
+ background: transparent;
74
+ }
75
+ .ldio-2oha7mxue8v {
76
+ width: 80px;
77
+ height: 80px;
78
+ position: absolute;
79
+ transform: translateZ(0) scale(0.5) translate(-50%, 0);
80
+ backface-visibility: hidden;
81
+ transform-origin: 0 0; /* see note above */
82
+ top: 200px;
83
+ left: 50%;
84
+ z-index: 99999;
85
+ }
86
+ .loading-container {
87
+ position: fixed;
88
+ top: 0;
89
+ left: 0;
90
+ width: 100vw;
91
+ height: 100vh;
92
+ z-index: 99999;
93
+ }
94
+ .ldio-2oha7mxue8v div { box-sizing: content-box; }
95
+ /* generated by https://loading.io/ */
96
+ }
@@ -0,0 +1,184 @@
1
+ import { Menu } from 'antd';
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import {matchPath,useLocation,useNavigate,} from 'react-router-dom';
4
+ import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
5
+ import {useLoading} from '@/hooks';
6
+
7
+ import styles from './index.less';
8
+
9
+ const ICON_NAME={
10
+ 'AppstoreOutlined':<AppstoreOutlined />,
11
+ 'MailOutlined':<MailOutlined />,
12
+ 'SettingOutlined':<SettingOutlined />,
13
+ }
14
+
15
+
16
+ const SUB_MENU_CONFIG=[
17
+ {
18
+ path:'/',//匹配菜单路由是/video的菜单
19
+ // routeTemplate:''匹配某个模板菜单的模板
20
+ subRoute:[
21
+ {
22
+ path:'/detail',//将video/detail这个路由匹配给菜单/video
23
+ // routeTemplate:''//也可以将某个路由模板匹配给某个菜单
24
+ }
25
+ ]
26
+ },
27
+ ]
28
+
29
+ const MenuRoute=[
30
+ {
31
+ label:'内容管理',
32
+ icon:'AppstoreOutlined',
33
+ children:[
34
+ {label:'剧集管理',path:'/'},
35
+ ]
36
+ },
37
+ {
38
+ label:'用户中心',
39
+ icon:'CustomerServiceOutlined',
40
+ path:'/my'
41
+ },
42
+ ]
43
+
44
+ const LeftMenu=(props)=>{
45
+
46
+ const loader = useLoading();
47
+ const [menus,setMenus] = useState([]);
48
+ const [openKeys,setOpenKeys] = useState([]);
49
+ const [selectedKeys,setSelectKeys] = useState([]);
50
+ const curRoute = useLocation();
51
+ const nav = useNavigate();
52
+
53
+ const MENU_KEY_COUNTER=useRef(1);
54
+ const MENU_KEY=useRef({});
55
+
56
+ const getSubConfig=(menu)=>{
57
+ const {path,routeTemplate}= menu;
58
+ for(let i=0;i<SUB_MENU_CONFIG.length;i++){
59
+ let sub= SUB_MENU_CONFIG[i];
60
+ if(routeTemplate&&sub.routeTemplate&&routeTemplate==sub.routeTemplate){
61
+ return sub.subRoute;
62
+ }
63
+ if(path&&sub.path&&path==sub.path){
64
+ return sub.subRoute;
65
+ }
66
+ }
67
+ return null;
68
+ }
69
+
70
+ const translateMenu=(data={},parent)=>{
71
+ const {label,icon,children,path}= data;
72
+ let myKey = `${MENU_KEY_COUNTER.current}`
73
+ let item ={
74
+ key:myKey,
75
+ label,
76
+ source:data,
77
+ path,
78
+ routepath:parent?`${parent.key}-${myKey}`:myKey
79
+ }
80
+ MENU_KEY.current[myKey] = item;
81
+ MENU_KEY_COUNTER.current++;
82
+ if(icon){
83
+ item.icon= ICON_NAME[icon];
84
+ }
85
+ let subRoute= getSubConfig(data);
86
+ item.source.subRoute= subRoute;
87
+ if(children){
88
+ item.children = children.map(childData=>{
89
+ return translateMenu(childData,item)
90
+ })
91
+ }
92
+ return item;
93
+ }
94
+
95
+
96
+ window.matchPath=matchPath;
97
+
98
+
99
+ const GET_ROUTE_MENU=(menuList)=>{
100
+ let groupKeys=[];
101
+ for(let key in menuList){
102
+ const menuItem = menuList[key];
103
+ const {path,routeTemplate,subRoute}= menuItem.source;
104
+ if(path){
105
+ let fn = matchPath;
106
+ let match= fn(routeTemplate||path,curRoute.pathname);
107
+ if(!match&&subRoute){
108
+ match= subRoute.some(sub=>{
109
+ let subMatch= fn(sub.routeTemplate||sub.path,curRoute.pathname);
110
+ if(subMatch){
111
+ return true;
112
+ }
113
+ return false;
114
+ })
115
+ }
116
+ if(match){
117
+ groupKeys = menuItem.routepath?menuItem.routepath.split('-'):'';
118
+ }
119
+ }
120
+ }
121
+ return groupKeys;
122
+ }
123
+
124
+ const loadMenu= async ()=>{
125
+ loader.setLoading(true);
126
+ // const req= await GET_LEFT_MENU();
127
+
128
+
129
+ const req= {code:0,info:MenuRoute}
130
+ if(req.info){
131
+ const menuList= req.info.map(menu=>{
132
+ return translateMenu(menu)
133
+ })
134
+ setMenus(menuList);
135
+ }else{
136
+ setMenus([]);
137
+ }
138
+ loader.setLoading(false);
139
+ }
140
+
141
+ useEffect(()=>{
142
+ loadMenu();
143
+ },[])
144
+
145
+ useEffect(()=>{
146
+ let groupKeys= GET_ROUTE_MENU(MENU_KEY.current);
147
+ setOpenKeys(groupKeys);
148
+ let selectKey =groupKeys[groupKeys.length-1];
149
+ setSelectKeys([selectKey])
150
+ },[curRoute,menus]);
151
+
152
+ const onClickMenuItem=(e)=>{
153
+ const { item, key, keyPath, domEvent } = e;
154
+ const menuData = MENU_KEY.current[key];
155
+ if(menuData.path){
156
+ nav(menuData.path);
157
+ }
158
+ }
159
+ const onOpenChange=(keys)=>{
160
+ setOpenKeys(keys);
161
+ }
162
+ return (
163
+ <section
164
+ className={styles.wrap}
165
+ >
166
+
167
+ <Menu
168
+ selectedKeys={selectedKeys}
169
+ className={styles.nav}
170
+ openKeys={openKeys}
171
+ onOpenChange={onOpenChange}
172
+ onClick={onClickMenuItem}
173
+ mode="inline"
174
+ items={loader.loading?[]:menus}
175
+ />
176
+
177
+ </section>
178
+
179
+
180
+ )
181
+ }
182
+
183
+ export default LeftMenu;
184
+
@@ -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
+ }
@@ -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);