kn-cli 1.0.91 → 1.0.93

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 (143) hide show
  1. package/package.json +1 -1
  2. package/readme.md +3 -0
  3. package/src/.DS_Store +0 -0
  4. package/templates/template_admin/.gitignore +6 -0
  5. package/templates/template_admin/public/index.html +5 -2
  6. package/templates/template_admin/public/src/_antd.less +7 -1
  7. package/templates/template_admin/public/src/components/menu/index.jsx +47 -100
  8. package/templates/template_admin/public/src/components/menu/topMenu/index.jsx +119 -0
  9. package/templates/template_admin/public/src/dictionary/index.js +4 -1
  10. package/templates/template_admin/public/src/hooks/index.jsx +4 -1
  11. package/templates/template_admin/public/src/hooks/useRouteMenu.jsx +232 -0
  12. package/templates/template_admin/public/src/provider/menu.jsx +261 -10
  13. package/templates/template_admin/public/src/route.jsx +18 -9
  14. package/templates/template_app/.gitignore +6 -0
  15. package/templates/template_oa/.gitignore +6 -0
  16. package/templates/template_oa/jsconfig.json +5 -1
  17. package/templates/template_oa/public/src/components/dialog/index.jsx +237 -0
  18. package/templates/template_oa/public/src/components/{Empty → empty}/index.jsx +9 -0
  19. package/templates/{template_oa_jwt/public/src/components/FormRow → template_oa/public/src/components/formRow}/index.jsx +25 -3
  20. package/templates/{template_oa_jwt/public/src/components/FormTable → template_oa/public/src/components/formTable}/index.jsx +39 -1
  21. package/templates/template_oa/public/src/components/iconFont/index.jsx +22 -0
  22. package/templates/template_oa/public/src/components/{IFrame → iframe}/index.jsx +18 -4
  23. package/templates/template_oa/public/src/components/{Layout/Basic → layout/basic}/index.jsx +7 -1
  24. package/templates/{template_oa_jwt/public/src/components/Layout/CenterBody → template_oa/public/src/components/layout/centerBody}/index.jsx +2 -0
  25. package/templates/{template_oa_jwt/public/src/components/Layout/FormBlock → template_oa/public/src/components/layout/formBlock}/index.jsx +3 -1
  26. package/templates/template_oa/public/src/components/{Layout → layout}/index.jsx +12 -6
  27. package/templates/{template_oa_jwt/public/src/components/Layout/Provider → template_oa/public/src/components/layout/provider}/index.jsx +4 -0
  28. package/templates/template_oa/public/src/components/{Link → link}/index.jsx +16 -0
  29. package/templates/template_oa/public/src/components/{Nav → nav}/index.jsx +8 -2
  30. package/templates/{template_oa_jwt/public/src/components/Page/PageLoading → template_oa/public/src/components/page/pageLoading}/index.jsx +25 -4
  31. package/templates/template_oa/public/src/components/{Popup → popup}/index.jsx +13 -0
  32. package/templates/template_oa/public/src/components/{Select/DepSelect → select/depSelect}/index.jsx +15 -0
  33. package/templates/template_oa/public/src/components/{Select/StaffSelect → select/staffSelect}/index.jsx +27 -0
  34. package/templates/template_oa/public/src/components/title/index.jsx +3 -0
  35. package/templates/template_oa/public/src/components/{Toast → toast}/index.jsx +21 -1
  36. package/templates/template_oa/public/src/components/{Upload → upload}/index.jsx +41 -3
  37. package/templates/template_oa/public/src/hooks/index.jsx +1 -0
  38. package/templates/template_oa/public/src/hooks/useDelay.jsx +5 -0
  39. package/templates/template_oa/public/src/hooks/useImageLoader.jsx +1 -2
  40. package/templates/template_oa/public/src/hooks/useLoading.jsx +5 -1
  41. package/templates/template_oa/public/src/hooks/usePreload.jsx +2 -1
  42. package/templates/template_oa/public/src/hooks/useScrollTop.jsx +12 -0
  43. package/templates/template_oa/public/src/hooks/useSearch.jsx +28 -2
  44. package/templates/template_oa/public/src/hooks/useUpdate.jsx +5 -0
  45. package/templates/template_oa/public/src/index.jsx +15 -1
  46. package/templates/template_oa/public/src/pages/video/index.jsx +17 -13
  47. package/templates/template_oa/public/src/provider/app.jsx +33 -2
  48. package/templates/template_oa/public/src/route.jsx +4 -2
  49. package/templates/template_oa/public/src/services/common.js +11 -0
  50. package/templates/template_oa/public/src/services/index.js +44 -2
  51. package/templates/template_oa/public/src/type.js +48 -0
  52. package/templates/template_oa/public/src/utils/index.js +34 -17
  53. package/templates/template_oa_jwt/.gitignore +6 -0
  54. package/templates/template_oa_jwt/jsconfig.json +5 -1
  55. package/templates/template_oa_jwt/public/src/components/dialog/index.jsx +237 -0
  56. package/templates/template_oa_jwt/public/src/components/{Empty → empty}/index.jsx +9 -0
  57. package/templates/{template_oa/public/src/components/FormRow → template_oa_jwt/public/src/components/formRow}/index.jsx +25 -3
  58. package/templates/{template_oa/public/src/components/FormTable → template_oa_jwt/public/src/components/formTable}/index.jsx +41 -2
  59. package/templates/template_oa_jwt/public/src/components/formTable/index.less +18 -0
  60. package/templates/template_oa_jwt/public/src/components/iconFont/index.jsx +22 -0
  61. package/templates/template_oa_jwt/public/src/components/{IFrame → iframe}/index.jsx +15 -0
  62. package/templates/template_oa_jwt/public/src/components/{Layout/Basic → layout/basic}/index.jsx +11 -6
  63. package/templates/{template_oa/public/src/components/Layout/CenterBody → template_oa_jwt/public/src/components/layout/centerBody}/index.jsx +2 -0
  64. package/templates/{template_oa/public/src/components/Layout/FormBlock → template_oa_jwt/public/src/components/layout/formBlock}/index.jsx +3 -1
  65. package/templates/template_oa_jwt/public/src/components/{Layout → layout}/index.jsx +10 -4
  66. package/templates/{template_oa/public/src/components/Layout/Provider → template_oa_jwt/public/src/components/layout/provider}/index.jsx +4 -0
  67. package/templates/template_oa_jwt/public/src/components/{Link → link}/index.jsx +16 -0
  68. package/templates/template_oa_jwt/public/src/components/{Nav → nav}/index.jsx +11 -5
  69. package/templates/{template_oa/public/src/components/Page/PageLoading → template_oa_jwt/public/src/components/page/pageLoading}/index.jsx +25 -4
  70. package/templates/template_oa_jwt/public/src/components/{Popup → popup}/index.jsx +13 -0
  71. package/templates/template_oa_jwt/public/src/components/{Select/DepSelect → select/depSelect}/index.jsx +15 -0
  72. package/templates/template_oa_jwt/public/src/components/{Select/StaffSelect → select/staffSelect}/index.jsx +27 -0
  73. package/templates/template_oa_jwt/public/src/components/title/index.jsx +3 -0
  74. package/templates/template_oa_jwt/public/src/components/{Toast → toast}/index.jsx +21 -1
  75. package/templates/template_oa_jwt/public/src/components/{Upload → upload}/index.jsx +41 -3
  76. package/templates/template_oa_jwt/public/src/dictionary/index.js +2 -0
  77. package/templates/template_oa_jwt/public/src/hooks/index.jsx +2 -2
  78. package/templates/template_oa_jwt/public/src/hooks/useDelay.jsx +5 -0
  79. package/templates/template_oa_jwt/public/src/hooks/useImageLoader.jsx +1 -2
  80. package/templates/template_oa_jwt/public/src/hooks/useLoading.jsx +5 -1
  81. package/templates/template_oa_jwt/public/src/hooks/usePreload.jsx +2 -1
  82. package/templates/template_oa_jwt/public/src/hooks/useScrollTop.jsx +12 -0
  83. package/templates/template_oa_jwt/public/src/hooks/useSearch.jsx +28 -2
  84. package/templates/template_oa_jwt/public/src/hooks/useUpdate.jsx +5 -0
  85. package/templates/template_oa_jwt/public/src/pages/demo/index.jsx +17 -11
  86. package/templates/template_oa_jwt/public/src/provider/app.jsx +30 -1
  87. package/templates/template_oa_jwt/public/src/route.jsx +4 -2
  88. package/templates/template_oa_jwt/public/src/services/common.js +13 -1
  89. package/templates/template_oa_jwt/public/src/services/index.js +52 -8
  90. package/templates/template_oa_jwt/public/src/services/token.js +7 -0
  91. package/templates/template_oa_jwt/public/src/utils/index.js +62 -22
  92. package/templates/template_offcial/.gitignore +6 -0
  93. package/templates/template_admin/public/src/components/topMenu/index.jsx +0 -267
  94. package/templates/template_oa/public/src/components/Alert/index.jsx +0 -0
  95. package/templates/template_oa/public/src/components/Alert/index.less +0 -0
  96. package/templates/template_oa/public/src/components/Auth/index.jsx +0 -44
  97. package/templates/template_oa/public/src/components/Dialog/index.jsx +0 -150
  98. package/templates/template_oa/public/src/components/Footer/index.jsx +0 -17
  99. package/templates/template_oa/public/src/components/Footer/index.less +0 -28
  100. package/templates/template_oa/public/src/components/IconFont/index.jsx +0 -10
  101. package/templates/template_oa/public/src/components/Loading/index.jsx +0 -14
  102. package/templates/template_oa/public/src/components/Loading/index.less +0 -85
  103. package/templates/template_oa_jwt/public/src/components/Alert/index.jsx +0 -0
  104. package/templates/template_oa_jwt/public/src/components/Alert/index.less +0 -0
  105. package/templates/template_oa_jwt/public/src/components/Auth/index.jsx +0 -44
  106. package/templates/template_oa_jwt/public/src/components/Dialog/index.jsx +0 -150
  107. package/templates/template_oa_jwt/public/src/components/Footer/index.jsx +0 -17
  108. package/templates/template_oa_jwt/public/src/components/Footer/index.less +0 -28
  109. package/templates/template_oa_jwt/public/src/components/IconFont/index.jsx +0 -10
  110. package/templates/template_oa_jwt/public/src/components/Loading/index.jsx +0 -16
  111. package/templates/template_oa_jwt/public/src/components/Loading/index.less +0 -96
  112. /package/templates/template_admin/public/src/components/{topMenu → menu/topMenu}/index.less +0 -0
  113. /package/templates/template_oa/public/src/components/{Dialog → dialog}/index.less +0 -0
  114. /package/templates/template_oa/public/src/components/{Empty → empty}/index.less +0 -0
  115. /package/templates/template_oa/public/src/components/{FormRow → formRow}/index.less +0 -0
  116. /package/templates/{template_oa_jwt/public/src/components/FormTable → template_oa/public/src/components/formTable}/index.less +0 -0
  117. /package/templates/template_oa/public/src/components/{IconFont → iconFont}/index.less +0 -0
  118. /package/templates/template_oa/public/src/components/{IFrame → iframe}/index.less +0 -0
  119. /package/templates/template_oa/public/src/components/{Layout/Basic → layout/basic}/index.less +0 -0
  120. /package/templates/template_oa/public/src/components/{Layout/CenterBody → layout/centerBody}/index.less +0 -0
  121. /package/templates/template_oa/public/src/components/{Layout/FormBlock → layout/formBlock}/index.less +0 -0
  122. /package/templates/template_oa/public/src/components/{Layout → layout}/index.less +0 -0
  123. /package/templates/template_oa/public/src/components/{Link → link}/index.less +0 -0
  124. /package/templates/template_oa/public/src/components/{Nav → nav}/index.less +0 -0
  125. /package/templates/template_oa/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  126. /package/templates/template_oa/public/src/components/{Popup → popup}/index.less +0 -0
  127. /package/templates/template_oa/public/src/components/{Select/StaffSelect → select/staffSelect}/index.less +0 -0
  128. /package/templates/template_oa/public/src/components/{Toast → toast}/index.less +0 -0
  129. /package/templates/template_oa_jwt/public/src/components/{Dialog → dialog}/index.less +0 -0
  130. /package/templates/template_oa_jwt/public/src/components/{Empty → empty}/index.less +0 -0
  131. /package/templates/template_oa_jwt/public/src/components/{FormRow → formRow}/index.less +0 -0
  132. /package/templates/template_oa_jwt/public/src/components/{IconFont → iconFont}/index.less +0 -0
  133. /package/templates/template_oa_jwt/public/src/components/{IFrame → iframe}/index.less +0 -0
  134. /package/templates/template_oa_jwt/public/src/components/{Layout/Basic → layout/basic}/index.less +0 -0
  135. /package/templates/template_oa_jwt/public/src/components/{Layout/CenterBody → layout/centerBody}/index.less +0 -0
  136. /package/templates/template_oa_jwt/public/src/components/{Layout/FormBlock → layout/formBlock}/index.less +0 -0
  137. /package/templates/template_oa_jwt/public/src/components/{Layout → layout}/index.less +0 -0
  138. /package/templates/template_oa_jwt/public/src/components/{Link → link}/index.less +0 -0
  139. /package/templates/template_oa_jwt/public/src/components/{Nav → nav}/index.less +0 -0
  140. /package/templates/template_oa_jwt/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  141. /package/templates/template_oa_jwt/public/src/components/{Popup → popup}/index.less +0 -0
  142. /package/templates/template_oa_jwt/public/src/components/{Select/StaffSelect → select/staffSelect}/index.less +0 -0
  143. /package/templates/template_oa_jwt/public/src/components/{Toast → toast}/index.less +0 -0
