kn-cli 1.0.64 → 1.0.65

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 (129) hide show
  1. package/package.json +2 -1
  2. package/readme.md +3 -0
  3. package/src/create.js +2 -0
  4. package/templates/template_oa/public/src/components/IFrame/index.jsx +3 -0
  5. package/templates/template_oa/webpack.api.js +7 -3
  6. package/templates/template_oa_jwt/.gitignore +6 -0
  7. package/templates/template_oa_jwt/build.sh +7 -0
  8. package/templates/template_oa_jwt/cli.config.js +30 -0
  9. package/templates/template_oa_jwt/dev.sh +89 -0
  10. package/templates/template_oa_jwt/frontend_build.sh +88 -0
  11. package/templates/template_oa_jwt/init/prepare-commit-msg +5 -0
  12. package/templates/template_oa_jwt/init.sh +33 -0
  13. package/templates/template_oa_jwt/jsconfig.json +10 -0
  14. package/templates/template_oa_jwt/package.json +25 -0
  15. package/templates/template_oa_jwt/public/404.html +26 -0
  16. package/templates/template_oa_jwt/public/favicon.ico +0 -0
  17. package/templates/template_oa_jwt/public/index.html +44 -0
  18. package/templates/template_oa_jwt/public/src/_antd.less +216 -0
  19. package/templates/template_oa_jwt/public/src/_reset.less +134 -0
  20. package/templates/template_oa_jwt/public/src/_variable.less +84 -0
  21. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.eot +0 -0
  22. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.less +57 -0
  23. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.svg +36 -0
  24. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.ttf +0 -0
  25. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff +0 -0
  26. package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff2 +0 -0
  27. package/templates/template_oa_jwt/public/src/assets/images/NY-pop-bg.png +0 -0
  28. package/templates/template_oa_jwt/public/src/assets/images/avatar.png +0 -0
  29. package/templates/template_oa_jwt/public/src/assets/images/loading.svg +40 -0
  30. package/templates/template_oa_jwt/public/src/components/Alert/index.jsx +0 -0
  31. package/templates/template_oa_jwt/public/src/components/Alert/index.less +0 -0
  32. package/templates/template_oa_jwt/public/src/components/Auth/index.jsx +44 -0
  33. package/templates/template_oa_jwt/public/src/components/Dialog/index.jsx +150 -0
  34. package/templates/template_oa_jwt/public/src/components/Dialog/index.less +123 -0
  35. package/templates/template_oa_jwt/public/src/components/Empty/index.jsx +23 -0
  36. package/templates/template_oa_jwt/public/src/components/Empty/index.less +6 -0
  37. package/templates/template_oa_jwt/public/src/components/Footer/index.jsx +17 -0
  38. package/templates/template_oa_jwt/public/src/components/Footer/index.less +28 -0
  39. package/templates/template_oa_jwt/public/src/components/FormRow/index.jsx +39 -0
  40. package/templates/template_oa_jwt/public/src/components/FormRow/index.less +67 -0
  41. package/templates/template_oa_jwt/public/src/components/FormTable/index.jsx +137 -0
  42. package/templates/template_oa_jwt/public/src/components/FormTable/index.less +18 -0
  43. package/templates/template_oa_jwt/public/src/components/IFrame/index.jsx +44 -0
  44. package/templates/template_oa_jwt/public/src/components/IFrame/index.less +4 -0
  45. package/templates/template_oa_jwt/public/src/components/IconFont/index.jsx +10 -0
  46. package/templates/template_oa_jwt/public/src/components/IconFont/index.less +5 -0
  47. package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.jsx +52 -0
  48. package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.less +82 -0
  49. package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.jsx +15 -0
  50. package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.less +36 -0
  51. package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.jsx +23 -0
  52. package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.less +37 -0
  53. package/templates/template_oa_jwt/public/src/components/Layout/Provider/index.jsx +12 -0
  54. package/templates/template_oa_jwt/public/src/components/Layout/index.jsx +27 -0
  55. package/templates/template_oa_jwt/public/src/components/Layout/index.less +8 -0
  56. package/templates/template_oa_jwt/public/src/components/Link/index.jsx +24 -0
  57. package/templates/template_oa_jwt/public/src/components/Link/index.less +11 -0
  58. package/templates/template_oa_jwt/public/src/components/Loading/index.jsx +16 -0
  59. package/templates/template_oa_jwt/public/src/components/Loading/index.less +96 -0
  60. package/templates/template_oa_jwt/public/src/components/Nav/index.jsx +184 -0
  61. package/templates/template_oa_jwt/public/src/components/Nav/index.less +38 -0
  62. package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.jsx +30 -0
  63. package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.less +29 -0
  64. package/templates/template_oa_jwt/public/src/components/Popup/index.jsx +22 -0
  65. package/templates/template_oa_jwt/public/src/components/Popup/index.less +18 -0
  66. package/templates/template_oa_jwt/public/src/components/Select/DepSelect/index.jsx +47 -0
  67. package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.jsx +97 -0
  68. package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.less +24 -0
  69. package/templates/template_oa_jwt/public/src/components/Toast/index.jsx +60 -0
  70. package/templates/template_oa_jwt/public/src/components/Toast/index.less +43 -0
  71. package/templates/template_oa_jwt/public/src/components/Upload/index.jsx +358 -0
  72. package/templates/template_oa_jwt/public/src/components/title/index.jsx +12 -0
  73. package/templates/template_oa_jwt/public/src/components/title/index.less +21 -0
  74. package/templates/template_oa_jwt/public/src/dictionary/index.js +20 -0
  75. package/templates/template_oa_jwt/public/src/hooks/index.jsx +21 -0
  76. package/templates/template_oa_jwt/public/src/hooks/useDelay.jsx +29 -0
  77. package/templates/template_oa_jwt/public/src/hooks/useImageLoader.jsx +27 -0
  78. package/templates/template_oa_jwt/public/src/hooks/useLoading.jsx +42 -0
  79. package/templates/template_oa_jwt/public/src/hooks/useLogin.jsx +33 -0
  80. package/templates/template_oa_jwt/public/src/hooks/usePreload.jsx +66 -0
  81. package/templates/template_oa_jwt/public/src/hooks/useScrollTop.jsx +32 -0
  82. package/templates/template_oa_jwt/public/src/hooks/useSearch.jsx +137 -0
  83. package/templates/template_oa_jwt/public/src/hooks/useUpdate.jsx +11 -0
  84. package/templates/template_oa_jwt/public/src/index.jsx +50 -0
  85. package/templates/template_oa_jwt/public/src/mock/common.js +484 -0
  86. package/templates/template_oa_jwt/public/src/mock/index.js +63 -0
  87. package/templates/template_oa_jwt/public/src/mock/user.js +70 -0
  88. package/templates/template_oa_jwt/public/src/mock/utils.js +33 -0
  89. package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.jsx +13 -0
  90. package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.less +20 -0
  91. package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.jsx +21 -0
  92. package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.less +16 -0
  93. package/templates/template_oa_jwt/public/src/pages/demo/detail/index.jsx +14 -0
  94. package/templates/template_oa_jwt/public/src/pages/demo/index.jsx +399 -0
  95. package/templates/template_oa_jwt/public/src/pages/demo/index.less +15 -0
  96. package/templates/template_oa_jwt/public/src/pages/login/index.jsx +29 -0
  97. package/templates/template_oa_jwt/public/src/pages/login/index.less +44 -0
  98. package/templates/template_oa_jwt/public/src/pages/redirect/index.jsx +31 -0
  99. package/templates/template_oa_jwt/public/src/provider/app.jsx +66 -0
  100. package/templates/template_oa_jwt/public/src/route.jsx +45 -0
  101. package/templates/template_oa_jwt/public/src/services/common.js +133 -0
  102. package/templates/template_oa_jwt/public/src/services/demo.js +41 -0
  103. package/templates/template_oa_jwt/public/src/services/index.js +266 -0
  104. package/templates/template_oa_jwt/public/src/services/token.js +132 -0
  105. package/templates/template_oa_jwt/public/src/utils/index.js +115 -0
  106. package/templates/template_oa_jwt/public/static/about.html +1 -0
  107. package/templates/template_oa_jwt/public/static/kssoLogin.html +22 -0
  108. package/templates/template_oa_jwt/public/static/noAuth.html +217 -0
  109. package/templates/template_oa_jwt/public/static/noAuth.png +0 -0
  110. package/templates/template_oa_jwt/readme.md +71 -0
  111. package/templates/template_oa_jwt/report.sh +68 -0
  112. package/templates/template_oa_jwt/tools/iconfont/gulpfile.js +70 -0
  113. package/templates/template_oa_jwt/tools/iconfont/package.json +20 -0
  114. package/templates/template_oa_jwt/tools/iconfont/run.sh +39 -0
  115. package/templates/template_oa_jwt/tools/iconfont/svg/arrowBack.svg +1 -0
  116. package/templates/template_oa_jwt/tools/iconfont/svg/check.svg +1 -0
  117. package/templates/template_oa_jwt/tools/iconfont/svg/close.svg +1 -0
  118. package/templates/template_oa_jwt/tools/iconfont/svg/down.svg +1 -0
  119. package/templates/template_oa_jwt/tools/iconfont/svg/image.svg +1 -0
  120. package/templates/template_oa_jwt/tools/iconfont/svg/play.svg +1 -0
  121. package/templates/template_oa_jwt/tools/iconfont/svg/refresh.svg +1 -0
  122. package/templates/template_oa_jwt/tools/iconfont/svg/warn.svg +1 -0
  123. package/templates/template_oa_jwt/tools/iconfont/templates/_icons.css +26 -0
  124. package/templates/template_oa_jwt/tools/iconfont/templates/_icons.less +29 -0
  125. package/templates/template_oa_jwt/tools/iconfont/templates/index.html +56 -0
  126. package/templates/template_oa_jwt/tools/tinypng/package.json +11 -0
  127. package/templates/template_oa_jwt/tools/tinypng/run.sh +15 -0
  128. package/templates/template_oa_jwt/versionPublish.sh +27 -0
  129. package/templates/template_oa_jwt/webpack.api.js +61 -0
