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.
Files changed (218) hide show
  1. package/build/cli.config.js +5 -0
  2. package/build/webpack.config.js +4 -3
  3. package/package.json +3 -1
  4. package/readme.md +8 -0
  5. package/src/build.js +1 -0
  6. package/templates/template_oa/.DS_Store +0 -0
  7. package/templates/template_oa/build.sh +2 -0
  8. package/templates/template_oa/cli.config.js +24 -0
  9. package/templates/template_oa/dev.sh +89 -0
  10. package/templates/template_oa/frontend_build.sh +83 -0
  11. package/templates/template_oa/init/prepare-commit-msg +5 -0
  12. package/templates/template_oa/init.sh +33 -0
  13. package/templates/template_oa/jsconfig.json +10 -0
  14. package/templates/template_oa/package-lock.json +1925 -0
  15. package/templates/template_oa/package.json +24 -0
  16. package/templates/template_oa/public/.DS_Store +0 -0
  17. package/templates/template_oa/public/404.html +26 -0
  18. package/templates/template_oa/public/favicon.ico +0 -0
  19. package/templates/template_oa/public/favicon.png +0 -0
  20. package/templates/template_oa/public/index.html +43 -0
  21. package/templates/template_oa/public/pluginjs/.DS_Store +0 -0
  22. package/templates/template_oa/public/src/.DS_Store +0 -0
  23. package/templates/template_oa/public/src/_antd.less +237 -0
  24. package/templates/template_oa/public/src/_reset.less +131 -0
  25. package/templates/template_oa/public/src/_variable.less +84 -0
  26. package/templates/template_oa/public/src/assets/.DS_Store +0 -0
  27. package/templates/template_oa/public/src/assets/iconfont/.DS_Store +0 -0
  28. package/templates/template_oa/public/src/assets/iconfont/iconfont.eot +0 -0
  29. package/templates/template_oa/public/src/assets/iconfont/iconfont.less +57 -0
  30. package/templates/template_oa/public/src/assets/iconfont/iconfont.svg +36 -0
  31. package/templates/template_oa/public/src/assets/iconfont/iconfont.ttf +0 -0
  32. package/templates/template_oa/public/src/assets/iconfont/iconfont.woff +0 -0
  33. package/templates/template_oa/public/src/assets/iconfont/iconfont.woff2 +0 -0
  34. package/templates/template_oa/public/src/assets/images/.DS_Store +0 -0
  35. package/templates/template_oa/public/src/assets/images/avatar.png +0 -0
  36. package/templates/template_oa/public/src/assets/images/loading.svg +40 -0
  37. package/templates/template_oa/public/src/components/.DS_Store +0 -0
  38. package/templates/template_oa/public/src/components/Alert/index.jsx +0 -0
  39. package/templates/template_oa/public/src/components/Alert/index.less +0 -0
  40. package/templates/template_oa/public/src/components/Auth/index.jsx +44 -0
  41. package/templates/template_oa/public/src/components/Footer/index.jsx +17 -0
  42. package/templates/template_oa/public/src/components/Footer/index.less +28 -0
  43. package/templates/template_oa/public/src/components/IFrame/index.jsx +37 -0
  44. package/templates/template_oa/public/src/components/IFrame/index.less +4 -0
  45. package/templates/template_oa/public/src/components/IconFont/index.jsx +10 -0
  46. package/templates/template_oa/public/src/components/IconFont/index.less +5 -0
  47. package/templates/template_oa/public/src/components/Layout/.DS_Store +0 -0
  48. package/templates/template_oa/public/src/components/Layout/Basic/index.jsx +31 -0
  49. package/templates/template_oa/public/src/components/Layout/Basic/index.less +74 -0
  50. package/templates/template_oa/public/src/components/Layout/CenterBody/index.jsx +15 -0
  51. package/templates/template_oa/public/src/components/Layout/CenterBody/index.less +36 -0
  52. package/templates/template_oa/public/src/components/Layout/FormBlock/index.jsx +23 -0
  53. package/templates/template_oa/public/src/components/Layout/FormBlock/index.less +34 -0
  54. package/templates/template_oa/public/src/components/Layout/Provider/index.jsx +12 -0
  55. package/templates/template_oa/public/src/components/Layout/index.jsx +26 -0
  56. package/templates/template_oa/public/src/components/Layout/index.less +8 -0
  57. package/templates/template_oa/public/src/components/Link/index.jsx +24 -0
  58. package/templates/template_oa/public/src/components/Link/index.less +11 -0
  59. package/templates/template_oa/public/src/components/Loading/index.jsx +14 -0
  60. package/templates/template_oa/public/src/components/Loading/index.less +85 -0
  61. package/templates/template_oa/public/src/components/Nav/index.jsx +121 -0
  62. package/templates/template_oa/public/src/components/Nav/index.less +38 -0
  63. package/templates/template_oa/public/src/components/Page/.DS_Store +0 -0
  64. package/templates/template_oa/public/src/components/Page/PageLoading/index.jsx +30 -0
  65. package/templates/template_oa/public/src/components/Page/PageLoading/index.less +29 -0
  66. package/templates/template_oa/public/src/components/Popup/index.jsx +22 -0
  67. package/templates/template_oa/public/src/components/Popup/index.less +18 -0
  68. package/templates/template_oa/public/src/components/Toast/index.jsx +60 -0
  69. package/templates/template_oa/public/src/components/Toast/index.less +43 -0
  70. package/templates/template_oa/public/src/components/mask/index.jsx +47 -0
  71. package/templates/template_oa/public/src/components/mask/index.less +32 -0
  72. package/templates/template_oa/public/src/dictionary/index.js +39 -0
  73. package/templates/template_oa/public/src/hooks/.DS_Store +0 -0
  74. package/templates/template_oa/public/src/hooks/index.jsx +20 -0
  75. package/templates/template_oa/public/src/hooks/useDelay.jsx +29 -0
  76. package/templates/template_oa/public/src/hooks/useImageLoader.jsx +27 -0
  77. package/templates/template_oa/public/src/hooks/useLoading.jsx +42 -0
  78. package/templates/template_oa/public/src/hooks/useLogin.jsx +33 -0
  79. package/templates/template_oa/public/src/hooks/usePreload.jsx +66 -0
  80. package/templates/template_oa/public/src/hooks/useScrollTop.jsx +32 -0
  81. package/templates/template_oa/public/src/hooks/useSearch.jsx +137 -0
  82. package/templates/template_oa/public/src/hooks/useUpdate.jsx +11 -0
  83. package/templates/template_oa/public/src/index.jsx +50 -0
  84. package/templates/template_oa/public/src/mock/auth.js +91 -0
  85. package/templates/template_oa/public/src/mock/index.js +63 -0
  86. package/templates/template_oa/public/src/mock/user.js +70 -0
  87. package/templates/template_oa/public/src/mock/utils.js +33 -0
  88. package/templates/template_oa/public/src/pages/.DS_Store +0 -0
  89. package/templates/template_oa/public/src/pages/components/pageTitle/index.jsx +13 -0
  90. package/templates/template_oa/public/src/pages/components/pageTitle/index.less +20 -0
  91. package/templates/template_oa/public/src/pages/login/index.jsx +27 -0
  92. package/templates/template_oa/public/src/pages/login/index.less +44 -0
  93. package/templates/template_oa/public/src/pages/video/index.jsx +91 -0
  94. package/templates/template_oa/public/src/pages/video/index.less +12 -0
  95. package/templates/template_oa/public/src/provider/app.jsx +119 -0
  96. package/templates/template_oa/public/src/provider/menu.jsx +20 -0
  97. package/templates/template_oa/public/src/route.jsx +43 -0
  98. package/templates/template_oa/public/src/services/.DS_Store +0 -0
  99. package/templates/template_oa/public/src/services/auth.js +121 -0
  100. package/templates/template_oa/public/src/services/index.js +181 -0
  101. package/templates/template_oa/public/src/services/user.js +26 -0
  102. package/templates/template_oa/public/src/services/video.js +33 -0
  103. package/templates/template_oa/public/src/utils/.DS_Store +0 -0
  104. package/templates/template_oa/public/src/utils/index.js +66 -0
  105. package/templates/template_oa/public/static/.DS_Store +0 -0
  106. package/templates/template_oa/public/static/about.html +1 -0
  107. package/templates/template_oa/public/static/kssoLogin.html +22 -0
  108. package/templates/template_oa/readme.md +60 -0
  109. package/templates/template_oa/release/.DS_Store +0 -0
  110. package/templates/template_oa/report.sh +68 -0
  111. package/templates/template_oa/tools/.DS_Store +0 -0
  112. package/templates/template_oa/tools/iconfont/.DS_Store +0 -0
  113. package/templates/template_oa/tools/iconfont/dist/.DS_Store +0 -0
  114. package/templates/template_oa/tools/iconfont/gulpfile.js +70 -0
  115. package/templates/template_oa/tools/iconfont/package.json +20 -0
  116. package/templates/template_oa/tools/iconfont/run.sh +39 -0
  117. package/templates/template_oa/tools/iconfont/svg/.DS_Store +0 -0
  118. package/templates/template_oa/tools/iconfont/svg/arrowBack.svg +1 -0
  119. package/templates/template_oa/tools/iconfont/svg/check.svg +1 -0
  120. package/templates/template_oa/tools/iconfont/svg/close.svg +1 -0
  121. package/templates/template_oa/tools/iconfont/svg/down.svg +1 -0
  122. package/templates/template_oa/tools/iconfont/svg/image.svg +1 -0
  123. package/templates/template_oa/tools/iconfont/svg/play.svg +1 -0
  124. package/templates/template_oa/tools/iconfont/svg/refresh.svg +1 -0
  125. package/templates/template_oa/tools/iconfont/svg/warn.svg +1 -0
  126. package/templates/template_oa/tools/iconfont/templates/_icons.css +26 -0
  127. package/templates/template_oa/tools/iconfont/templates/_icons.less +29 -0
  128. package/templates/template_oa/tools/iconfont/templates/index.html +56 -0
  129. package/templates/template_oa/tools/tinypng/.DS_Store +0 -0
  130. package/templates/template_oa/tools/tinypng/img/.DS_Store +0 -0
  131. package/templates/template_oa/tools/tinypng/package.json +11 -0
  132. package/templates/template_oa/tools/tinypng/run.sh +15 -0
  133. package/templates/template_oa/versionPublish.sh +27 -0
  134. package/templates/template_oa/webpack.api.js +62 -0
  135. package/templates/template_offcial/.gitignore +6 -0
  136. package/templates/template_offcial/build.sh +2 -0
  137. package/templates/template_offcial/cli.config.js +25 -0
  138. package/templates/template_offcial/dev.sh +89 -0
  139. package/templates/template_offcial/frontend_build.sh +83 -0
  140. package/templates/template_offcial/init/prepare-commit-msg +5 -0
  141. package/templates/template_offcial/init.sh +33 -0
  142. package/templates/template_offcial/jsconfig.json +10 -0
  143. package/templates/template_offcial/package.json +23 -0
  144. package/templates/template_offcial/public/404.html +26 -0
  145. package/templates/template_offcial/public/favicon.ico +0 -0
  146. package/templates/template_offcial/public/favicon.png +0 -0
  147. package/templates/template_offcial/public/index.html +52 -0
  148. package/templates/template_offcial/public/src/_antd.less +4 -0
  149. package/templates/template_offcial/public/src/_reset.less +130 -0
  150. package/templates/template_offcial/public/src/_variable.less +78 -0
  151. package/templates/template_offcial/public/src/assets/iconfont/iconfont.eot +0 -0
  152. package/templates/template_offcial/public/src/assets/iconfont/iconfont.less +57 -0
  153. package/templates/template_offcial/public/src/assets/iconfont/iconfont.svg +36 -0
  154. package/templates/template_offcial/public/src/assets/iconfont/iconfont.ttf +0 -0
  155. package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff +0 -0
  156. package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff2 +0 -0
  157. package/templates/template_offcial/public/src/assets/images/avatar.png +0 -0
  158. package/templates/template_offcial/public/src/assets/images/loading.svg +40 -0
  159. package/templates/template_offcial/public/src/components/Alert/index.jsx +0 -0
  160. package/templates/template_offcial/public/src/components/Alert/index.less +0 -0
  161. package/templates/template_offcial/public/src/components/Footer/index.jsx +32 -0
  162. package/templates/template_offcial/public/src/components/Footer/index.less +8 -0
  163. package/templates/template_offcial/public/src/components/Header/index.jsx +68 -0
  164. package/templates/template_offcial/public/src/components/Header/index.less +76 -0
  165. package/templates/template_offcial/public/src/components/IconFont/index.jsx +10 -0
  166. package/templates/template_offcial/public/src/components/IconFont/index.less +5 -0
  167. package/templates/template_offcial/public/src/components/Layout/Provider/index.jsx +12 -0
  168. package/templates/template_offcial/public/src/components/Layout/index.jsx +20 -0
  169. package/templates/template_offcial/public/src/components/Layout/index.less +20 -0
  170. package/templates/template_offcial/public/src/components/Link/index.jsx +24 -0
  171. package/templates/template_offcial/public/src/components/Link/index.less +11 -0
  172. package/templates/template_offcial/public/src/components/Page/PageLoading/index.jsx +30 -0
  173. package/templates/template_offcial/public/src/components/Page/PageLoading/index.less +29 -0
  174. package/templates/template_offcial/public/src/components/Popup/index.jsx +22 -0
  175. package/templates/template_offcial/public/src/components/Popup/index.less +18 -0
  176. package/templates/template_offcial/public/src/components/Toast/index.jsx +60 -0
  177. package/templates/template_offcial/public/src/components/Toast/index.less +43 -0
  178. package/templates/template_offcial/public/src/hooks/index.jsx +12 -0
  179. package/templates/template_offcial/public/src/hooks/useImageLoader.jsx +27 -0
  180. package/templates/template_offcial/public/src/hooks/useInToView.jsx +55 -0
  181. package/templates/template_offcial/public/src/hooks/usePreload.jsx +66 -0
  182. package/templates/template_offcial/public/src/hooks/useScroll.jsx +66 -0
  183. package/templates/template_offcial/public/src/index.jsx +50 -0
  184. package/templates/template_offcial/public/src/mock/index.js +63 -0
  185. package/templates/template_offcial/public/src/mock/user.js +70 -0
  186. package/templates/template_offcial/public/src/mock/utils.js +33 -0
  187. package/templates/template_offcial/public/src/pages/index.jsx +23 -0
  188. package/templates/template_offcial/public/src/pages/index.less +0 -0
  189. package/templates/template_offcial/public/src/pages/mobile/index.jsx +11 -0
  190. package/templates/template_offcial/public/src/pages/mobile/index.less +0 -0
  191. package/templates/template_offcial/public/src/pages/pc/index.jsx +45 -0
  192. package/templates/template_offcial/public/src/pages/pc/index.less +42 -0
  193. package/templates/template_offcial/public/src/provider/app.jsx +26 -0
  194. package/templates/template_offcial/public/src/route.jsx +26 -0
  195. package/templates/template_offcial/public/src/services/index.js +182 -0
  196. package/templates/template_offcial/public/src/services/user.js +26 -0
  197. package/templates/template_offcial/public/src/utils/index.js +109 -0
  198. package/templates/template_offcial/public/static/about.html +1 -0
  199. package/templates/template_offcial/readme.md +59 -0
  200. package/templates/template_offcial/report.sh +68 -0
  201. package/templates/template_offcial/tools/iconfont/gulpfile.js +70 -0
  202. package/templates/template_offcial/tools/iconfont/package.json +20 -0
  203. package/templates/template_offcial/tools/iconfont/run.sh +39 -0
  204. package/templates/template_offcial/tools/iconfont/svg/arrowBack.svg +1 -0
  205. package/templates/template_offcial/tools/iconfont/svg/check.svg +1 -0
  206. package/templates/template_offcial/tools/iconfont/svg/close.svg +1 -0
  207. package/templates/template_offcial/tools/iconfont/svg/down.svg +1 -0
  208. package/templates/template_offcial/tools/iconfont/svg/image.svg +1 -0
  209. package/templates/template_offcial/tools/iconfont/svg/play.svg +1 -0
  210. package/templates/template_offcial/tools/iconfont/svg/refresh.svg +1 -0
  211. package/templates/template_offcial/tools/iconfont/svg/warn.svg +1 -0
  212. package/templates/template_offcial/tools/iconfont/templates/_icons.css +26 -0
  213. package/templates/template_offcial/tools/iconfont/templates/_icons.less +29 -0
  214. package/templates/template_offcial/tools/iconfont/templates/index.html +56 -0
  215. package/templates/template_offcial/tools/tinypng/package.json +11 -0
  216. package/templates/template_offcial/tools/tinypng/run.sh +15 -0
  217. package/templates/template_offcial/versionPublish.sh +27 -0
  218. package/templates/template_offcial/webpack.api.js +36 -0