@@ -1,22 +1,273 @@
1
1
  // @ts-ignore
2
- import React,{ useState,useMemo } from 'react';
2
+ import React,{ useState,useMemo, useEffect } from 'react';
3
+ // @ts-ignore
4
+ import { useLocation } from 'react-router-dom';
3
5
  // @ts-ignore
4
6
  import { createContainer } from "unstated-next"
5
7
 
6
- import {GET_MENU} from '@/services/auth';
8
+ import useRouteMenu from '@/hooks/useRouteMenu';
9
+
10
+
11
+ // @ts-ignore
12
+ import { AppstoreOutlined, MailOutlined } from '@ant-design/icons';
13
+
14
+ const MenuRoute=[
15
+ {
16
+ name:'常用管理',
17
+ url:'/',
18
+ children:[
19
+ {
20
+ name:'内容管理',
21
+ icon:<AppstoreOutlined />,
22
+ url:'/content',
23
+ children:[
24
+ {name:'剧集管理',url:'/content/video'},
25
+ {name:'素材管理',url:'/content/material'},
26
+ ]
27
+
28
+ },
29
+ {
30
+ name:'数据管理',
31
+ icon:<MailOutlined />,
32
+ url:'/data',
33
+ children:[
34
+ {primaryId:'orderData',name:'订单数据',msgCount:3,url:'/data/order'},
35
+ {name:'用户数据',url:'/data/userData'},
36
+ ]
37
+ },
38
+ {
39
+ name:'用户管理',
40
+ url:'/user',
41
+ children:[
42
+ {name:'账户管理',url:'/user/user'},
43
+ {name:'客诉管理',url:'/user/suggest'},
44
+ ]
45
+ },
46
+ ]
47
+ },
48
+ {
49
+ name:'权限管理',
50
+ url:'/auth',
51
+ children:[
52
+ {
53
+ name:'权限设置',
54
+ icon:<AppstoreOutlined />,
55
+ url:'/auth/config',
56
+ children:[
57
+ {name:'角色配置',url:'/auth/config/permission'},
58
+ ]
59
+ },
60
+ ]
61
+ }
62
+ ]
63
+
64
+ const MenuRoute2=[
65
+ {
66
+ name:'数据管理',
67
+ icon:'AppstoreOutlined',
68
+ url:'/order',
69
+ auth:['super'],
70
+ children:[
71
+ {
72
+ name:'数据管理',
73
+ // icon:'AppstoreOutlined',
74
+ url:'/order',
75
+ // children:[
76
+ // {name:'剧集管理',url:'/video'},
77
+ // {name:'素材管理',url:'/material'},
78
+ // ]
79
+
80
+ },
81
+ ]
82
+ },
83
+ {
84
+ name:'手机管理',
85
+ url:'/device',
86
+ icon:'AppstoreOutlined',
87
+ children:[]
88
+ },
89
+ {
90
+ name:'服务设置',
91
+ url:'/service',
92
+ icon:'AppstoreOutlined',
93
+ children:[
94
+ {
95
+ name:'账号管理',
96
+ url:'/service/account'
97
+ },
98
+ // {
99
+ // name:'账号健康设置',
100
+ // url:'/service/accountHealth'
101
+ // },
102
+ // {
103
+ // name:'排班管理',
104
+ // url:'/service/workforce'
105
+ // },
106
+ // {
107
+ // name:'表单设置',
108
+ // url:'/service/workforce'
109
+ // },
110
+
111
+ ]
112
+
113
+ },
114
+ {
115
+ name:'内容管理',
116
+ url:'/video',
117
+ icon:'AppstoreOutlined',
118
+ children:[
119
+ {
120
+ name:'内容管理',
121
+ url:'/video',
122
+ // children:[
123
+ // {name:'剧集管理',url:'/video'},
124
+ // {name:'素材管理',url:'/material'},
125
+ // ]
126
+
127
+ },
128
+ // {
129
+ // name:'数据管理',
130
+ // icon:'AppstoreOutlined',
131
+ // children:[
132
+ // {name:'订单数据',url:'/order'},
133
+ // {name:'用户数据',url:'/userData'},
134
+ // ]
135
+ // },
136
+ // {
137
+ // name:'用户管理',
138
+ // icon:'UserOutlined',
139
+ // url:'/user'
140
+ // },
141
+ // {
142
+ // name:'客诉管理',
143
+ // icon:'CustomerServiceOutlined',
144
+ // url:'/suggest'
145
+ // },
146
+ // {
147
+ // name:'权限配置',
148
+ // icon:'CrownOutlined',
149
+ // url:'/permission'
150
+ // },
151
+ ]
152
+ },
153
+ {
154
+ name: '权限设置',
155
+ url: '/authUser',
156
+ icon: 'AppstoreOutlined',
157
+ children: [
158
+ {
159
+ name: '用户管理',
160
+ url: '/authUser',
161
+ },
162
+ {
163
+ name: '角色管理',
164
+ url: '/authRole',
165
+ },
166
+ {
167
+ name: '用户组',
168
+ url: '/authUserGroup',
169
+ },
170
+ ]
171
+ },
172
+ {
173
+ name:'消息中心',
174
+ url:'/message',
175
+ icon:'AppstoreOutlined',
176
+ children:[
177
+ {
178
+ primaryId:'myMessage',
179
+ name:'我的消息',
180
+ // msgCount:MSG_COUNT++,
181
+ url:'/message/my',
182
+ },
183
+ {
184
+ name:'消息设置',
185
+ url:'/message/config',
186
+ children:[
187
+ {
188
+ name:'消息查询-2',
189
+ url:'/message/config/2',
190
+ },
191
+ {
192
+ name:'消息查询-3',
193
+ url:'/message/config/3',
194
+ },
195
+ ]
196
+ },
197
+ {
198
+ name:'消息查询',
199
+ url:'/message/query',
200
+ children:[
201
+ {
202
+ name:'消息查询-设置',
203
+ hideMenu:true,
204
+ routeTemplate:'/message/query/:type',
205
+ },
206
+ ]
207
+ },
208
+
209
+ ]
210
+
211
+ },
212
+ ]
213
+
7
214
 
