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,9 +1,15 @@
1
+ // @ts-ignore
1
2
  import Axios from 'axios';
3
+ // @ts-ignore
2
4
  import qs from 'qs';
5
+ // @ts-ignore
3
6
  import { message } from 'antd';
7
+
4
8
  import { toHref, exportExcel } from '@/utils';
5
9
  import { CHANGE_TOKEN, setRefreshToken ,toLogin} from './token';
6
10
  const axios = Axios.create();
11
+
12
+ // @ts-ignore
7
13
  console.log(`========API_HOST:${API_HOST}========`);
8
14
 
9
15
  const tokenMode='header';//header,cookie
@@ -95,10 +101,23 @@ axios.interceptors.response.use(
95
101
  }
96
102
  );
97
103
 
98
-
104
+ /**
105
+ * @typedef RequestOptions 发送请求的扩展信息
106
+ * @property {number|boolean} ttl=false - 接口缓存周期,开启后默认为2秒,ttl单位为毫秒
107
+ * @property {string|boolean} noInterceptors=false - 关闭拦截类型,'all'为关闭包括401、403在内的所有异常,默认情况下只拦截response.code不为0的情况
108
+ *
109
+ */
99
110
 
100
111
 
101
112
  let buffer = {};
113
+ /**
114
+ * @function
115
+ * @description 发送一个GET请求
116
+ * @param {string} url - 请求地址
117
+ * @param {Object} [param] - 请求的参数
118
+ * @param {RequestOptions} [options] - 扩展参数
119
+ * @returns {Promise<Object>}
120
+ */
102
121
  export async function GET_DEFAULT(url, param, options) {
103
122
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
104
123
  let now = Date.now();
@@ -131,6 +150,13 @@ export async function GET_DEFAULT(url, param, options) {
131
150
  return response && response.data ? response.data : null;
132
151
  }
133
152
 
153
+ /**
154
+ * @function
155
+ * @description 发送一个GET请求
156
+ * @param {string} url - 请求地址
157
+ * @param {Object} [param] - 请求的参数
158
+ * @returns {Promise<Object>}
159
+ */
134
160
  export async function GET_DEFAULT_CROSS(url, param) {
135
161
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
136
162
 
@@ -143,6 +169,14 @@ export async function GET_DEFAULT_CROSS(url, param) {
143
169
  });
144
170
  return response && response.data ? response.data : null;
145
171
  }
