kn-cli 1.0.133 → 1.0.135

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 (108) hide show
  1. package/build/shellUtil.sh +2 -2
  2. package/build/start.sh +3 -2
  3. package/build/vite.config.js +1 -0
  4. package/package.json +1 -1
  5. package/templates/template_admin_antd5/package.json +3 -3
  6. package/templates/template_admin_antd5/public/src/_antd.less +4 -4
  7. package/templates/template_admin_antd5/public/src/_reset.module.less +1 -1
  8. package/templates/template_admin_antd5/public/src/_variable.module.less +5 -5
  9. package/templates/template_admin_antd5/public/src/assets/images/expand-hover.png +0 -0
  10. package/templates/template_admin_antd5/public/src/assets/images/expand.png +0 -0
  11. package/templates/template_admin_antd5/public/src/assets/images/icon-add.png +0 -0
  12. package/templates/template_admin_antd5/public/src/assets/images/icon-full-size.png +0 -0
  13. package/templates/template_admin_antd5/public/src/assets/images/icon-resize.png +0 -0
  14. package/templates/template_admin_antd5/public/src/assets/images/icon-user.png +0 -0
  15. package/templates/template_admin_antd5/public/src/assets/images/login/bg.png +0 -0
  16. package/templates/template_admin_antd5/public/src/assets/images/login/logo.png +0 -0
  17. package/templates/template_admin_antd5/public/src/assets/images/nav/slogan.png +0 -0
  18. package/templates/template_admin_antd5/public/src/assets/images/unexpand-hover.png +0 -0
  19. package/templates/template_admin_antd5/public/src/assets/images/unexpand.png +0 -0
  20. package/templates/template_admin_antd5/public/src/components/antd/antProvider.jsx +16 -4
  21. package/templates/template_admin_antd5/public/src/components/antd/drawer/README.md +336 -0
  22. package/templates/template_admin_antd5/public/src/components/antd/drawer/index.jsx +264 -0
  23. package/templates/template_admin_antd5/public/src/components/antd/index.jsx +19 -7
  24. package/templates/template_admin_antd5/public/src/components/antd/index.module.less +26 -0
  25. package/templates/template_admin_antd5/public/src/components/antd/modal/README.md +324 -0
  26. package/templates/template_admin_antd5/public/src/components/antd/modal/index.jsx +185 -0
  27. package/templates/template_admin_antd5/public/src/components/antd/select/index.jsx +1 -1
  28. package/templates/template_admin_antd5/public/src/components/antd/spin/index.jsx +92 -0
  29. package/templates/template_admin_antd5/public/src/components/antd/spin/index.module.less +58 -0
  30. package/templates/template_admin_antd5/public/src/components/antd/theme.js +19 -8
  31. package/templates/template_admin_antd5/public/src/components/antd/tooltip/detail/index.jsx +19 -56
  32. package/templates/template_admin_antd5/public/src/components/debug/index.jsx +7 -2
  33. package/templates/template_admin_antd5/public/src/components/error/index.jsx +0 -5
  34. package/templates/template_admin_antd5/public/src/components/icon/expand/index.jsx +17 -0
  35. package/templates/template_admin_antd5/public/src/components/icon/expand/index.module.less +22 -0
  36. package/templates/template_admin_antd5/public/src/components/icon/fullSize/index.jsx +13 -0
  37. package/templates/template_admin_antd5/public/src/components/icon/fullSize/index.module.less +28 -0
  38. package/templates/template_admin_antd5/public/src/components/icon/index.jsx +7 -1
  39. package/templates/template_admin_antd5/public/src/components/image/preview.jsx +7 -10
  40. package/templates/template_admin_antd5/public/src/components/layout/basic/index.module.less +1 -1
  41. package/templates/template_admin_antd5/public/src/components/leftMenu/index.jsx +1 -2
  42. package/templates/template_admin_antd5/public/src/components/link/index.module.less +2 -2
  43. package/templates/template_admin_antd5/public/src/components/menuIcon/index.module.less +3 -3
  44. package/templates/template_admin_antd5/public/src/components/popup/index.jsx +91 -50
  45. package/templates/template_admin_antd5/public/src/components/popup/index.module.less +22 -15
  46. package/templates/template_admin_antd5/public/src/components/react/index.jsx +23 -9
  47. package/templates/template_admin_antd5/public/src/components/resizeBox/index.jsx +3 -3
  48. package/templates/template_admin_antd5/public/src/components/select/defaultServicesSelect/index.jsx +151 -40
  49. package/templates/template_admin_antd5/public/src/components/select/dictSelect/index.jsx +19 -3
  50. package/templates/template_admin_antd5/public/src/components/select/useSelectList.jsx +65 -65
  51. package/templates/template_admin_antd5/public/src/components/table/index.jsx +48 -327
  52. package/templates/template_admin_antd5/public/src/components/table/index.module.less +0 -110
  53. package/templates/template_admin_antd5/public/src/components/table/table/index.jsx +242 -0
  54. package/templates/template_admin_antd5/public/src/components/table/table/index.module.less +85 -0
  55. package/templates/template_admin_antd5/public/src/components/table/withPage.jsx +53 -0
  56. package/templates/template_admin_antd5/public/src/components/topMenu/index.jsx +46 -11
  57. package/templates/template_admin_antd5/public/src/components/topMenu/index.module.less +10 -7
  58. package/templates/template_admin_antd5/public/src/components/topMenu/popmenu/index.jsx +89 -0
  59. package/templates/template_admin_antd5/public/src/components/topMenu/popmenu/index.module.less +76 -0
  60. package/templates/template_admin_antd5/public/src/components/topMenu/topBar/index.module.less +4 -3
  61. package/templates/template_admin_antd5/public/src/components/video/index.jsx +1 -1
  62. package/templates/template_admin_antd5/public/src/components/video/preview.jsx +7 -10
  63. package/templates/template_admin_antd5/public/src/config.js +3 -0
  64. package/templates/template_admin_antd5/public/src/hooks/useLoading.jsx +2 -2
  65. package/templates/template_admin_antd5/public/src/index.jsx +2 -4
  66. package/templates/template_admin_antd5/public/src/mock/demo.js +3 -3
  67. package/templates/template_admin_antd5/public/src/pages/antdComponents/button/index.jsx +22 -0
  68. package/templates/template_admin_antd5/public/src/pages/antdComponents/check/index.jsx +12 -0
  69. package/templates/template_admin_antd5/public/src/pages/antdComponents/index.jsx +57 -114
  70. package/templates/template_admin_antd5/public/src/pages/antdComponents/index.module.less +5 -0
  71. package/templates/template_admin_antd5/public/src/pages/antdComponents/input/index.jsx +14 -0
  72. package/templates/template_admin_antd5/public/src/pages/antdComponents/loading/index.jsx +31 -0
  73. package/templates/template_admin_antd5/public/src/pages/antdComponents/message/index.jsx +102 -0
  74. package/templates/template_admin_antd5/public/src/pages/antdComponents/message/index.module.less +17 -0
  75. package/templates/template_admin_antd5/public/src/pages/antdComponents/radio/index.jsx +26 -0
  76. package/templates/template_admin_antd5/public/src/pages/antdComponents/select/index.jsx +13 -0
  77. package/templates/template_admin_antd5/public/src/pages/antdComponents/switch/index.jsx +12 -0
  78. package/templates/template_admin_antd5/public/src/pages/antdComponents/tableWithPage/index.jsx +70 -0
  79. package/templates/template_admin_antd5/public/src/pages/antdComponents/text/index.jsx +21 -0
  80. package/templates/template_admin_antd5/public/src/pages/auth/user/dialog/index.jsx +48 -75
  81. package/templates/template_admin_antd5/public/src/pages/auth/user/index.jsx +17 -23
  82. package/templates/template_admin_antd5/public/src/pages/lazyLoad/index.jsx +11 -0
  83. package/templates/template_admin_antd5/public/src/pages/login/index.jsx +8 -3
  84. package/templates/template_admin_antd5/public/src/pages/login/index.module.less +18 -10
  85. package/templates/template_admin_antd5/public/src/route.jsx +14 -9
  86. package/templates/template_admin_antd5/public/src/services/demo.js +38 -2
  87. package/templates/template_admin_antd5/public/src/services/interceptor/index.js +30 -3
  88. package/templates/template_admin_antd5/public/src/types/global.d.js +306 -0
  89. package/templates/template_admin_antd5/public/src/utils/format.js +1 -1
  90. package/templates/template_admin_antd5/public/src/utils/index.js +3 -3
  91. package/templates/template_admin_antd5/public/src/utils/moment.js +15 -0
  92. package/templates/template_admin_antd5/public/src/components/_table/column.jsx +0 -47
  93. package/templates/template_admin_antd5/public/src/components/_table/column.module.less +0 -12
  94. package/templates/template_admin_antd5/public/src/components/_table/index.jsx +0 -71
  95. package/templates/template_admin_antd5/public/src/components/_table/index.module.less +0 -15
  96. package/templates/template_admin_antd5/public/src/components/badge/index.jsx +0 -47
  97. package/templates/template_admin_antd5/public/src/components/badge/index.module.less +0 -44
  98. package/templates/template_admin_antd5/public/src/components/page/pageLoading/index.jsx +0 -51
  99. package/templates/template_admin_antd5/public/src/components/page/pageLoading/index.module.less +0 -29
  100. package/templates/template_admin_antd5/public/src/components/table/aliTable/index.jsx +0 -250
  101. package/templates/template_admin_antd5/public/src/components/table/aliTable/index.module.less +0 -105
  102. package/templates/template_admin_antd5/public/src/components/toast/index.jsx +0 -79
  103. package/templates/template_admin_antd5/public/src/components/toast/index.module.less +0 -43
  104. package/templates/template_admin_antd5/public/src/type.js +0 -67
  105. package/templates/template_admin_antd5/renamejstojsx.js +0 -45
  106. package/templates/template_admin_antd5/renameless.js +0 -53
  107. /package/templates/template_admin_antd5/public/src/components/{button → antd/button}/index.jsx +0 -0
  108. /package/templates/template_admin_antd5/public/src/components/resizeBox/{index.module.css → index.module.less} +0 -0