@@ -0,0 +1,27 @@
1
+ import React, { useEffect,useState,useMemo } from 'react';
2
+
3
+
4
+
5
+ const useImageLoader=(img_src)=>{
6
+ const [src,setSrc] = useState('');
7
+ useEffect(() => {
8
+ if(img_src===src)return;
9
+ if(!img_src)return;
10
+ let img = new Image();
11
+ img.onload = () => {
12
+ setSrc(img_src);
13
+ };
14
+ img.onerror = () => {
15
+ setSrc('');
16
+ console.log(`图片加载失败:${img_src}`)
17
+ };
18
+ img.src = img_src;
19
+ }, [img_src]);
20
+
21
+ const actions=useMemo(()=>{
22
+ return src;
23
+ },[src]);
24
+ return actions;
25
+ }
26
+
27
+ export default useImageLoader;
@@ -0,0 +1,42 @@
1
+ import { useRef,useState, useEffect } from 'react';
2
+ import {ShowPageLoading} from '@/components/Page/PageLoading';
3
+
4
+ const useLoading=(props={})=>{
5
+ const {canTouch=false} = props;
6
+ const [name] = useState(props?.name||'loading')
7
+ const [count,setCount] = useState(props?.loading?1:0);
8
+ const refPageLoading = useRef();
9
+
10
+ const setLoading=(state)=>{
11
+ if(state){
12
+ setCount(v=>v+1);
13
+ }else{
14
+ setCount(v=>v-1);
15
+ }
16
+ }
17
+ const reset=()=>{
18
+ setCount(v=>0);
19
+ }
20
+ useEffect(()=>{
21
+ if(count > 0 ){
22
+ if(!refPageLoading.current){
23
+ refPageLoading.current = ShowPageLoading({canTouch:canTouch});
24
+ }
25
+ }else{
26
+ if(refPageLoading.current){
27
+ refPageLoading.current();//销毁
28
+ refPageLoading.current=null;
29
+ }
30
+ }
31
+ },[count])
32
+
33
+
34
+ return {
35
+ name,
36
+ reset,
37
+ setLoading,
38
+ loading:count
39
+ }
40
+ }
41
+
42
+ export default useLoading;
@@ -0,0 +1,33 @@
1
+
2
+
3
+ import React, { useEffect, useState, useRef } from 'react';
4
+ import {IS_LOGIN,SET_TOKEN,LOGIN} from '@/services/wish';
5
+ import ShowLogin from '@/pages/components/dialog/alert/login';
6
+
7
+
8
+ const useLogin=(props)=>{
9
+ const [isLogin,setLogin] = useState(IS_LOGIN());
10
+
11
+ const login=async ()=>{
12
+ if(IS_LOGIN()){
13
+ setLogin(true);
14
+ return true;
15
+ }else{
16
+ setLogin(false);
17
+ const phone = await ShowLogin();
18
+ if(phone){
19
+ const loginReq = await LOGIN({phone});
20
+ if(loginReq?.code==0){
21
+ SET_TOKEN(loginReq.data.api_token);
22
+ setLogin(IS_LOGIN());
23
+ return true;
24
+ }
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+
30
+ return {login,isLogin}
31
+ }
32
+
33
+ export default useLogin;
@@ -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' && window.knFeishu?.IS_FEISHU()){
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)} />);