@@ -0,0 +1,66 @@
1
+ import React, { useEffect,useState,useMemo,useRef,useCallback } from 'react';
2
+
3
+ const usePreload=(files)=>{
4
+ const [list] = useState(files);
5
+ const [count,setCount] = useState(files.length);
6
+ const [state,setState]=useState('');
7
+
8
+ const load=useCallback((options)=>{
9
+ return new Promise(resolve=>{
10
+ if(count <= 0 ){
11
+ resolve(true);
12
+ return;
13
+ }
14
+ if(state=='loading'){
15
+ resolve(false);
16
+ return;
17
+ }
18
+ setState('loading');
19
+ let per = files.length;
20
+ list.forEach((item, idx) => {
21
+ if (typeof item === 'string') {
22
+ let img = new Image();
23
+ img.onload = () => {
24
+ console.log('加载成功')
25
+ per--;
26
+ if(per<=0){
27
+ setCount(0);
28
+ if(options?.delay){
29
+ setTimeout(resolve, options.delay);
30
+ return;
31
+ }
32
+ resolve(true);
33
+ }
34
+ };
35
+ img.onerror = () => {
36
+ per--;
37
+ if(per<=0){
38
+ setCount(0);
39
+ resolve(true);
40
+ }
41
+ console.log(`图片预加载失败`,item);
42
+ };
43
+ img.src = item;
44
+ } else {
45
+ console.log(`图片预加载失败异常图片`,item);
46
+ per--;
47
+ if(per<=0){
48
+ setCount(0);
49
+ resolve(true);
50
+ }
51
+ }
52
+ });
53
+ })
54
+
55
+ },[state,setState,count]);
56
+
57
+ const actions=useMemo(()=>{
58
+ return {
59
+ count,
60
+ load,
61
+ };
62
+ },[count]);
63
+ return actions;
64
+ }
65
+
66
+ export default usePreload;
@@ -0,0 +1,32 @@
1
+ import { useState, useMemo, useEffect } from 'react'
2
+ import { createContainer } from 'unstated-next'
3
+
4
+ const useActivity = () => {
5
+ const [scrollTop, setScrollTop] = useState(0);
6
+ const [containerNode, setContainerNode] = useState();
7
+ const [clientHeight, setClientHeight] = useState(0);
8
+ const [titleRefs, setTitleRefs] = useState({});
9
+
10
+ useEffect(() => {
11
+ const node = document.getElementById('main-view');
12
+ setContainerNode(node);
13
+ setClientHeight(node.clientHeight)
14
+ node.addEventListener('scroll', (e) => {
15
+ setScrollTop(e.target.scrollTop);
16
+ })
17
+ }, [])
18
+
19
+ const action = useMemo(() => {
20
+ return {
21
+ scrollTop,
22
+ clientHeight,
23
+ titleRefs,
24
+ setTitleRefs,
25
+ containerNode,
26
+ setContainerNode,
27
+ }
28
+ }, [scrollTop, setScrollTop, clientHeight, titleRefs, setTitleRefs, containerNode, setContainerNode])
29
+ return action
30
+ }
31
+ const Activity = createContainer(useActivity);
32
+ export default Activity;
@@ -0,0 +1,137 @@
1
+ import { useRef,useState,useMemo, useEffect } from 'react';
2
+
3
+ /**
4
+ * 管理表格数据的查询搜索及分页
5
+ */
6
+ const useSearch=(props)=>{
7
+ const [search,setSearch] = useState(props.initSearch||{});
8
+ const [service] = useState(()=>props.service);
9
+ const [beforeSearch] = useState(()=>props.beforeSearch);
10
+ const [beforeService] = useState(()=>props.beforeService);
11
+
12
+ const [pagination,setPagination] = useState(()=>{
13
+ let temp = {current:1,pageSize:10,total:0,startIdx:0,...props.pagination};
14
+ temp.startIdx = (temp.current-1)*temp.pageSize;
15
+ return temp;
16
+ });
17
+ const [updateData] = useState(()=>props.updateData);
18
+ const [orderInfo,setOrderInfo]=useState({});
19
+
20
+ const onPaginationChange=async (pageInfo,sorterInfo)=>{
21
+ let {current,pageSize} = pagination;
22
+ let orderValue=orderInfo;
23
+ if(pageInfo){
24
+ current = pageInfo.current;
25
+ pageSize = pageInfo.pageSize;
26
+ }
27
+
28
+ if(sorterInfo){
29
+ const {field,order}= sorterInfo;
30
+ if(field){
31
+ if(order){
32
+ orderInfo[field] = order;
33
+ }else{
34
+ delete orderInfo[field];
35
+ }
36
+ }
37
+ orderValue = orderInfo;
38
+ setOrderInfo({...orderInfo});
39
+ }
40
+
41
+
42
+ let searchValue = await getSearchValue();
43
+ refresh({
44
+ searchValue,
45
+ pageValue:{pageSize,current},
46
+ orderValue});
47
+ }
48
+
49
+ const onSorter=async (sorter)=>{
50
+ const {field,order}= sorter;
51
+ if(field){
52
+ if(order){
53
+ orderInfo[field] = order;
54
+ }else{
55
+ delete orderInfo[field];
56
+ }
57
+ }
58
+ setOrderInfo({...orderInfo});
59
+ console.log(`${JSON.stringify(orderInfo)}`);
60
+ refresh();
61
+
62
+
63
+
64
+ }
65
+
66
+ const getSearchValue=async ()=>{
67
+ let value={};
68
+ value = search;
69
+
70
+ if(beforeSearch){
71
+ value = beforeSearch(value);
72
+ }
73
+ return value;
74
+
75
+ }
76
+ const btnSearch=async ()=>{
77
+ let value = await getSearchValue();
78
+ if(value){
79
+ refresh({searchValue:value});
80
+ }
81
+ }
82
+ const btnReset=()=>{
83
+ formRef.resetFields();
84
+ }
85
+
86
+ const refresh= async ({searchValue,pageValue,orderValue}={})=>{
87
+ searchValue = searchValue || search;
88
+ pageValue = pageValue || pagination;
89
+
90
+ // 排序暂无
91
+ // orderValue = orderValue || orderInfo;
92
+ // let order=[];
93
+ // if(orderValue){
94
+ // Object.keys(orderValue).map(name=>{
95
+ // if(orderValue[name]==='ascend'){
96
+ // order.push(`${name}`);
97
+ // }else if(orderValue[name]==='descend'){
98
+ // order.push(`-${name}`);
99
+ // }
100
+ // })
101
+ // }
102
+
103
+ let {current,pageSize} = pageValue;
104
+ let params = {...searchValue,page:current,pageSize:pageSize};
105
+ if(beforeService)params=beforeService(params);
106
+ if(!params)return;
107
+ let ret = await service(params);
108
+ if(ret?.code==0){
109
+ const {page} = ret.data;
110
+ setPagination({
111
+ current:page.pageNum||1,
112
+ pageSize:page.pageSize||10,
113
+ total:page.total,
114
+ startIdx:(page.page-1)*page.pageSize
115
+ })
116
+ }
117
+
118
+ if(updateData)updateData(ret);
119
+ return ret;
120
+ }
121
+
122
+
123
+ return {
124
+ onPaginationChange,
125
+ pagination,
126
+ btnSearch,
127
+ search,
128
+ setSearch,
129
+ refresh,
130
+ btnReset,
131
+ onSorter
132
+
133
+ };
134
+
135
+ }
136
+
137
+ export default useSearch;
@@ -0,0 +1,11 @@
1
+ import { useState, useMemo } from 'react';
2
+
3
+ const useUpdate=()=>{
4
+ const [count,setCount] = useState(1);
5
+ const action = useMemo(()=>{
6
+ return [count,()=>{setCount(count+1)}]
7
+ },[count,setCount])
8
+ return action;
9
+ }
10
+
11
+ export default useUpdate;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import {HashRouter} from 'react-router-dom';
4
+ // import {createRoot} from 'react-dom/client';
5
+ // import { createHashRouter,RouterProvider } from 'react-router-dom';
6
+ import './_antd.less';
7
+ import './_reset.less';
8
+ import {RouteList} from './route';
9
+
10
+
11
+ if(MOCK){
12
+ let mock = require('@/mock');
13
+ mock;
14
+ }
15
+
16
+ window.appLog=(txt)=>{
17
+ console.log(txt);
18
+ }
19
+
20
+ /* eslint-disable */
21
+ if(BUILD_ENV!='prod'){
22
+ let VConsole = require('vconsole');
23
+ const vConsole = new VConsole();
24
+ setTimeout(() => {
25
+ vConsole.setSwitchPosition(70, 10);
26
+ }, 2000);
27
+ }
28
+
29
+ if(BUILD_ENV){
30
+ window.appLog(`代码环境类型:${BUILD_ENV}`);
31
+ }
32
+ if (VERSION_HASH) {
33
+ window.appLog(`VERSION_HASH:${VERSION_HASH}`);
34
+ }
35
+ window.appLog(`log init`);
36
+ window.appLog(`${location.href}`);
37
+ window.appLog(`ua:${navigator.userAgent}`);
38
+ /* eslint-enable */
39
+
40
+ const BasicRoute = () => {
41
+ return (
42
+ <HashRouter>
43
+ {RouteList}
44
+ </HashRouter>
45
+ );
46
+ }
47
+
48
+ ReactDOM.render(<BasicRoute />, document.getElementById('main-view'));
49
+
50
+ // createRoot(document.getElementById('main-view')).render(<RouterProvider router={createHashRouter(router)} />);
@@ -0,0 +1,91 @@
1
+ import {waitTime,REP_SUCCESS} from './utils.js';
2
+ import qs from 'qs';
3
+ import {GET_REQUEST} from './utils';
4
+
5
+ async function GET_MENU(req,res){
6
+ await waitTime();
7
+ const MenuRoute=[
8
+ {
9
+ name:'顶部菜单',
10
+ url:'/video',
11
+ children:[
12
+ {
13
+ name:'内容管理',
14
+ icon:'AppstoreOutlined',
15
+ children:[
16
+ {name:'剧集管理',url:'/video'},
17
+ {name:'素材管理',url:'/material'},
18
+ ]
19
+
20
+ },
21
+ {
22
+ name:'数据管理',
23
+ icon:'AppstoreOutlined',
24
+ children:[
25
+ {name:'订单数据',url:'/order'},
26
+ {name:'用户数据',url:'/userData'},
27
+ ]
28
+ },
29
+ {
30
+ name:'用户管理',
31
+ icon:'UserOutlined',
32
+ url:'/user'
33
+ },
34
+ {
35
+ name:'客诉管理',
36
+ icon:'CustomerServiceOutlined',
37
+ url:'/suggest'
38
+ },
39
+ {
40
+ name:'权限配置',
41
+ icon:'CrownOutlined',
42
+ url:'/permission'
43
+ },
44
+ ]
45
+ }
46
+ ]
47
+ return {code:0,data:MenuRoute}
48
+ }
49
+
50
+ async function LOGIN(req,res){
51
+ await waitTime();
52
+ return {code:0,data:{
53
+ authorities:['admin'],
54
+ token:'token',
55
+ userId:'1',
56
+ username:'cx',
57
+ realName:'cx',
58
+ name:'cx'
59
+
60
+ }}
61
+ }
62
+
63
+ async function KSSOLOGIN(req,res){
64
+ await waitTime();
65
+ return {code:0,data:{
66
+ authorities:['admin'],
67
+ token:'token',
68
+ userId:'1',
69
+ username:'cx',
70
+ realName:'cx',
71
+ name:'cx'
72
+
73
+ }}
74
+ }
75
+
76
+
77
+ async function LOGOUT(req,res){
78
+ await waitTime();
79
+ return {code:0}
80
+ }
81
+
82
+
83
+ LOGOUT
84
+ export default {
85
+ '/api/menu/nav':{get:GET_MENU},
86
+ '/api/login':{post:LOGIN},
87
+ '/api/ksso/auth':{post:KSSOLOGIN},
88
+ '/api/logout':{post:LOGOUT},
89
+
90
+
91
+ }
@@ -0,0 +1,63 @@
1
+ import mock from 'mockjs-async';
2
+
3
+ import auth from './auth.js';
4
+ function regMock(list){
5
+ if(list){
6
+ let keys = Object.keys(list)
7
+ keys.map(key=>{
8
+ let pattern;
9
+ if(typeof key === 'string'){
10
+ pattern = new RegExp(key)
11
+ }else{
12
+ pattern=key;
13
+ }
14
+ let config = list[key];
15
+ if(typeof config == 'function'){
16
+ console.log(`[mock]注册 ()${pattern}`)
17
+ mock.mock(pattern,(options)=>{
18
+ return new Promise(reslove=>{
19
+ if(config){
20
+ config(options).then(ret=>{
21
+ console.log(`[mock]response ()${pattern}`,options,ret)
22
+ reslove(ret);
23
+ });
24
+ }else{
25
+ reslove();
26
+ }
27
+ })
28
+ i
29
+ });
30
+ }else{
31
+ let methods = Object.keys(config);
32
+ methods.forEach(method=>{
33
+ console.log(`[mock]注册 (${method})${pattern}`)
34
+ mock.mock(pattern,method,(options)=>{
35
+ return new Promise(reslove=>{
36
+ if(config[method]){
37
+ config[method](options).then(ret=>{
38
+ console.log(`[mock]response (${method})${pattern}`,options,ret)
39
+ reslove(ret);
40
+ });
41
+ }else{
42
+ reslove();
43
+ }
44
+ })
45
+ i
46
+ });
47
+ })
48
+
49
+ }
50
+ })
51
+ }
52
+ }
53
+ /* eslint-disable */
54
+ if(MOCK){
55
+ console.log(`=========MOCK OPEN=======`)
56
+ regMock(auth);
57
+ }else{
58
+ console.log(`=========MOCK CLOSE=======`)
59
+ }
60
+ /* eslint-enable */
61
+
62
+
63
+ export default {};
@@ -0,0 +1,70 @@
1
+ import {waitTime,REP_SUCCESS} from './utils.js';
2
+ import qs from 'qs';
3
+ import {GET_REQUEST} from './utils';
4
+ async function GET_USER(req,res){
5
+ const query = qs.parse(req.url.split('?')[1]);
6
+ const {name} = query;
7
+ await waitTime();
8
+ return {code:0,data:{name}}
9
+ }
10
+
11
+ async function SET_USER(req,res){
12
+ const query = JSON.parse(req.body);
13
+ const {name,age}= query;
14
+ await waitTime();
15
+
16
+ return {
17
+ "code": 0,
18
+ "data":{name,age}
19
+ }
20
+ }
21
+
22
+ async function GET_USER_LIST(req,res){
23
+ const {current,pageSize} = GET_REQUEST(req,res);
24
+ const MAX_TOTAL=98;
25
+ let data=[];
26
+ let idx=(current-1)*pageSize;
27
+
28
+ for(let i=0;i<pageSize;i++){
29
+ if(idx>=MAX_TOTAL)break;
30
+ data.push({
31
+ name:`${idx++}小朋友`
32
+ })
33
+ }
34
+ return {
35
+ code:0,
36
+ data:{
37
+ list:data,
38
+ page:{
39
+ pageNum:current,
40
+ pageSize:pageSize,
41
+ total:MAX_TOTAL
42
+ }
43
+ }
44
+ }
45
+ }
46
+
47
+ async function GET_USER_TYPE(req,res){
48
+ let data=[];
49
+ for(let i=0;i<10;i++){
50
+ data.push({
51
+ label:`标题${i}`,
52
+ value:i,
53
+ key:`title${i}`
54
+ })
55
+ }
56
+ return {
57
+ code:0,
58
+ data:data
59
+ }
60
+ }
61
+
62
+
63
+
64
+
65
+ export default {
66
+ '/userType':{get:GET_USER_TYPE},
67
+ '/userList':{get:GET_USER_LIST},
68
+ '/user':{get:GET_USER,post:SET_USER},
69
+
70
+ }
@@ -0,0 +1,33 @@
1
+ import qs from 'qs';
2
+
3
+ export const waitTime = (time = 500) => {
4
+ return new Promise((resolve) => {
5
+ setTimeout(() => {
6
+ resolve(true);
7
+ }, time);
8
+ });
9
+ };
10
+
11
+
12
+ export const REP_SUCCESS=async (req,res)=>{
13
+ await waitTime();
14
+ return res.json({code:0,data:{}})
15
+ }
16
+ export const REP_FAIL=async (req,res)=>{
17
+ await waitTime();
18
+ return res.json({code:1,message:'mock失败',data:{}})
19
+ }
20
+
21
+ export const REP_500=async (req,res)=>{
22
+ await waitTime();
23
+ // console.log(res);
24
+ return res.status(500).send({})
25
+ }
26
+
27
+
28
+ export const GET_REQUEST=(req)=>{
29
+ if(req.type=='GET'){
30
+ return qs.parse(req.url.split('?')[1]);
31
+ }
32
+ return JSON.parse(req.body);
33
+ }
@@ -0,0 +1,13 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+
4
+ import styles from './index.less';
5
+ const PageTitle=(props)=>{
6
+ return (
7
+ <section className={styles.pageTitle}>
8
+ <div className={styles.flag} />
9
+ <h3 className={styles.text}>{props.children}</h3>
10
+ </section>
11
+ );
12
+ }
13
+ export default PageTitle;
@@ -0,0 +1,20 @@
1
+
2
+ .pageTitle{
3
+ display: flex;
4
+ align-items: center;
5
+ border-bottom:1px solid rgb(232, 232, 232);
6
+ padding-bottom: 10px;
7
+ margin-bottom: 20px;
8
+ .flag{
9
+ background-color: #2a96fc;
10
+ margin-right: 7px;
11
+ width: 4px;
12
+ height: 18px;
13
+ display: block;
14
+ }
15
+ .text{
16
+ font-size: 16px;
17
+ color:#555;
18
+ margin:0;
19
+ }
20
+ }
@@ -0,0 +1,27 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
3
+ import ProviderApp from '@/provider/app';
4
+
5
+
6
+ import styles from './index.less';
7
+
8
+ const Page = () => {
9
+ const [search] = useSearchParams();
10
+ const providerApp = ProviderApp.useContainer();
11
+
12
+ const kssoLogin=async ()=>{
13
+ const req= await providerApp.kssoLogin();
14
+ if(!req){
15
+ return;
16
+ }
17
+ }
18
+ useEffect(kssoLogin,[])
19
+
20
+ return (
21
+ <section className={styles.body}>
22
+ 登录跳转中...
23
+ </section>
24
+ )
25
+ }
26
+
27
+ export default Page;
@@ -0,0 +1,44 @@
1
+
2
+ .link{
3
+ display: block;
4
+ }
5
+
6
+ .body{
7
+ width: 100%;
8
+ height:100%;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ flex-direction: column;
13
+
14
+ }
15
+ .wrap{
16
+ padding:26px 32px;
17
+ background-color: #ccc;
18
+ .title{
19
+ font-size: 24px;
20
+ font-weight: var(--weight-Medium);
21
+ margin-bottom: 24px;
22
+ }
23
+
24
+ hgroup{
25
+ margin-bottom: 16px;
26
+ display: block;
27
+ .inputLabel{
28
+ display: block;
29
+ font-size: 13px;
30
+ font-weight: var(--weight-Medium);
31
+ color: #86909C;
32
+ line-height: 22px;
33
+ }
34
+ }
35
+ .input{
36
+ width: 336px;
37
+ border-radius: 4px;
38
+ border: 1px solid #E5E6EB;
39
+ }
40
+ .btn{
41
+ width: 336px;
42
+ margin-top: 18px;
43
+ }
44
+ }