@@ -5,10 +5,9 @@ import { HashRouter, Routes, Route, Navigate, useNavigate } from 'react-router-d
5
5
  import { LayoutBasic, AbsoluteLayout } from '@/components/layout';
6
6
  import ErrorBoundary from '@/components/error';
7
7
 
8
-
9
- import PageLoading from '@/components/page/pageLoading';
10
8
  import { AuthLogin } from '@/components/auth';
11
9
  import NavCheck from '@/components/auth/navCheck';
10
+ import {Spin} from '@/components/antd';
12
11
 
13
12
 
14
13
  import LeftMenu from '@/components/leftMenu';
@@ -26,6 +25,12 @@ const Page503 = React.lazy(() => import('@/pages/error/503'));
26
25
 
27
26
  const AntdComponents = React.lazy(() => import('@/pages/antdComponents'));
28
27
 
28
+ const LazyLoad = React.lazy(() =>
29
+ new Promise((resolve) =>
30
+ setTimeout(() => resolve(import('@/pages/lazyLoad')), 5000)
31
+ )
32
+ );
33
+
29
34
 
30
35
 
31
36
  const GetIndexRoute=()=>{
@@ -38,7 +43,6 @@ const GetIndexRoute=()=>{
38
43
  for(let _menu of menu.topMenu){
39
44
  let req = menu.findHasAuthMenu(_menu,app.auths);
40
45
  if(req){
41
- debugger;
42
46
  nav(req.url);
43
47
  return;
44
48
  }
@@ -83,7 +87,7 @@ const renderMenuConfig=(menu)=>{
83
87
  export const RouteList = (
84
88
  <Routes>
85
89
  <Route path='/' element={
86
- <Suspense fallback={<PageLoading />}>
90
+ <Suspense fallback={<Spin spinning tip='页面加载中' fullscreen></Spin>}>
87
91
  <AbsoluteLayout />
88
92
  </Suspense>}
89
93
  >
@@ -105,12 +109,13 @@ export const RouteList = (
105
109
  menuConfig.map(menu=>renderMenuConfig(menu))
106
110
  }
107
111
 
108
- <Route path='/antd' element={<AntdComponents/>} />
109
- s <Route path='/403' element={<Page403/>} />
110
- <Route path='/404' element={<Page404/>} />
111
- <Route path='/503' element={<Page503/>} />
112
- <Route path='*' element={<Navigate to='/404' />} />
112
+ <Route path='/lazyLoad' element={<LazyLoad/>} />
113
113
  </Route>
114
+ <Route path='/antd' element={<AntdComponents/>} />
115
+ <Route path='/403' element={<Page403/>} />
116
+ <Route path='/404' element={<Page404/>} />
117
+ <Route path='/503' element={<Page503/>} />
118
+ <Route path='*' element={<Navigate to='/404' />} />
114
119
  </Route>
115
120
  </Routes>
116
121
  );
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- import moment from 'moment';
3
+ import moment from '@/utils/moment';
4
4
  import {GET_DEFAULT,POST_DEFAULT,API_ROOT} from './index';
5
5
 
6
6
  const MAX_TOTAL=100;
@@ -10,6 +10,13 @@ let LIST=null;
10
10
 
11
11
  const createData=(id)=>{
12
12
  const selectValue=['1','2','3','4','5','6']
13
+ let children=[];
14
+ for(let i=0;i<3;i++){
15
+ children.push({
16
+ id:`${id}-${i}`,
17
+ name:`${id}-${i}`
18
+ })
19
+ }
13
20
  return {
14
21
  id:`${id}`,
15
22
  img:'https://image.knscq.com/216376107732045824-%E5%B0%8F%E7%A8%8B%E5%BA%8F1024.png',
@@ -30,7 +37,8 @@ const createData=(id)=>{
30
37
  ],
31
38
  videoName:'https://nebula-api.oss-cn-shanghai.aliyuncs.com/20240329/fc172bf8-1f61-4464-8d48-29b98a42fb4a/1711701991414-12827489.mp4',
32
39
  disabled:id%2?true:false,
33
- state:id%2?1:2
40
+ state:id%2?1:2,
41
+ children
34
42
  }
35
43
  };
36
44
 
@@ -47,6 +55,18 @@ function updateListData(){
47
55
  }
48
56
 
49
57
 
58
+ export function GET_RECORDS_BY_PAGE(params){
59
+ const {current,pageSize}= params;
60
+ let idx=(current-1)*pageSize;
61
+ if(!LIST)updateListData();
62
+ let data=[];
63
+ for(let i=0;i<pageSize;i++){
64
+ if(idx>=MAX_TOTAL+CREATE_COUNT)break;
65
+ data.push({...LIST[idx]});
66
+ idx++;
67
+ }
68
+ return data;
69
+ }
50
70
 
51
71
  export function GET_LIST(params) {
52
72
  const {current,pageSize,...querys}= params;
@@ -83,3 +103,19 @@ export function UPDATE(params) {
83
103
  return POST_DEFAULT(`${API_ROOT}/api/demo/update`,params)
84
104
  }
85
105
 
106
+
107
+
108
+ /**
109
+ * 将接口数据转化成usePaginationWithForm能使用的数据
110
+ * 这里根据每个项目后端的数据结构要改写
111
+ */
112
+ export const FormatDemoTableService = (req)=>{
113
+ const { records, current, pages, size, total } = req.data;
114
+ let _req={
115
+ code: 0,
116
+ data: records,
117
+ page: { current, total, pageSize: size, cursor: '' }
118
+ };
119
+ return _req;
120
+ };
121
+
@@ -18,16 +18,43 @@ export const DefaultRequest=(config)=> {
18
18
  }
19
19
 
20
20
 
21
-
21
+ /**
22
+ * 将接口数据转化成usePaginationWithForm能使用的数据
23
+ * 这里根据每个项目后端的数据结构要改写
24
+ *
25
+ * @param {*} response
26
+ * @returns {ServicesResponse}
27
+ */
22
28
  export const FormatTableService = (response)=>{
23
29
  let req={
24
30
  code:response[RESPONSE_STRUCT.CODE]||0,
25
31
  data:response[RESPONSE_STRUCT.DATA]||null,
26
32
  msg:response[RESPONSE_STRUCT.MSG]||''
27
33
  };
28
- if(response[RESPONSE_STRUCT.PAGINATION]){
29
- req.page = response[RESPONSE_STRUCT.PAGINATION]
34
+ debugger;
35
+ let keyPagination = response[RESPONSE_STRUCT.PAGINATION];
36
+ if( keyPagination in response){
37
+ req.page={
38
+ current:response[keyPagination].current,
39
+ pageSize:response[keyPagination].pageSize,
40
+ total:response[keyPagination].total,
41
+ }
30
42
  }
43
+ else if( 'pages' in req.data ){
44
+ req.page = {
45
+ current:req.data.current,
46
+ pageSize:req.data.size,
47
+ total:req.data.total,
48
+ cursor:req.data.cursor||'',
49
+ }
50
+ if('hasMore' in req?.data){
51
+ req.page.more = req.data.hasMore;
52
+ }
53
+ req.data = req.data.records;
54
+ }
55
+ const { records, ...otherDataInfo } = response.data || {};
56
+ req.otherDataInfo = otherDataInfo;
57
+
31
58
  return req;
32
59
  };
33
60
 
@@ -0,0 +1,306 @@
1
+
2
+ /**
3
+ * @typedef {import('antd/lib/form/hooks/useForm').FormInstance<any>} AtndForm
4
+ */
5
+
6
+ /**
7
+ * 可自行扩展任意数量的属性
8
+ * @typedef {Object<string, any>} OtherAny
9
+ */
10
+
11
+
12
+ /**
13
+ * JSX组件
14
+ * @typedef {*} JSXComponent
15
+ */
16
+
17
+ /**
18
+ * 指向DOM节点的ref
19
+ * @typedef {object} RefDomElement
20
+ * @property {HTMLElement} current - DOM节点
21
+ */
22
+
23
+
24
+ /**
25
+ * 分页
26
+ * @typedef {object} Pagination
27
+ * @property {number} current - 当前页码,1~N
28
+ * @property {number} pageSize=10 - 分页大小
29
+ * @property {number} total - 总记录条数
30
+ * @property {number} startIdx - 当前页面第一条的数据索引起始值
31
+ *
32
+ */
33
+
34
+
35
+ /**
36
+ * 分页类型接口返回的data格式
37
+ * @template [T=object]
38
+ * @typedef {object} PaginationData
39
+ * @property {number} current - 接口处理结果,0为成功
40
+ * @property {number} pages - 接口返回的数据
41
+ * @property {number} size - 接口返回的数据
42
+ * @property {number} total - 接口返回的数据
43
+ * @property {T[]} [records] - 内容
44
+ *
45
+ */
46
+
47
+ /**
48
+ * 接口response数据
49
+ * @template [T=object]
50
+ * @typedef {object} ServicesResponse
51
+ * @property {number} code - 接口处理结果,0为成功
52
+ * @property {T} data - 接口返回的数据
53
+ * @property {string} [msg] - 消息内容
54
+ *
55
+ */
56
+
57
+ /**
58
+ * 接口response数据
59
+ * @template [T=object]
60
+ * @typedef {object} ServicesListResponse
61
+ * @property {number} code - 接口处理结果,0为成功
62
+ * @property {PaginationData<T>} data - 接口返回的数据
63
+ * @property {string} [msg] - 消息内容
64
+ *
65
+ */
66
+
67
+
68
+ /**
69
+ * 设置菜单属性
70
+ * @typedef MenuConfig
71
+ * @property {string} primaryId - 菜单的primaryId值
72
+ * @property {('msgCount'|'icon'|'name')} key - 需要设置的字段名称
73
+ * @property {any} value - 字段值
74
+ */
75
+
76
+ /**
77
+ * 菜单项
78
+ * @typedef RouteMenuItem
79
+ * @property {string} name - 菜单展示的名称
80
+ * @property {JSX.Element} [component] - 菜单对应的页面JSX组件
81
+ * @property {boolean} [noAutoMatch=false] - 关闭自动菜单匹配跳转
82
+ * @property {string|JSX.Element} [icon] - 菜单图标
83
+ * @property {string} [url] - 菜单的URL地址
84
+ * @property {string} [routeTemplate] - 菜单的路由模版,用于匹配动态路由
85
+ * @property {number} [msgCount] - 菜单的未读消息数量
86
+ * @property {boolean} [hideMenu=false] - 是否为隐藏的菜单,隐藏的菜单不会展示独立菜单,但是会匹配路由
87
+ * @property {string[]|boolean} [auth] - 允许访问该菜单的权限列表
88
+ * @property {RouteMenuItem[]} [children] - 子菜单
89
+ * @property {string} [primaryId] - 菜单的唯一ID,如果存在primaryId,则菜单的key同primaryId
90
+ * @property {string} [key] - 会自动生成的菜单唯一ID,如果菜单配置内存在了primaryId,则会取该id
91
+ * @property {string} [parentKey] - 父级菜单的key,自动生成的
92
+ * @property {RouteMenuItem} [parent] - 父级菜单的key,自动生成的
93
+ * @property {boolean} [hideLeftMenu=false] - 进入页面后隐藏左侧导航菜单
94
+ *
95
+ */
96
+
97
+
98
+ /**
99
+ * 权限属性
100
+ * @typedef AuthItem
101
+ * @property {string} id - 权限ID
102
+ * @property {string} name - 权限名称
103
+ * @property {string} description - 权限展示名称
104
+ * @property {AuthItem[]} [children] - 子权限集
105
+ * @property {string} [type] - 隶属哪个模块,module/field/product/api
106
+ * @property {string} [nodeId] - 节点唯一ID
107
+ * @property {AuthItem} [parent] - 父节点权限
108
+ * @property {boolean} [isGroup] - 是否是一个组节点
109
+ *
110
+ *
111
+ */
112
+
113
+
114
+ /**
115
+ * 权限组
116
+ * @typedef AuthGroups
117
+ * @property {AuthItem[]} module - 模块权限
118
+ * @property {AuthItem[]} field - 字段权限
119
+ * @property {AuthItem[]} product - 产品权限
120
+ */
121
+
122
+
123
+ /**
124
+ * 各类选择框组件
125
+ * @typedef SelectListProps
126
+ * @property {string} [name] - 调试名称
127
+ * @property {boolean} [debug=false] - 开启调试日志
128
+ * @property {'single'|'multiple'} [mode='single'] - 单选/多选模式
129
+ * @property {(value:string|string[],items:object|object[])=>void} [onChange] - 选择发生变化时的回调
130
+ * @property {(value:string|string[])=>void} [onBlur] - 失焦时的回调
131
+ * @property {string|string[]} [value] - 选择发生变化时的回调
132
+ * @property {object} [style={}] - 样式
133
+ * @property {string} [placeholder] - 提示
134
+ * @property {boolean} [allowClear=false] - 一键删除按钮
135
+ * @property {boolean} [showAll=false] - 是否第一个展示全部选项
136
+ * @property {string} [allValue=''] - 定义全部选项的值是哪种类型,''代表空字符串
137
+ * @property {(id:string)=>SelectItem} [onNoMatchData] - 当没有匹配到数据时的回调
138
+ * @property {{id:number|string,label:string}[]} [noMatchList] - 为匹配到数据时的备用匹配数据
139
+ * @property {string} [onNoMatchDataLabel] - 当单选时,默认选中的数据没有匹配到合法数据时展示的label
140
+ * @property {object} [params={}] - 扩展参数
141
+ * @property {boolean} [disabled=false] - 是否禁止编辑
142
+ * @property {boolean} [noCheckNotFound=false] 是否禁止做不匹配数据的检查补全
143
+ * @property {string} [className='']
144
+ * @property {number|boolean} [maxTagCount] - 多选时最多支持的标签数量
145
+ * @property {JSX.Element|string} [suffixIcon] 选择框尾部的icon
146
+ * @property {(value:string|string[],items:object|object[])=>Promise<boolean>} [canChange] - 用于在切换选项时拦截决定是否允许变更
147
+ * @property {boolean} [required=false] - 是否为必选,必选的话不允许allowClear
148
+ * @property {(list:SelectItem[])=>object} [onDefaultSelect] - 初始化后如果需要有默认选中项的计算的话,可以通过这里拦截
149
+ * @property {(list:SelectItem[])=>void} [onListUpdate] - 每当列表内的数据更新时回调
150
+ * @property {()=>SelectItem[]} [getItems] - 获取所有有效数据
151
+ * @property {string} [size='middle']
152
+ * @property {number|boolean} [dropdownMatchSelectWidth] - 下拉展开框的宽度
153
+ * @property {number} [maxCount] - 多选情况下最多可选数量
154
+ * @property {any[]} [list] - 选项列表
155
+ * @property {(list:SelectItem[])=>void} [onAfterListUpdate] - 每当列表内的数据更新时回调,它的触发时间节点在组件init后
156
+ * @property {boolean} [antd5=false] - 是否使用antd5的组件
157
+ */
158
+
159
+ /**
160
+ * @typedef SelectItem
161
+ * @property {string} label - 文本下拉框里展示的文本
162
+ * @property {string} value - 文本下拉框里选项的值
163
+ * @property {any} data - 文本下拉框里选项对应的原始数据
164
+ * @property {boolean} [isNoFind] - 是否是缺失的数据
165
+ * @property {boolean} [_delete] - 是否删除该选项
166
+ */
167
+
168
+ /**
169
+ * @typedef UseSelectList
170
+ * @property {(list:SelectItem[])=>Promise<boolean>} init - 初始化函数
171
+ * @property {string|number|string[]|number[]} value - 值发生变化时的回调
172
+ * @property {SelectItem[]} list - 选择的数据列表
173
+ * @property {(value)=>void} setValue - 设置当前值
174
+ * @property {object} props - 继承给Select组件的通用属性
175
+ * @property {(value:string|string[])=>object[]} getItemByValue - 通过ID获取到所有匹配的对象数据
176
+ * @property {()=>SelectItem[]} [getItems] - 获取所有有效数据
177
+ *
178
+ */
179
+
180
+
181
+ /**
182
+ * @typedef SelectItemOption
183
+ * @property {string} label - 显示的名称
184
+ * @property {string} value - 唯一值
185
+ * @property {object} [data] - 原始数据
186
+ *
187
+ */
188
+
189
+ /**
190
+ * @typedef DefaultServicesSelectProps
191
+ * @property {string} [name] - 调试用的名称
192
+ * @property {object} services - api接口 符合输出的结果为{id:'',name:''}结构
193
+ * @property {object} [servicesProps={}] - 接口传参
194
+ * @property {(item:object)=>SelectItemOption} [formatOptionItem] - 用户格式化接口返回的数据成标准option数据
195
+ * @property {(list:object[]|object)=>SelectItemOption[]} [formatOptionList] - 对整个response处理返回option
196
+ * @property {(input:string,option:object)=>boolean} [onFilter] - 搜索过滤方法
197
+ */
198
+
199
+
200
+
201
+ /**
202
+ * @typedef AntdUploadFile
203
+ * @property {string} name - 文件名
204
+ * @property {string} [uid] - 唯一ID
205
+ * @property {string} [url] - 文件下载地址
206
+ * @property {number} [percent] - 上传进度
207
+ * @property {string} [status] - 上传状态,error|success|done|uploading|removed
208
+ * @property {string} [thumbUrl] - 缩略图地址
209
+ * @property {string} [crossOrigin] - cors属性设置,'anonymous'|'use-credentials'|''
210
+ * @property {UploadFile} [response] - 上传结果
211
+ *
212
+ */
213
+
214
+ /**
215
+ * 管理Upload组件使用描述文件的数据结构
216
+ * @typedef UploadFile
217
+ * @property {string} name - 文件名
218
+ * @property {string} url - 文件下载地址
219
+ * @property {string} key - 文件唯一标识
220
+ * @property {{width:number,height:number,size:number}} [info] - 扩展信息
221
+ *
222
+ */
223
+
224
+ /**
225
+ * @typedef UploadHelperOptions
226
+ * @property {(options:{percent:number})=>void} onProgress - 上传进度回调
227
+ * @property {(file:UploadFile)=>void} onSuccess - 上传成功后的回调
228
+ * @property {(e:any)=>void} [onError] - 上传失败的回调
229
+ * @property {boolean} [keepSource=false]
230
+ * @property {boolean} [autoAddPrimaryKey=true] - 是否在上传的时候给文件自动增加唯一key值
231
+ * @property {(file:object,params?:object)=>string} [onGetUploadKey] - 拦截获取上传用的key值
232
+ */
233
+
234
+
235
+
236
+ /**
237
+ * 上传文件的组件
238
+ * @typedef UploadProps
239
+ * @property {string} [listType='text'] - 上传的内容类型:text|picture-card
240
+ * @property {UploadFile[]} [value=[]] - 文件
241
+ * @property {string[]} [fileTypes] - 支持的文件类型
242
+ * @property {string} [server] - 上传文件的目标服务,huawei/tencent
243
+ * @property {string} [fromType=''] - 文件来源的板块
244
+ * @property {number} [maxCount=1] - 单次最大可上传文件个数
245
+ * @property {number} [maxSize] - 单个文件最大支持大小,单位KB,默认:5G
246
+ * @property {JSX.Element|string|function} [children] - 子组件
247
+ * @property {function} [onRemove] - 子删除文件的监听方法
248
+ * @property {(files:UploadFile[], initFile:any)=>void} [onChange] - 文件发生变更时的回调
249
+ * @property {boolean|object} [showUploadList] - 参考antd-upload组件
250
+ * @property {boolean} [onlyView=false] - 是否仅预览模式,不可上传编辑
251
+ * @property {boolean} [multiple=true] - 是否是多文件
252
+ * @property {(options:any,file:any,fileList:any[])=>boolean|Promise<any>} [beforeUpload] - 上传前的拦截器用于检查文件
253
+ * @property {boolean} [noStyle=false] - 如果true,则不会显示上传后的任何文件
254
+ * @property {function} [itemRender] - 自定义已上传的元素渲染
255
+ * @property {function} [onPregress] - 上传进度
256
+ * @property {(files,fileList,isLast)=>boolean} [onBeforeUpload] - 上传前的检查函数
257
+ * @property {boolean} [canCover=false] - 是否允许覆盖上传,当文件数量到达最大时新上传的自动覆盖老的
258
+ * @property {boolean} [keepSource=false] - 是否不对文件进行encode
259
+ * @property {boolean} [autoAddPrimaryKey=true] - 是否在上传的时候给文件自动增加唯一key值
260
+ * @property {boolean} [directory=false] - 文件夹上传模式
261
+ * @property {function} [customRequest] - 自定义上传请求
262
+ * @property {(file:object)=>string} [onGetUploadKey] - 拦截获取上传用的key值
263
+ * @property {boolean} [sync=false] - 是否用队列排队上传
264
+ * @property {(files)=>void} [onBreak] - 当有文件上传失败时的中断拦截器
265
+ */
266
+
267
+ /**
268
+ * @typedef UploadViewProps
269
+ * @property {AntdUploadFile[]} [fileList] - 上传的文件
270
+ * @property {React.RefObject} [refUpload] - upload组件的ref
271
+ * @property {boolean} [onlyView=false] - 是否仅预览模式,不可上传编辑
272
+ * @property {boolean} [loading=false] - 是否在上传中
273
+ * @property {string} [btnLabel='上传文件']
274
+ */
275
+
276
+
277
+
278
+ /**
279
+ * 弹出式对话框基础属性
280
+ * @typedef DialogProps
281
+ * @property {(req:any)=>any} [destory] - 关闭时的回调
282
+ * @property {any} [rootDom] - 窗口创建的目标DOM
283
+ */
284
+
285
+
286
+ /**
287
+ * 自定义多选框
288
+ * @typedef CheckboxProps
289
+ * @property {(value:string|string[])=>void} [onChange] - 选择发生变化时的回调
290
+ * @property {string[]} [value] - 选择发生变化时的回调
291
+ * @property {object} [style={}] - 样式
292
+ * @property {object} [params={}] - 扩展参数
293
+ * @property {object} [list={}] - 扩展参数
294
+ * @property {string} [className='']
295
+ */
296
+
297
+ /**
298
+ * 自定义多选框
299
+ * @typedef CheckboxItem
300
+ * @property {string} id - 数据唯一ID
301
+ * @property {string} name - 数据唯一id对应的别名
302
+ * @property {string} label - 展示给用户看的文字
303
+ * @property {string} [type] - 展示给用户看的文字
304
+ */
305
+
306
+
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore
2
- import moment from 'moment';
2
+ import moment from '@/utils/moment';
3
3
 
4
4
  /**
5
5
  * 格式化为货币格式
@@ -1,5 +1,5 @@
1
1
  // @ts-ignore
2
- import moment from 'moment';
2
+ import dayjs from 'dayjs';
3
3
 
4
4
 
5
5
 
@@ -254,7 +254,7 @@ CONSOLE_LOG.log = (moduleName, txt, ...other)=>{
254
254
  export const WriteLog=(text)=>{
255
255
  let log = localStorage.getItem('nebulaLog');
256
256
  let logs=[];
257
- text = `[${moment().format('MM-DD HH:mm:ss')}]:${text}`;
257
+ text = `[${dayjs().format('MM-DD HH:mm:ss')}]:${text}`;
258
258
  if(log){
259
259
  logs = log.split('\n');
260
260
  }else{
@@ -660,7 +660,7 @@ export const startsWithChinese = (str) => {
660
660
 
661
661
  // 时间早于当日则设为当日
662
662
  export const returnAtLeastToDay = (timeStr) => {
663
- return moment().isBefore(moment(timeStr)) ? moment(timeStr) : moment();
663
+ return dayjs().isBefore(dayjs(timeStr)) ? dayjs(timeStr) : dayjs();
664
664
  }
665
665
 
666
666
  /**
@@ -0,0 +1,15 @@
1
+
2
+
3
+ import dayjs from 'dayjs';
4
+ import 'dayjs/locale/zh-cn';
5
+
6
+ import duration from 'dayjs/plugin/duration';
7
+ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
8
+
9
+ dayjs.locale('zh-cn');
10
+ dayjs.extend(isSameOrBefore);
11
+ dayjs.extend(duration);
12
+ //@ts-ignore
13
+ dayjs.isMoment=dayjs.isDayjs;
14
+
15
+ export default dayjs;
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
-
3
- // @ts-ignore
4
- import styles from './column.module.less';
5
- import {DebugTableItem} from '@/components/debug';
6
-
7
-
8
- /**
9
- * 用于Table组件内渲染列用
10
- * 一旦设置了width/minWidth/maxWidth后,则会自动根据宽度显示,超出的显示省略号
11
- * @param {object} props
12
- * @param {string|number} [props.width] - 列宽限制,width和minWidth、maxWidth不要同时存在,2者取1
13
- * @param {string|number} [props.minWidth] - 列宽限制范围
14
- * @param {string|number} [props.maxWidth] - 列宽限制范围
15
- * @param {boolean} [props.wrap=false] - 是否允许自动换行
16
- * @param {number} [props.maxLine=3] - 最大限制换行数
17
- * @param {object} [props.item] - 源数据对象
18
- * @param {string|JSX.Element} [props.children] - 显示的列内容
19
- *
20
- *
21
- * @returns {JSX.Element}
22
- */
23
- const Column=(props)=>{
24
- const {width,minWidth,maxWidth,wrap=false,maxLine=3,item={}} = props;
25
- const myStyle = {
26
- };
27
- if(minWidth){myStyle.minWidth=minWidth;}
28
- if(maxWidth){myStyle.maxWidth=maxWidth;}
29
- if(width){myStyle.width=width;}
30
-
31
- if(width || minWidth || maxWidth){
32
- if(wrap && maxLine){
33
- myStyle.display='-webkit-box';
34
- myStyle.webkitBoxOrient='vertical';
35
- myStyle.webkitLineClamp=''+maxLine;
36
- }
37
- }
38
- return (
39
- <DebugTableItem item={item}>
40
- <div className={styles.column} style={myStyle} data-wrap={wrap}>
41
- {props.children??'-'}
42
- </div>
43
- </DebugTableItem>
44
- )
45
- }
46
-
47
- export default Column;
@@ -1,12 +0,0 @@
1
-
2
-
3
- .column{
4
- flex-wrap: nowrap;
5
- text-overflow: ellipsis;
6
- overflow: hidden;
7
- white-space: nowrap;
8
- &[data-wrap='true']{
9
- white-space: normal;
10
- flex-wrap: wrap;
11
- }
12
- }
@@ -1,71 +0,0 @@
1
- import React,{useCallback} from 'react';
2
- // @ts-ignore
3
- import { Table } from '@/components/antd';
4
- // @ts-ignore
5
- import styles from './index.module.less';
6
- import Column from './column';
7
-
8
- export const SCROLL_CONFIG={x:'max-content',y:550}
9
-
10
- /**
11
- * 页面公共Table组件
12
- * @param {object} [props]
13
- * @param {string} [props.rowKey] - Table主键
14
- * @param {boolean} [props.loading] - 是否加载中
15
- * @param {Array} [props.columns] - 表格列
16
- * @param {Array} [props.dataSource] - 数据数组
17
- * @param {object} [props.pagination] - 分页器,参考配置项或 pagination 文档,设为 false 时不展示和进行分页
18
- * @param {object} [props.scroll] - 表格是否可滚动
19
- * @param {object} [props.page] - 表格数据,包括数据数组、分页参数、loading等
20
- *
21
- * @returns {JSX.Element}
22
- */
23
- const PageTable = (props) => {
24
- const {
25
- rowKey,
26
- loading,
27
- columns,
28
- dataSource,
29
- pagination,
30
- scroll,
31
- page,
32
- ...others
33
- } = props;
34
-
35
- const paginationFn = useCallback(() => {
36
- // pagination=false时不分页
37
- if (typeof pagination === 'boolean') {
38
- return pagination;
39
- }
40
- return {
41
- pageSizeOptions: [10, 15, 20, 50, 100],
42
- current: page?.pagination?.current,
43
- pageSize: page?.pagination?.pageSize,
44
- total: page?.pagination?.total,
45
- showTotal: (total) => `总计${total}条`,
46
- ...pagination,
47
- };
48
- }, [pagination, page]);
49
-
50
- return (
51
- <section className={styles.tableScrollWrap}>
52
- <Table
53
- rowKey={rowKey ?? 'id'}
54
- bordered
55
- size="small"
56
- loading={loading ?? page?.loading?.state}
57
- columns={columns}
58
- dataSource={
59
- dataSource ?? (page?.data?.[page?.pagination?.current - 1] || [])
60
- }
61
- pagination={paginationFn()}
62
- scroll={scroll?{...SCROLL_CONFIG,...scroll}: SCROLL_CONFIG }
63
- {...others}
64
- />
65
- </section>
66
- );
67
- };
68
-
69
-
70
- PageTable.Column = Column;
71
- export default PageTable;
@@ -1,15 +0,0 @@
1
-
2
-
3
- .tableScrollWrap{
4
- flex:1;
5
- width: 100%;
6
- overflow: auto;
7
- }
8
-
9
- .tableWrap{
10
- flex:1;
11
- display: flex;
12
- width: 100%;
13
- flex-direction: column;
14
- overflow: hidden;
15
- }