8
215
  const useProvider=() =>{
9
- const [menus,setMenus]= useState([]);
10
216
 
11
- const reload= async ()=>{
12
- await GET_MENU();
217
+ const routeMenu = useRouteMenu();
218
+
219
+ const curLocation =useLocation();
220
+
221
+ const [topMenu,setTopMenu]=useState([]);
222
+ const [leftMenu,setLeftMenu]=useState([]);
223
+
224
+ const [selectMenus,setSelectMenus] = useState({menus:[],keys:[]});
225
+
226
+
227
+ const reload = async ()=>{
228
+ routeMenu.setSourceMap([...MenuRoute]);
229
+ }
230
+ const getTopMenu=(userAuth=[])=>{
231
+ const list = routeMenu.getMenu(routeMenu.source,userAuth);
232
+ setTopMenu(list||[]);
13
233
  }
14
- const action=useMemo(()=>{
15
- return {
16
- menus,setMenus
234
+ const getLeftMenu=(userAuth=[])=>{
235
+ const list = routeMenu.getMenu(routeMenu.source,userAuth);
236
+ let menus= routeMenu.getOpenMenus(curLocation.pathname);
237
+
238
+ const req= list.filter(menu=>{
239
+ return menus.some(openMenu=>openMenu.key==menu.key)
240
+ })
241
+
242
+ let subs=[];
243
+ if(req && req[0]){
244
+ subs=req[0].children||[];
17
245
  }
18
- },[menus,setMenus]);
19
- return action
246
+ setLeftMenu(subs);
247
+ }
248
+
249
+ const findMenuData=(menuKey)=>{
250
+ return routeMenu.findMenuData(menuKey);
251
+
252
+ }
253
+ const setMenuConfig=(params)=>{
254
+ routeMenu.setMenuConfig(params);
255
+ }
256
+
257
+ useEffect(()=>{
258
+ let menus= routeMenu.getOpenMenus(curLocation.pathname);
259
+ let keys=menus.map(item=>item.key);
260
+ setSelectMenus({menus,keys});
261
+ },[curLocation,routeMenu.source]);
262
+
263
+ useEffect(()=>{
264
+ getTopMenu();
265
+ getLeftMenu();
266
+ },[routeMenu.source,curLocation])
267
+
268
+
269
+
270
+ return {leftMenu,topMenu,reload,selectMenus,findMenuData,setMenuConfig}
20
271
  }
21
272
  const App = createContainer(useProvider);
22
273
 
@@ -10,7 +10,7 @@ import PageLoading from '@/components/page/pageLoading';
10
10
  import Login from '@/pages/login';
11
11
  import {AuthLogin} from '@/components/auth';
12
12
  import LeftMenu from '@/components/menu';
13
- import TopMenu from '@/components/topMenu';
13
+ import TopMenu from '@/components/menu/topMenu';
14
14
 
15
15
  import ProviderMenu from '@/provider/menu';
16
16
 
@@ -54,14 +54,23 @@ export const RouteList = (
54
54
  </ProviderMenu.Provider>
55
55
  }
56
56
  >
57
- <Route path='/' element={<Navigate to="/video"></Navigate> } />
58
- <Route path='/video' element={<Video />} />
59
- <Route path='/suggest' element={<Suggest />} />
60
- <Route path='/order' element={<Order />} />
61
- <Route path='/permission' element={<Permission />} />
62
- <Route path='/material' element={<Material />} />
63
- <Route path='/user' element={<User />} />
64
- <Route path='/userData' element={<UserData />} />
57
+ <Route path='/' element={<Navigate to="/content/video"></Navigate> } />
58
+ <Route path='/content/video' element={<Video />} />
59
+ <Route path='/content/material' element={<Material />} />
60
+
61
+
62
+ <Route path='/data' element={<Navigate to="/data/order"></Navigate> } />
63
+ <Route path='/data/order' element={<Order />} />
64
+ <Route path='/data/userData' element={<UserData />} />
65
+
66
+ <Route path='/user' element={<Navigate to="/user/user"></Navigate> } />
67
+ <Route path='/user/user' element={<User />} />
68
+ <Route path='/user/suggest' element={<Suggest />} />
69
+
70
+ <Route path='/auth' element={<Navigate to="/auth/config/permission"></Navigate> } />
71
+ <Route path='/auth/config/permission' element={<Permission />} />
72
+
73
+
65
74
 
66
75
  </Route>
67
76
  </Route>
@@ -0,0 +1,6 @@
1
+ **/node_modules
2
+ **/package-lock.json
3
+ **/.DS_Store
4
+ **/dist
5
+ **/release
6
+
@@ -0,0 +1,6 @@
1
+ **/node_modules
2
+ **/package-lock.json
3
+ **/.DS_Store
4
+ **/dist
5
+ **/release
6
+
@@ -3,8 +3,12 @@
3
3
  "baseUrl": ".",
4
4
  "emitDecoratorMetadata": true,
5
5
  "experimentalDecorators": true,
6
+ "lib": ["dom", "ES2021"],
7
+ "allowJs":true,
8
+ "checkJs": true,
9
+ "jsx": "react",
6
10
  "paths": {
7
11
  "@/*": ["./public/src/*"]
8
- }
12
+ },
9
13
  }