172
+
173
+ /**
174
+ * 导出EXCEL
175
+ * @param {string} url - 接口地址
176
+ * @param {any} param - 接口参数
177
+ * @param {any} user - 用户信息
178
+ * @returns {Promise}
179
+ */
146
180
  export async function EXPORT_DEFAULT_CROSS(url, param, user) {
147
181
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
148
182
 
@@ -158,7 +192,14 @@ export async function EXPORT_DEFAULT_CROSS(url, param, user) {
158
192
  exportExcel(response, user);
159
193
  }
160
194
 
161
- export async function POST_DEFAULT(url, params, method, options) {
195
+ /**
196
+ * 发送一个POST请求
197
+ * @param {string} url - 请求地址
198
+ * @param {Object} [params] - 请求的参数
199
+ * @param {RequestOptions} [options] - 扩展参数
200
+ * @returns {Promise<Object>}
201
+ */
202
+ export async function POST_DEFAULT(url, params, options) {
162
203
  let data = params;
163
204
  // if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
164
205
  // if (typeof params === 'string') {
@@ -168,7 +209,7 @@ export async function POST_DEFAULT(url, params, method, options) {
168
209
  // }
169
210
  // let token= await GET_TOKEN();
170
211
  let response = await axios({
171
- method: method || 'POST',
212
+ method: 'POST',
172
213
  url: url,
173
214
  data:{
174
215
  // _token:token,
@@ -180,6 +221,12 @@ export async function POST_DEFAULT(url, params, method, options) {
180
221
  return response && response.data ? response.data : null;
181
222
  }
182
223
 
224
+ /**
225
+ * 发送一个POST请求
226
+ * @param {string} url - 请求地址
227
+ * @param {Object} [params] - 请求的参数
228
+ * @returns {Promise<Object>}
229
+ */
183
230
  export async function POST_DEFAULT_CROSS(url, params) {
184
231
  // let token= await GET_TOKEN();
185
232
 
@@ -246,13 +293,10 @@ export function FORMAT_RESPONSE_NO_PAGINATION(response){
246
293
  return req;
247
294
  }
248
295
 
249
- /**
250
- *
251
- * @param {} error 业务接口401时,用 refreshToken 重新获取token,再重试当前接口
252
- * @returns
253
- */
296
+
254
297
  const refreshAndRetry = async (error) => {
255
298
  if (!localStorage.getItem('refreshToken')) {
299
+ // @ts-ignore
256
300
  if(toLogin)toLogin(error.response.data.data.auth_url);
257
301
  return;
258
302
  }
@@ -1,5 +1,8 @@
1
+ // @ts-ignore
1
2
  import Axios from 'axios';
3
+ // @ts-ignore
2
4
  import { message } from 'antd';
5
+
3
6
  import { toHref } from '@/utils';
4
7
  const axios = Axios.create();
5
8
 
@@ -30,6 +33,7 @@ export const setRefreshToken = (value) => {
30
33
 
31
34
  export let logout = ()=>{}
32
35
  export const setLogout=(fn)=>{
36
+ // @ts-ignore
33
37
  window.logout=fn;
34
38
  logout=fn;
35
39
  }
@@ -71,11 +75,13 @@ axios.interceptors.response.use(
71
75
  }
72
76
  console.log('token error:', JSON.stringify(error));
73
77
  const url = error.response.data.data.auth_url;
78
+ // @ts-ignore
74
79
  if(toLogin)toLogin(url);
75
80
  return;
76
81
  // jwt失效
77
82
  if (error.response.status === 401) {
78
83
  const url = error.response.data.data.auth_url;
84
+ // @ts-ignore
79
85
  if(toLogin)toLogin(url);
80
86
  return;
81
87
  } else if (error.response.status === 403) {
@@ -127,6 +133,7 @@ async function POST_DEFAULT_CROSS(url, params) {
127
133
  */
128
134
  export async function CHANGE_TOKEN(params){
129
135
  let values = params ? params : {refresh_token: refreshToken};
136
+ // @ts-ignore
130
137
  const res = await POST_DEFAULT_CROSS(`${KSSO_HOST}/oauth/ksso/exchange`, values);
131
138
  return res;
132
139
  }
@@ -1,10 +1,19 @@
1
+ // @ts-ignore
1
2
  import moment from 'moment';
2
3
 
4
+
5
+ /**
6
+ * 打开一个第三方链接
7
+ * @param {string} link - 链接地址
8
+ * @param {string} [target='_blank'] - 打开方式,_blank:新窗口打开
9
+ */
3
10
  export const openLink = (link, target = '_blank') => {
4
11
  let domLink = document.createElement('a');
5
12
  domLink.href = link;
6
13
  domLink.setAttribute('target', target);
14
+ // @ts-ignore
7
15
  domLink.style.opacity = 0;
16
+ // @ts-ignore
8
17
  domLink.style.zIndex = -999;
9
18
  document.body.appendChild(domLink);
10
19
  domLink.click();
@@ -13,50 +22,60 @@ export const openLink = (link, target = '_blank') => {
13
22
  }, 200);
14
23
  }
15
24
 
25
+ /**
26
+ * 判断当前是否为移动端
27
+ * @returns {boolean}
28
+ */
16
29
  export const isMobile = () => {
17
30
  return navigator.userAgent.match(
18
31
  /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
19
- )
32
+ )?true:false
20
33
  }
21
34
 
22
- export const toHref = (url, replace, newWindow) => {
23
- if (window.knFeishu) {
24
- window.knFeishu.ToHref(url, replace, newWindow);
25
- return;
26
- }
27
- if (newWindow) {
28
- window.open(url);
29
- return;
30
- }
31
- if (replace) {
32
- location.replace(url);
33
- return;
34
- }
35
- location.href = url;
36
- };
37
35
 
38
- export const jumpUrl = (url, options = {}) => {
39
- const { replace, newWindow, reload } = options;
40
- if (reload) {
36
+ /**
37
+ * 跳转URL-兼容飞书
38
+ * @param {string} url - 链接地址
39
+ * @param {object} [options] - 参数
40
+ * @param {boolean} [options.replace] - 是否要覆盖当前URL记录
41
+ * @param {boolean} [options.newWindow] - 是否新窗口中打开
42
+ * @param {boolean} [options.reload] - 是否重载当前页面
43
+ *
44
+ *
45
+ */
46
+ export const jumpUrl=(url,options={})=>{
47
+ const {replace=false,newWindow=false,reload=false}= options;
48
+ if(!reload){
49
+ // @ts-ignore
50
+ if(window.knFeishu){
51
+ // @ts-ignore
52
+ window.knFeishu.ToHref(url,replace,newWindow);
53
+ return;
54
+ }
55
+ }
56
+
57
+ if(reload){
41
58
  location.reload();
42
59
  return;
43
60
  }
44
- if (replace) {
61
+ if(replace){
45
62
  location.replace(url);
46
63
  return;
47
64
  }
48
- if (newWindow) {
65
+ if(newWindow){
49
66
  window.open(url);
50
67
  return;
51
68
  }
52
- location.href = url;
69
+ location.href=url;
53
70
 
54
71
  }
55
72
 
56
73
 
57
74
  // 关闭页面
58
75
  export const closeWindow = () => {
76
+ // @ts-ignore
59
77
  if (window.knFeishu && window.knFeishu.closeWindow) {
78
+ // @ts-ignore
60
79
  window.knFeishu.closeWindow();
61
80
  } else {
62
81
  if (window.close) {
@@ -66,6 +85,26 @@ export const closeWindow = () => {
66
85
  };
67
86
 
68
87
 
88
+
89
+ export const toHref = (url, replace, newWindow) => {
90
+ // @ts-ignore
91
+ if (window.knFeishu) {
92
+ // @ts-ignore
93
+ window.knFeishu.ToHref(url, replace, newWindow);
94
+ return;
95
+ }
96
+ if (newWindow) {
97
+ window.open(url);
98
+ return;
99
+ }
100
+ if (replace) {
101
+ location.replace(url);
102
+ return;
103
+ }
104
+ location.href = url;
105
+ };
106
+
107
+
69
108
  export function formatMoney(s, n = 2) {
70
109
  if (typeof s === 'undefined' || s === '') {
71
110
  return '-'
@@ -99,6 +138,7 @@ export const isEditAuth = (user) => {
99
138
  }
100
139
 
101
140
  export const exportExcel = (response, user) => {
141
+ // @ts-ignore
102
142
  const blob = new Blob([response.data], { type: `${type},charset=UTF-8` });
103
143
  const disposition = response.headers.get('content-disposition');
104
144
  const fileName = `管理系统-${user.usr_username}-${moment().format('YYYY-MM-DD')}.xlsx`;
@@ -0,0 +1,6 @@
1
+ **/node_modules
2
+ **/package-lock.json
3
+ **/.DS_Store
4
+ **/dist
5
+ **/release
6
+
@@ -1,267 +0,0 @@
1
- // @ts-ignore
2
- import React, { useState,useEffect, useRef} from 'react';
3
- // @ts-ignore
4
- import { matchPath,useLocation,useNavigate } from 'react-router-dom';
5
- // @ts-ignore
6
- import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
7
- // @ts-ignore
8
- import { Menu,Dropdown } from 'antd';
9
-
10
- import ProviderApp from '@/provider/app';
11
- import ProviderMenu from '@/provider/menu';
12
- import {GET_MENU} from '@/services/auth';
13
-
14
- // @ts-ignore
15
- import imgAvatar from '@/assets/images/avatar.png';
16
- // @ts-ignore
17
- import styles from './index.less';
18
-
19
- /**
20
- * 菜单下的隐藏子路由集
21
- * 当这些隐藏子路由打开的时候,导航栏的选中菜单会显示被匹配的这个子菜单
22
- */
23
- const SUB_MENU_CONFIG=[
24
- {
25
- path:'/video',//匹配菜单路由是/video的菜单
26
- // routeTemplate:''匹配某个模板菜单的模板
27
- subRoute:[
28
- {
29
- path:'/video/detail',//将video/detail这个路由匹配给菜单/video
30
- // routeTemplate:''//也可以将某个路由模板匹配给某个菜单
31
- }
32
- ]
33
- },
34
- ]
35
-
36
- /**
37
- * 顶部导航栏
38
- * 左侧导航栏的路由也继顶部导航栏来控制
39
- * 路由数据结构:
40
- * const MenuRoute=[
41
- {
42
- label:'顶部菜单A',
43
- path:'/home/sub/1',
44
- menus:[
45
- {
46
- label:'菜单组A-1',
47
- icon:'MailOutlined',
48
- children:[
49
- {label:'菜单组A-1-home',path:'/',},
50
- {label:'菜单组A-1-sub:id',path:'/home/sub/1',routeTemplate:'/home/sub/:id'},
51
- {label:'菜单组A-1-sub3:id',path:'/home/sub3/2',routeTemplate:'/home/sub3/:id'},
52
- ]
53
- },
54
- ]
55
- }
56
- ]
57
- 顶部的导航栏结构为{label,path,menus}
58
- 左侧导航栏数据为顶部导航栏数据的menus内子项{label,icon,children}组成
59
- routeTemplate用来识别动态参数的路由,同前端本地路由配置同步即可
60
- 当顶部导航栏只有一项时,将自动隐藏顶部导航菜单
61
- * @returns {JSX.Element}
62
- */
63
- const TopMenu=()=>{
64
- const app = ProviderApp.useContainer();
65
- const providerMenu = ProviderMenu.useContainer();
66
- const curRoute = useLocation();
67
-
68
- const [menus,setMenus]=useState([]);
69
- const navigate = useNavigate();
70
- const [selectedKeys,setSelectedKeys] = useState([]);
71
-
72
-
73
- const MENU_KEY_COUNTER=useRef(1);
74
- const MENU_KEY=useRef({})
75
- const translateMenu=(data={})=>{
76
- const {label,path}= data;
77
- let myKey = `${MENU_KEY_COUNTER.current}`
78
- let item ={
79
- key:myKey,
80
- label:`${label}`,
81
- path,
82
- source:data,
83
- }
84
- MENU_KEY.current[myKey] = item;
85
- MENU_KEY_COUNTER.current++;
86
- return item;
87
- }
88
-
89
- const getSubConfig=(menu)=>{
90
- const {url,routeTemplate}= menu;
91
- for(let i=0;i<SUB_MENU_CONFIG.length;i++){
92
- let sub= SUB_MENU_CONFIG[i];
93
- if(routeTemplate&&sub.routeTemplate&&routeTemplate==sub.routeTemplate){
94
- return sub.subRoute;
95
- }
96
- if(url&&sub.path&&url==sub.path){
97
- return sub.subRoute;
98
- }
99
- }
100
- return null;
101
- }
102
- const transServicesMenuChildren=(menu)=>{
103
- let req=[];
104
- for(let i=0;i<menu.length;i++){
105
- let item= menu[i];
106
- const {url:path,name:label,icon,children:menus,routeTemplate}= item;
107
- let children;
108
- if(menus&&menus.length>0){
109
- children= transServicesMenuChildren(menus);
110
- }
111
- let subRoute= getSubConfig(item);
112
- req.push({
113
- path,label,icon,children,routeTemplate,subRoute
114
- })
115
- }
116
- return req;
117
- }
118
- const loadMenu=async ()=>{
119
- let reqMenu = await GET_MENU();
120
- if(reqMenu?.code==0){
121
- let originMenu= reqMenu.data;
122
- reqMenu=[];
123
- for(let i=0;i<originMenu.length;i++){
124
- let topMenu= originMenu[i];
125
- const {url:path,children,name:label}=topMenu;
126
- const menus = transServicesMenuChildren(children);
127
- reqMenu.push({
128
- path,menus,label
129
- })
130
- }
131
- }
132
- if(!reqMenu){
133
- setMenus([]);
134
- return;
135
- }
136
- const data = reqMenu.map(topMenu=>{
137
- return translateMenu(topMenu);
138
- })
139
- setMenus(data);
140
- }
141
-
142
- const GET_ROUTE_MENU=(menu)=>{
143
- const {routeTemplate,path,subRoute} = menu;
144
- const children = menu.children||menu.menus||null;
145
- if(routeTemplate||path){
146
- let match= matchPath(routeTemplate||path,curRoute.pathname);
147
- if(!match&&subRoute){
148
- match= subRoute.some(sub=>{
149
- let subMatch= matchPath(sub.routeTemplate||sub.path,curRoute.pathname);
150
- if(subMatch){
151
- console.log(`match sub route: ${sub.routeTemplate||sub.path} -> ${curRoute.pathname}` )
152
- return true;
153
- }
154
- return false;
155
- });
156
- }
157
- if(match){
158
- console.log(`match route: ${routeTemplate||path} -> ${curRoute.pathname}` )
159
- return true;
160
- }
161
- }
162
- if(children){
163
- for(let subMenu of children){
164
- let match = GET_ROUTE_MENU(subMenu);
165
- if(match){
166
- return true;
167
- }
168
- }
169
- }
170
- return false;
171
- }
172
-
173
- const reloadOpenMenu=()=>{
174
- for(let menuKey in MENU_KEY.current){
175
- const topMenu = MENU_KEY.current[menuKey];
176
- const match= GET_ROUTE_MENU(topMenu.source);
177
- if(match){
178
- let changeLeftMenu=false;//是否重新设置左侧导航菜单数据
179
- if(selectedKeys[0] != menuKey){
180
- changeLeftMenu= true;
181
- }
182
- if(!providerMenu.menus||providerMenu.menus.length<=0){
183
- changeLeftMenu= true;
184
- }
185
- setSelectedKeys([menuKey]);
186
- if(changeLeftMenu){
187
- providerMenu.setMenus(topMenu.source.menus);
188
- }
189
- return;
190
- }
191
- }
192
- setSelectedKeys([]);
193
- providerMenu.setMenus([]);
194
- }
195
- useEffect(()=>{loadMenu()},[]);
196
-
197
- useEffect(()=>{
198
- reloadOpenMenu();
199
- },[curRoute,menus]);
200
-
201
-
202
-
203
- // 推出登录
204
- const onAvatarClick = (e)=>{
205
- if (e?.key === 'logout') {
206
- app.logout();
207
- }
208
- }
209
- const onHome=()=>{
210
- navigate('/');
211
- }
212
- const onClickMenuItem=(e)=>{
213
- const { item, key, keyPath, domEvent } = e;
214
- const menuData = MENU_KEY.current[key];
215
- const {path,source:{menus}} = menuData;
216
- providerMenu.setMenus(menus);
217
- if(path){
218
- navigate(path)
219
- }
220
- setSelectedKeys([key])
221
- }
222
-
223
- return (
224
- <section className={styles.topMenu}>
225
- <div className={styles.left}>
226
- <span className={styles.title} onClick={onHome}>后管系统</span>
227
- </div>
228
-
229
- <div className={styles.center}>
230
- {
231
- menus&&menus.length>1&&
232
- <Menu
233
- items={menus}
234
- mode="horizontal"
235
- onClick={onClickMenuItem}
236
-
237
- selectedKeys={selectedKeys}
238
- className={styles.menu}
239
- />
240
- }
241
- </div>
242
- <div className={styles.right}>
243
-
244
- <span className={styles.username}>Hi,{app?.user?.username||''}!</span>
245
- <Dropdown overlay={(
246
- <Menu onClick={onAvatarClick} className={styles.avatarMenu}>
247
- <Menu.Item key="user">
248
- <UserOutlined />
249
- 用户名
250
- </Menu.Item>
251
-
252
- <Menu.Item key="logout">
253
- <LogoutOutlined />
254
- 退出登录
255
- </Menu.Item>
256
- </Menu>
257
- )}>
258
- <img className={styles.avatar} src={imgAvatar}/>
259
- </Dropdown>
260
-
261
- </div>
262
-
263
- </section>
264
- )
265
- }
266
-
267
- export default TopMenu;
@@ -1,44 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import ProviderApp from '@/provider/app';
3
- import { useNavigate } from 'react-router-dom';
4
- import {useLoading} from '@/hooks';
5
-
6
- export const AuthShow=(props)=>{
7
- const {name} = props;
8
- const app = ProviderApp.useContainer();
9
- if(app?.user?.authorities?.includes(name)){
10
- return props.children;
11
- }
12
- return <></>
13
- }
14
-
15
- export const AuthLogin=(props)=>{
16
- const navigate = useNavigate();
17
- const [pass,setPass] = useState(false)
18
- const app = ProviderApp.useContainer();
19
- const loading = useLoading();
20
-
21
- const check=async ()=>{
22
- loading.setLoading(true);
23
- console.log(`[Auth]检查用户登录态`)
24
- const req =await app.isLogin();
25
- loading.setLoading(false);
26
- if(req){
27
- console.log(`[Auth]检查用户登录态成功`)
28
- setPass(true);
29
- }else{
30
- console.log(`[Auth]检查用户登录态失败`)
31
- setPass(false);
32
- navigate('/login');
33
- }
34
- }
35
- useEffect(check,[]);
36
-
37
- if(pass){
38
- return props.children;
39
- }
40
- return <>检查登录态中...</>
41
- }
42
-
43
-
44
- export default {AuthShow,AuthLogin};