10
14
  }
@@ -0,0 +1,237 @@
1
+ // @ts-ignore
2
+ import React from 'react';
3
+ // @ts-ignore
4
+ import ReactDOM from 'react-dom';
5
+ // @ts-ignore
6
+ import { Button } from 'antd';
7
+
8
+ import IconFont from '@/components/iconFont';
9
+
10
+ import Popup from '@/components/popup';
11
+ // @ts-ignore
12
+ import styles from './index.less';
13
+
14
+
15
+ /**
16
+ * 对话框组件
17
+ * @param {object} props
18
+ * @param {string} props.title - 对话框的标题内容
19
+ * @param {string} [props.okText='确认'] - 确认按钮文案
20
+ * @param {string} [props.cancelText='取消'] - 取消按钮文案
21
+ * @param {boolean} [props.noCancel=false] - 不显示取消按钮
22
+ * @param {()=>Promise<boolean>} [props.onOk] - 点击确认按钮回调
23
+ * @param {()=>Promise<boolean>} [props.onClose] - 点击关闭的回调
24
+ * @param {()=>void} [props.destory] - 对话框销毁的回调
25
+ * @param {JSX.Element|any} [props.children] - 子组件
26
+ *
27
+ * @returns {JSX.Element}
28
+ */
29
+ const Dialog = (props) => {
30
+ const {
31
+ title='',
32
+ okText='确认',
33
+ cancelText='取消',
34
+ noCancel=false,
35
+ onOk:fnOnOk,
36
+ onClose:fnOnClose,
37
+ destory,
38
+ children
39
+ }= props;
40
+ async function onClose() {
41
+ if (fnOnClose) {
42
+ let ret = await fnOnClose();
43
+ if (ret) {
44
+ destory();
45
+ }
46
+ } else {
47
+ destory();
48
+ }
49
+ }
50
+ async function onOk() {
51
+ if (fnOnOk) {
52
+ let ret = await fnOnOk();
53
+ if (ret) {
54
+ destory();
55
+ }
56
+ } else {
57
+ destory();
58
+ }
59
+ }
60
+ return (
61
+ <section className={styles.body}>
62
+ <div className={styles.mask} />
63
+ <section className={styles.wrap}>
64
+ <div className={styles.header}>
65
+ <span>{title}</span>
66
+ <IconFont icon='close' className={styles.close} onClick={onClose} />
67
+ </div>
68
+
69
+ {children}
70
+
71
+ <div className={styles.footer}>
72
+ <Button type='primary' onClick={onOk}>
73
+ {okText}
74
+ </Button>
75
+ {noCancel ? (
76
+ ''
77
+ ) : (
78
+ <Button onClick={onClose} style={{ marginLeft: '10px' }}>
79
+ {cancelText}
80
+ </Button>
81
+ )}
82
+ </div>
83
+ </section>
84
+ </section>
85
+ );
86
+ };
87
+
88
+ /**
89
+ * 显示一个对话框
90
+ * @param {Object} props
91
+ * @param {string} props.title - 对话框标题
92
+ * @param {string} [props.okText='确认'] - 确认按钮文案
93
+ * @param {string} [props.cancelText='取消'] - 取消按钮文案
94
+ * @param {boolean} [props.noCancel=false] - 不显示取消按钮
95
+ * @param {()=>Promise<boolean>} [props.onOk] - 点击确认按钮回调
96
+ * @param {()=>Promise<boolean>} [props.onClose] - 点击关闭的回调
97
+ * @param {JSX.Element|any} [props.component] - 对话框内的实际内容
98
+ *
99
+ * @returns {Promise<boolean>}
100
+ */
101
+ export const ShowDialog = (props={title:''}) => {
102
+ const {title,onOk,okText,cancelText,noCancel,onClose,component}= props;
103
+ return new Promise((reslove) => {
104
+ let popup = Popup(reslove);
105
+ ReactDOM.render(
106
+ <Dialog
107
+ title={title}
108
+ destory={popup.destory}
109
+ onOk={onOk}
110
+ okText={okText}
111
+ cancelText={cancelText}
112
+ noCancel={noCancel}
113
+ onClose={onClose}
114
+ >
115
+ {component}
116
+ </Dialog>,
117
+ popup.dom
118
+ );
119
+ });
120
+ };
121
+
122
+ /**
123
+ * 一个带确认和取消的确认对话框
124
+ * @param {Object} props
125
+ * @param {string} props.title - 对话框标题
126
+ * @param {string} [props.okText='确认'] - 确认按钮文案
127
+ * @param {string} [props.cancelText='取消'] - 取消按钮文案
128
+ * @param {boolean} [props.noCancel=false] - 不显示取消按钮
129
+ * @param {JSX.Element|any} [props.content] - 对话框内的实际内容
130
+ * @returns {Promise<boolean>}
131
+ */
132
+ export const ShowConfirm = async (props) => {
133
+ if (typeof props === 'string') {
134
+ // @ts-ignore
135
+ props = { content: props };
136
+ }
137
+ const {title='注意',okText='确认',cancelText='取消',noCancel=false,content}= props;
138
+
139
+ let result = false;
140
+ await ShowDialog({
141
+ title: title || '注意',
142
+ okText: okText || '确认',
143
+ cancelText: cancelText || '取消',
144
+ noCancel: noCancel,
145
+ onClose: async () => {
146
+ result = false;
147
+ return Promise.resolve(true);
148
+ },
149
+ onOk: async () => {
150
+ result = true;
151
+ return Promise.resolve(true);
152
+ },
153
+ component: (
154
+ <div className={styles.confirmWrap}>
155
+ {content}
156
+ </div>
157
+ ),
158
+ });
159
+ return result;
160
+ };
161
+
162
+ /**
163
+ * 一个只有确认按钮的提示框
164
+ * @param {Object} props
165
+ * @param {string} [props.okText='确认'] - 确认按钮文案
166
+ * @param {JSX.Element|any} [props.content] - 对话框内的实际内容
167
+ * @param {()=>void} [props.onOk] - 点击确认的回调
168
+ * @param {()=>void} props.destory - 关闭对话框的回调
169
+ * @param {string} [props.type='error'] - 警告类型,'error'|'suuccess'
170
+ *
171
+ * @returns {JSX.Element}
172
+ */
173
+ const Alert = (props) => {
174
+ const {onOk:fnOnOk,destory,type,content,okText='确认'}= props;
175
+ function onOk() {
176
+ if (fnOnOk) fnOnOk();
177
+ destory();
178
+ }
179
+ return (
180
+ <section className={styles.body }>
181
+ <div className={styles.mask} />
182
+ <section className={styles.wrapAlert}>
183
+ <div className={styles.alertContent}>
184
+ <div className={type === 'success' ? styles.iconSuccess : styles.iconError} />
185
+ <span>{content}</span>
186
+ </div>
187
+ <div className={styles.alertFooter}>
188
+ <span onClick={onOk}>{okText}</span>
189
+ </div>
190
+ </section>
191
+ </section>
192
+ );
193
+ };
194
+
195
+ /**
196
+ * 显示一个alert
197
+ * @param {Object} props
198
+ * @param {JSX.Element|any} [props.content] - 对话框内的实际内容
199
+ * @param {()=>void} [props.onOk] - 点击确认的回调
200
+ * @param {string} [props.type='success'] - 警告类型,'error'|'suuccess'
201
+ *
202
+ * @returns {Promise<void>}
203
+ */
204
+ export const ShowAlert = (props) => {
205
+ if (props.constructor === String) {
206
+ // @ts-ignore
207
+ props = { content: props };
208
+ }
209
+
210
+ const {type='success',onOk,content}=props;
211
+
212
+ return new Promise((reslove) => {
213
+ let popup = Popup(reslove);
214
+
215
+ ReactDOM.render(
216
+ <Alert destory={popup.destory} type={type} onOk={onOk} content={content} />,
217
+ popup.dom
218
+ );
219
+ });
220
+ };
221
+
222
+ /**
223
+ * 显示一个错误提示alert
224
+ * @param {Object} props
225
+ * @param {JSX.Element|any} [props.content] - 对话框内的实际内容
226
+ * @param {()=>void} [props.onOk] - 点击确认的回调
227
+ *
228
+ * @returns {Promise<void>}
229
+ */
230
+ export const ShowErrorAlert = (props) => {
231
+ if (props.constructor === String) {
232
+ props = { content: props };
233
+ }
234
+ return ShowAlert({ ...props, type: 'fail' });
235
+ };
236
+
237
+ export default Dialog;
@@ -1,9 +1,18 @@
1
+ // @ts-ignore
1
2
  import React from 'react';
3
+ // @ts-ignore
2
4
  import { Empty, Button } from 'antd';
5
+
6
+ // @ts-ignore
3
7
  import styles from './index.less';
4
8
 
5
9
  /**
6
10
  * 当table数据为空时下方有“添加数据”按钮
11
+ * @param {object} props
12
+ * @param {()=>void} [props.onClick] - 点击添加数据的回调
13
+ * @param {boolean} [props.editmode] - 是否允许编辑模式,允许的话就会有添加数据的按钮
14
+ *
15
+ * @returns {JSX.Element}
7
16
  */
8
17
  function TableEmpty(props) {
9
18
  return (
@@ -1,6 +1,16 @@
1
- import React, { useState } from 'react';
1
+ // @ts-ignore
2
+ import React from 'react';
3
+
4
+ // @ts-ignore
2
5
  import styles from './index.less';
3
6
 
7
+ /**
8
+ * 表单的行组件,用于将子组件按照一行2列方式排列
9
+ * @param {Object} props
10
+ * @param {JSX.Element[]|JSX.Element} props.children
11
+ *
12
+ * @returns {JSX.Element}
13
+ */
4
14
  const FormRow = (props) => {
5
15
  function createCol(item, idx) {
6
16
  if (!item) return '';
@@ -9,6 +19,7 @@ const FormRow = (props) => {
9
19
  <div key={idx} className={styles.formRow}>
10
20
  <hgroup className={styles.row}>
11
21
  <div className={styles.title}>
22
+ {/* @ts-ignore */}
12
23
  <div required={editmode && item.props.required}>{item.props.label}</div>
13
24
  </div>
14
25
  <div className={styles.data}>{item}</div>
@@ -18,20 +29,31 @@ const FormRow = (props) => {
18
29
  }
19
30
  return (
20
31
  <section className={styles.formRowBody}>
32
+ {/* @ts-ignore */}
21
33
  {props.children.length > 0 ? props.children.map(createCol) : createCol(props.children)}
22
34
  </section>
23
35
  );
24
36
  };
25
37
 
38
+ /**
39
+ * 表单的行组件中的列组件
40
+ * @param {Object} props
41
+ * @param {JSX.Element[]|JSX.Element} props.children
42
+ * @param {boolean} [props.editmode=true] - 可编辑模式
43
+ * @param {string} [props.txtdata='-'] - 列的标题
44
+ * @param {boolean} [props.textarea=false] - 是否多行显示文本
45
+ *
46
+ * @returns {JSX.Element|JSX.Element[]|any}
47
+ */
26
48
  function HocEditControl(props) {
27
49
  const { editmode = true, txtdata ,textarea} = props;
28
50
  if (editmode) {
29
51
  return props.children;
30
52
  }
31
53
  if(textarea){
32
- return <span style={{whiteSpace:'pre-wrap'}}>{txtdata||'-'}</span>
54
+ return <span style={{whiteSpace:'pre-wrap'}}>{txtdata}</span>
33
55
  }
34
- return <span>{txtdata || '-'}</span>;
56
+ return <span>{txtdata}</span>;
35
57
  }
36
58
 
37
59
  FormRow.Col = HocEditControl;