kn-cli 1.0.96 → 1.0.98

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 (135) hide show
  1. package/build/package.json +1 -0
  2. package/package.json +1 -1
  3. package/readme.md +3 -0
  4. package/templates/template_admin/cli.config.js +4 -1
  5. package/templates/template_admin/package.json +7 -1
  6. package/templates/template_admin/public/favicon.png +0 -0
  7. package/templates/template_admin/public/index.html +6 -4
  8. package/templates/template_admin/public/src/_antd.less +30 -3
  9. package/templates/template_admin/public/src/_mixin.less +41 -0
  10. package/templates/template_admin/public/src/_reset.less +28 -20
  11. package/templates/template_admin/public/src/_variable.less +11 -6
  12. package/templates/template_admin/public/src/assets/iconfont/iconfont.eot +0 -0
  13. package/templates/template_admin/public/src/assets/iconfont/iconfont.less +60 -8
  14. package/templates/template_admin/public/src/assets/iconfont/iconfont.svg +57 -18
  15. package/templates/template_admin/public/src/assets/iconfont/iconfont.ttf +0 -0
  16. package/templates/template_admin/public/src/assets/iconfont/iconfont.woff +0 -0
  17. package/templates/template_admin/public/src/assets/iconfont/iconfont.woff2 +0 -0
  18. package/templates/template_admin/public/src/assets/images/arrow.png +0 -0
  19. package/templates/template_admin/public/src/assets/images/icon-notice.png +0 -0
  20. package/templates/template_admin/public/src/assets/images/icon-user.png +0 -0
  21. package/templates/template_admin/public/src/assets/images/loadFail.png +0 -0
  22. package/templates/template_admin/public/src/assets/images/login/bg.png +0 -0
  23. package/templates/template_admin/public/src/assets/images/login/logo.png +0 -0
  24. package/templates/template_admin/public/src/assets/images/login/slogan.png +0 -0
  25. package/templates/template_admin/public/src/assets/images/nav/icon-dep-active.png +0 -0
  26. package/templates/template_admin/public/src/assets/images/nav/icon-dep.png +0 -0
  27. package/templates/template_admin/public/src/assets/images/nav/icon-log-active.png +0 -0
  28. package/templates/template_admin/public/src/assets/images/nav/icon-log.png +0 -0
  29. package/templates/template_admin/public/src/assets/images/nav/icon-loginlog-active.png +0 -0
  30. package/templates/template_admin/public/src/assets/images/nav/icon-loginlog.png +0 -0
  31. package/templates/template_admin/public/src/assets/images/nav/icon-role-active.png +0 -0
  32. package/templates/template_admin/public/src/assets/images/nav/icon-role.png +0 -0
  33. package/templates/template_admin/public/src/assets/images/nav/icon-user-active.png +0 -0
  34. package/templates/template_admin/public/src/assets/images/nav/icon-user.png +0 -0
  35. package/templates/template_admin/public/src/assets/images/nav/nav-toggle.png +0 -0
  36. package/templates/template_admin/public/src/assets/images/nav/slogan.png +0 -0
  37. package/templates/template_admin/public/src/assets/images/noData.png +0 -0
  38. package/templates/template_admin/public/src/assets/images/noSelect.png +0 -0
  39. package/templates/template_admin/public/src/components/auth/index.jsx +7 -3
  40. package/templates/template_admin/public/src/components/auth/index.less +7 -0
  41. package/templates/template_admin/public/src/components/badge/index.jsx +47 -0
  42. package/templates/template_admin/public/src/components/badge/index.less +44 -0
  43. package/templates/template_admin/public/src/components/debug/index.jsx +27 -0
  44. package/templates/template_admin/public/src/components/debug/index.less +9 -0
  45. package/templates/template_admin/public/src/components/empty/index.jsx +28 -0
  46. package/templates/template_admin/public/src/components/empty/index.less +20 -0
  47. package/templates/template_admin/public/src/components/image/index.jsx +73 -0
  48. package/templates/template_admin/public/src/components/image/index.less +117 -0
  49. package/templates/template_admin/public/src/components/image/preview.jsx +85 -0
  50. package/templates/template_admin/public/src/components/layout/basic/index.jsx +24 -11
  51. package/templates/template_admin/public/src/components/layout/basic/index.less +58 -19
  52. package/templates/template_admin/public/src/components/layout/index.jsx +20 -17
  53. package/templates/template_admin/public/src/components/layout/index.less +4 -4
  54. package/templates/template_admin/public/src/components/layout/provider/index.jsx +19 -6
  55. package/templates/template_admin/public/src/components/{menu → leftMenu}/index.jsx +20 -28
  56. package/templates/template_admin/public/src/components/leftMenu/index.less +42 -0
  57. package/templates/template_admin/public/src/components/popup/index.jsx +25 -0
  58. package/templates/template_admin/public/src/components/table/column.jsx +47 -0
  59. package/templates/template_admin/public/src/components/table/column.less +12 -0
  60. package/templates/template_admin/public/src/components/table/index.jsx +22 -13
  61. package/templates/template_admin/public/src/components/table/index.less +15 -0
  62. package/templates/template_admin/public/src/components/text/index.jsx +98 -0
  63. package/templates/template_admin/public/src/components/text/index.less +13 -0
  64. package/templates/template_admin/public/src/components/topMenu/index.jsx +97 -0
  65. package/templates/template_admin/public/src/components/topMenu/index.less +80 -0
  66. package/templates/template_admin/public/src/components/topMenu/topBar/index.jsx +76 -0
  67. package/templates/template_admin/public/src/components/topMenu/topBar/index.less +88 -0
  68. package/templates/template_admin/public/src/components/video/index.jsx +96 -0
  69. package/templates/template_admin/public/src/components/video/index.less +132 -0
  70. package/templates/template_admin/public/src/components/video/preview.jsx +38 -0
  71. package/templates/template_admin/public/src/dictionary/index.js +108 -39
  72. package/templates/template_admin/public/src/enum.js +41 -0
  73. package/templates/template_admin/public/src/hooks/index.jsx +8 -6
  74. package/templates/template_admin/public/src/hooks/useDebounceFn.jsx +33 -0
  75. package/templates/template_admin/public/src/hooks/useInToView.jsx +58 -0
  76. package/templates/template_admin/public/src/hooks/useRouteMenu.jsx +37 -28
  77. package/templates/template_admin/public/src/hooks/useTimer.jsx +42 -0
  78. package/templates/template_admin/public/src/index.jsx +10 -7
  79. package/templates/template_admin/public/src/mock/auth.js +33 -0
  80. package/templates/template_admin/public/src/mock/demo.js +12 -74
  81. package/templates/template_admin/public/src/mock/index.js +1 -0
  82. package/templates/template_admin/public/src/pages/auth/user/create/index.jsx +55 -0
  83. package/templates/template_admin/public/src/pages/auth/user/create/index.less +6 -0
  84. package/templates/template_admin/public/src/pages/auth/user/dialog/index.jsx +96 -0
  85. package/templates/template_admin/public/src/pages/auth/user/index.jsx +271 -0
  86. package/templates/template_admin/public/src/pages/components/layout/index.jsx +75 -0
  87. package/templates/template_admin/public/src/pages/components/layout/index.less +78 -0
  88. package/templates/template_admin/public/src/pages/components/layout/titleBar/index.jsx +28 -0
  89. package/templates/template_admin/public/src/pages/components/layout/titleBar/index.less +44 -0
  90. package/templates/template_admin/public/src/pages/components/select/account/index.jsx +114 -0
  91. package/templates/template_admin/public/src/pages/components/select/device/index.jsx +83 -0
  92. package/templates/template_admin/public/src/pages/components/select/groupUser/index.jsx +172 -0
  93. package/templates/template_admin/public/src/pages/components/select/user/index.jsx +119 -0
  94. package/templates/template_admin/public/src/pages/home.jsx +79 -0
  95. package/templates/template_admin/public/src/pages/home.less +6 -0
  96. package/templates/template_admin/public/src/pages/login/index.jsx +90 -6
  97. package/templates/template_admin/public/src/pages/login/index.less +133 -24
  98. package/templates/template_admin/public/src/provider/app.jsx +72 -66
  99. package/templates/template_admin/public/src/provider/loading.jsx +47 -0
  100. package/templates/template_admin/public/src/provider/menu.jsx +117 -83
  101. package/templates/template_admin/public/src/provider/menu.less +35 -0
  102. package/templates/template_admin/public/src/route.jsx +41 -40
  103. package/templates/template_admin/public/src/services/auth.js +39 -0
  104. package/templates/template_admin/public/src/services/demo.js +3 -37
  105. package/templates/template_admin/public/src/services/index.js +139 -13
  106. package/templates/template_admin/public/src/services/login.js +37 -0
  107. package/templates/template_admin/public/src/services/socket/index.jsx +100 -0
  108. package/templates/template_admin/public/src/type.js +36 -19
  109. package/templates/template_admin/public/src/utils/event.js +58 -0
  110. package/templates/template_admin/public/src/utils/format.js +84 -0
  111. package/templates/template_admin/public/src/utils/index.js +214 -2
  112. package/templates/template_admin/public/src/utils/rule.js +3 -0
  113. package/templates/template_admin/public/static/kssoLogin.html +1 -1
  114. package/templates/template_admin/webpack.api.js +11 -3
  115. package/src/.DS_Store +0 -0
  116. package/templates/template_admin/.gitignore +0 -6
  117. package/templates/template_admin/public/favicon.ico +0 -0
  118. package/templates/template_admin/public/src/assets/images/avatars/1.png +0 -0
  119. package/templates/template_admin/public/src/assets/images/avatars/2.png +0 -0
  120. package/templates/template_admin/public/src/assets/images/avatars/3.png +0 -0
  121. package/templates/template_admin/public/src/components/layout/centerBody/index.jsx +0 -25
  122. package/templates/template_admin/public/src/components/layout/centerBody/index.less +0 -30
  123. package/templates/template_admin/public/src/components/menu/index.less +0 -19
  124. package/templates/template_admin/public/src/components/menu/topMenu/index.jsx +0 -132
  125. package/templates/template_admin/public/src/components/menu/topMenu/index.less +0 -105
  126. package/templates/template_admin/public/src/pages/demo/detail/index.jsx +0 -27
  127. package/templates/template_admin/public/src/pages/demo/edit/index.jsx +0 -109
  128. package/templates/template_admin/public/src/pages/demo/index.less +0 -9
  129. package/templates/template_admin/public/src/pages/demo/page1.jsx +0 -161
  130. package/templates/template_admin/public/src/pages/superAdminLogin/index.jsx +0 -64
  131. package/templates/template_admin/public/src/pages/superAdminLogin/index.less +0 -44
  132. package/templates/template_app/.gitignore +0 -6
  133. package/templates/template_oa/.gitignore +0 -6
  134. package/templates/template_oa_jwt/.gitignore +0 -6
  135. package/templates/template_offcial/.gitignore +0 -6
@@ -3,13 +3,10 @@
3
3
  import React from 'react';
4
4
  // @ts-ignore
5
5
  import {useDictionary} from 'kn-hooks';
6
+
6
7
  // @ts-ignore
7
8
  import {Select,Radio} from 'antd';
8
9
 
9
- import {GET_ENUM_TYPE} from '@/services/demo'
10
-
11
- import ShowToast from '@/components/toast';
12
-
13
10
 
14
11
 
15
12
  /**
@@ -39,51 +36,123 @@ import ShowToast from '@/components/toast';
39
36
  */
40
37
 
41
38
 
39
+ /**
40
+ * @typedef Dictionary
41
+ * @property {DictionaryItem[]} list - 字典数据列表
42
+ * @property {(labelOrName:string)=>string|number} getId - (labelOrName:string)=>string,搜索字典项中,label或name匹配labelOrName的项目,返回其id的值
43
+ * @property {(idOrLabel:string|number)=>string} getName - (id:string)=>string,搜索字典项中,id匹配id的项目,返回其name的值
44
+ * @property {(idOrName:string|number)=>string} getLabel - (id:string)=>string,搜索字典项中,id匹配id的项目,返回其label的值
45
+ * @property {(text:string|number)=>DictionaryItem|null} getItem - 匹配text为id\name\label中任何一个的对象
46
+ * @property {JSX.Element[]} [selectOptions] - antd-select渲染成员
47
+ */
48
+
49
+
42
50
 
43
- export const SelectOption=(props)=>{
44
- const {value}=props;
45
- const name = props['data-keyname'];
46
- const onClick=(e)=>{
47
- ShowToast(`点击option name=${name},value=${value},label=${props.children}`)
48
- if(props.onClick)props.onClick();
49
- }
50
- // @ts-ignore
51
- return <hgroup onClick={onClick} key={value} name={name} value={value}>{props.children}</hgroup>
52
- }
53
51
 
54
- useDictionary.SetConfig({SelectOption:Select.Option, RadioOption: Radio })
52
+ // export const SelectOption=(props)=>{
53
+ // const {value}=props;
54
+ // const name = props['data-keyname'];
55
+ // const onClick=(e)=>{
56
+ // ShowToast(`点击option name=${name},value=${value},label=${props.children}`)
57
+ // if(props.onClick)props.onClick();
58
+ // }
59
+ // // @ts-ignore
60
+ // return <hgroup onClick={onClick} key={value} name={name} value={value}>{props.children}</hgroup>
61
+ // }
55
62
 
63
+ useDictionary.SetConfig({SelectOption:Select.Option,RadioOption:Radio})
56
64
 
57
- export const useDemoType = useDictionary.createDictionary({
58
- api:GET_ENUM_TYPE,
59
- afterApi:(response)=>{
60
- if(response?.code==0){
61
- let req= response.data.map(item=>{
62
- const {label,value:id,key:name}=item;
63
- return {label,id,name}
64
- });
65
- return req;
65
+
66
+ /**
67
+ *
68
+ * @param {DictionaryItem[]|[]} list
69
+ * @returns {Dictionary}
70
+ */
71
+ const createDictionary=(list)=>{
72
+ const getId=(nameOrLabel)=>{
73
+ for(let i=0;i<list.length;i++){
74
+ if(list[i].label == nameOrLabel || list[i].name == nameOrLabel){
75
+ return list[i].id;
76
+ }
66
77
  }
67
- return [];
78
+ return null;
68
79
  }
69
- });
80
+ const getLabel=(nameOrId)=>{
81
+ for(let i=0;i<list.length;i++){
82
+ if(list[i].id == nameOrId || list[i].name == nameOrId){
83
+ return list[i].label;
84
+ }
85
+ }
86
+ return null;
87
+ }
88
+ const getName=(idOrLabel)=>{
89
+ for(let i=0;i<list.length;i++){
90
+ if(list[i].id == idOrLabel || list[i].label == idOrLabel){
91
+ return list[i].name;
92
+ }
93
+ }
94
+ return null;
95
+ }
96
+ const getItem=(idOrNameOrLabel)=>{
97
+ for(let i=0;i<list.length;i++){
98
+ if(list[i].id == idOrNameOrLabel || list[i].label == idOrNameOrLabel || list[i].name== idOrNameOrLabel ){
99
+ return list[i];
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+
105
+ const selectOptions = list.map(item=>{
106
+ return <Select.Option value={item.id} >{item.label}</Select.Option>
107
+ })
108
+ return {
109
+ getId,getLabel,getName,getItem,list,selectOptions
110
+ }
111
+ }
70
112
 
71
- export const useTaskState= useDictionary.createDictionary({
72
- defaultTypes:[
73
- {label:'进行中',id:'1',name:'run'},
74
- {label:'已完成',id:'5',name:'complete'},
75
- ]
76
- });
77
113
 
114
+ /**
115
+ * 用户枚举数据
116
+ * @type UseDictionary
117
+ */
118
+ // export const useUserEnum=useDictionary.createDictionary({
119
+ // beforeApi: () => ({
120
+ // status: 1 // 筛选已启用的数据
121
+ // }),
122
+ // api: USER_ENUM,
123
+ // labelKey: 'name',
124
+ // afterApi: res => {
125
+ // let list=[];
126
+ // if(res?.code===0) {
127
+ // list=res?.data||[];
128
+ // }
129
+ // return list;
130
+ // }
131
+ // })
132
+
133
+
134
+ /**
135
+ * 消息已读状态的
136
+ */
137
+ export const DictMessageStatus=[
138
+ {label: '未读',id: '0',name: '0'},
139
+ {label: '已读',id: '1',name: '1'}
140
+ ]
78
141
 
79
142
  /**
80
- * 健康状态
143
+ * 消息已读状态
81
144
  * @type UseDictionary
82
145
  */
83
- export const useHealthy= useDictionary.createDictionary({
84
- defaultTypes:[
85
- {label:'正常',id:'normal',name:'normal'},
86
- {label:'异常',id:'abnormal',name:'abnormal'},
87
- {label:'禁用',id:'disabled',name:'disabled'},
88
- ]
146
+ export const useMessageStatus=useDictionary.createDictionary({
147
+ defaultTypes: DictMessageStatus
89
148
  });
149
+
150
+
151
+ /**
152
+ * 用户状态
153
+ */
154
+ export const emUserState= createDictionary([
155
+ {label:'启用',id:'1',name:'open'},
156
+ {label:'禁用',id:'0',name:'disabled'},
157
+ {label:'离职',id:'2',name:'out'},
158
+ ]);
@@ -0,0 +1,41 @@
1
+
2
+
3
+ /**
4
+ * @enum {string}
5
+ */
6
+ export const ENUM_MESSAGE_STATE={
7
+ Delivered:'Delivered',
8
+ Failed:'Failed',// 发送失败
9
+ Read:'Read', // 已读
10
+ RecallFailed:'RecallFailed',
11
+ Recalled:'Recalled', // 已撤回
12
+ Recalling:'Recalling',
13
+ Received:'Received',
14
+ Sending:'Sending',// 发送中
15
+ Sent:'Sent'
16
+ }
17
+
18
+
19
+
20
+
21
+ /**
22
+ * 消息中心的消息类型
23
+ * @enum {string}
24
+ */
25
+ export const ENUM_EVENT_BUS_TYPE={
26
+ NEW_MSG:'new_msg',// 新消息
27
+ UPDATE_MSG:'update_msg',// 老消息状态变更
28
+ REMOVE_SESSION:'remove_session',
29
+ NEW_SESSION:'new_session',
30
+ CHANGE_INPUT_VALUE:'change_input_value',
31
+ NEW_NOTIFY:'new_notify',//有新的消息通知
32
+ ADD_WORK_USER:'add_work_user',//接入新账号
33
+ UPDATE_WORK_USER:'update_work_user',//工作账号内容变更
34
+ MSG_READ:'msg_read',//已读某个消息
35
+ UPDATE_NOTIFY_UNREAD:'update_notify_unread',//更新未读消息数量
36
+ CHAT_UNREAD_COUNT:'CHAT_UNREAD_COUNT',//更新聊天未读消息数
37
+ SEND_MESSAGE:'SEND_MESSAGE',//发送一条消息,
38
+ UPDATE_TIMELINE:'UPDATE_TIMELINE',//刷新TIMELINE
39
+
40
+
41
+ }
@@ -1,15 +1,15 @@
1
-
2
-
3
1
  import useImageLoader from './useImageLoader';
4
2
  import useDelay from './useDelay';
5
3
  import usePreload from './usePreload';
6
4
  import useSearch from './useSearch';
7
5
  import useUpdate from './useUpdate';
8
6
  import useLoading from './useLoading';
9
- import useRouteMenu from './useRouteMenu';
7
+ import useDebounceFn from './useDebounceFn';
8
+ import useInToView from './useInToView';
9
+ import useTimer from './useTimer';
10
10
 
11
11
  // @ts-ignore
12
- import {usePagination,usePaginationWithForm} from 'kn-hooks';
12
+ import { usePagination, usePaginationWithForm } from 'kn-hooks';
13
13
 
14
14
  export {
15
15
  usePaginationWithForm,
@@ -20,5 +20,7 @@ export {
20
20
  useSearch,
21
21
  useUpdate,
22
22
  useLoading,
23
- useRouteMenu
24
- }
23
+ useDebounceFn,
24
+ useInToView,
25
+ useTimer
26
+ };
@@ -0,0 +1,33 @@
1
+ import React,{useRef} from 'react';
2
+
3
+ /**
4
+ * 防抖函数(可延迟开始前执行或延迟后执行)
5
+ * @param {Function} fn - 必填项;要防抖处理的函数
6
+ * @param {object} [options] - 可选项;
7
+ * @param {number} [options.wait] - 可选项;等待时间,单位为毫秒
8
+ * @param {boolean} [options.leading] - 可选项;是否在延迟开始前调用函数,默认否
9
+ * @returns
10
+ */
11
+ const UseDebounceFn = (fn,options)=>{
12
+ const timer = useRef(null);
13
+
14
+ const run = function(){
15
+ const _arguments = arguments;
16
+ if (options?.leading && !timer.current) {
17
+ fn.apply(this, _arguments);
18
+ }
19
+ if (timer.current) {
20
+ clearTimeout(timer.current);
21
+ timer.current = null;
22
+ }
23
+ timer.current = setTimeout(function () {
24
+ timer.current = null;
25
+ if (!options?.leading) {
26
+ fn.apply(this, _arguments);
27
+ }
28
+ }, options?.wait || 300);
29
+ }
30
+ return [run];
31
+ }
32
+
33
+ export default UseDebounceFn;
@@ -0,0 +1,58 @@
1
+ // @ts-ignore
2
+ import React, { useEffect,useState,useMemo,useRef,useCallback } from 'react';
3
+
4
+
5
+ const useInToView=()=>{
6
+ const [visible,setVisible]= useState(false);
7
+ const [visibled,setVisibled]= useState(false);
8
+ const refDom= useRef();
9
+ const refObserver=useRef();
10
+
11
+ const destory=()=>{
12
+ if(refObserver.current){
13
+ // @ts-ignore
14
+ refObserver.current=disconnect();
15
+ refObserver.current=null;
16
+ }
17
+ }
18
+
19
+ useEffect(()=>{
20
+ return ()=>{
21
+ destory();
22
+ }
23
+ },[refObserver]);
24
+
25
+ const watch=(dom)=>{
26
+ let observe;
27
+ destory();
28
+ setDom(dom);
29
+ if(!refDom.current)return;
30
+ observe = new IntersectionObserver((entries) => {
31
+ if (entries[0].intersectionRatio <= 0) {
32
+ setVisible(false);
33
+ return;
34
+ }
35
+ setVisible(true);
36
+ setVisibled(true);
37
+ });
38
+ observe.observe(refDom.current);
39
+ // @ts-ignore
40
+ refObserver.current=observe;
41
+ }
42
+ const setDom=(dom)=>{
43
+ if(typeof dom == 'string'){
44
+ refDom.current = document.querySelector(dom);
45
+ if(!refDom.current)return;
46
+ }else{
47
+ refDom.current= dom;
48
+ }
49
+ }
50
+
51
+ return {
52
+ visible,
53
+ visibled,
54
+ watch
55
+ }
56
+ }
57
+
58
+ export default useInToView;
@@ -5,31 +5,9 @@ import React,{ useRef, useState} from 'react';
5
5
  // @ts-ignore
6
6
  import { matchPath } from 'react-router-dom';
7
7
 
8
+ import {CONSOLE_LOG} from '@/utils';
8
9
 
9
- /**
10
- * 设置菜单属性
11
- * @typedef MenuConfig
12
- * @property {string} primaryId - 菜单的primaryId值
13
- * @property {('msgCount'|'icon'|'name')} key - 需要设置的字段名称
14
- * @property {any} value - 字段值
15
- */
16
-
17
- /**
18
- * 菜单项
19
- * @typedef RouteMenuItem
20
- * @property {string} name - 菜单展示的名称
21
- * @property {string|JSX.Element} [icon] - 菜单图标
22
- * @property {string} [url] - 菜单的URL地址
23
- * @property {string} [routeTemplate] - 菜单的路由模版,用于匹配动态路由
24
- * @property {number} [msgCount] - 菜单的未读消息数量
25
- * @property {boolean} [hideMenu=false] - 是否为隐藏的菜单,隐藏的菜单不会展示独立菜单,但是会匹配路由
26
- * @property {string[]} [auth] - 允许访问该菜单的权限列表
27
- * @property {RouteMenuItem[]} [children] - 子菜单
28
- * @property {string} [primaryId] - 菜单的唯一ID,如果存在primaryId,则菜单的key同primaryId
29
- * @property {string} [key] - 会自动生成的菜单唯一ID,如果菜单配置内存在了primaryId,则会取该id
30
- * @property {string} [parentKey] - 父级菜单的key,自动生成的
31
- *
32
- */
10
+ const MODULE_NAME='useRouteMenu';
33
11
 
34
12
  // const MenuData=[
35
13
  // {
@@ -82,6 +60,7 @@ import { matchPath } from 'react-router-dom';
82
60
  // ]
83
61
 
84
62
 
63
+
85
64
  const useRouteMenu=()=>{
86
65
  /**
87
66
  * @type [RouteMenuItem[], React.Dispatch<React.SetStateAction<RouteMenuItem[]>>]
@@ -98,6 +77,11 @@ const useRouteMenu=()=>{
98
77
  */
99
78
  const refKeyMap = useRef();
100
79
 
80
+ /**
81
+ * @type React.MutableRefObject<object>
82
+ */
83
+ const refSelf = useRef();
84
+
101
85
  /**
102
86
  * 遍历菜单,给菜单创建key,并创建map表以便快速查找菜单数据
103
87
  * @param {RouteMenuItem[]} data - 菜单列表数据
@@ -143,8 +127,11 @@ const useRouteMenu=()=>{
143
127
  let auth= true;
144
128
  // 判断用户有没有权限可以访问这个菜单
145
129
  if(menu.auth){
146
- if(menu.auth.some(menuAuthName=>userAuth.includes(menuAuthName)) == false){
147
- auth=false;
130
+ // 不是数组的话代表menu.auth是一个boolean变量,代表长期展示菜单
131
+ if(Array.isArray(menu.auth)){
132
+ if(menu.auth.some(menuAuthName=>userAuth?.includes(menuAuthName)) == false){
133
+ auth=false;
134
+ }
148
135
  }
149
136
  }
150
137
  // 隐藏的菜单
@@ -158,12 +145,29 @@ const useRouteMenu=()=>{
158
145
  if(item.children&&item.children.length>0){
159
146
  const chidList= getMenu(item.children, userAuth);
160
147
  item.children = chidList.length>0?chidList:null;
148
+ if(item.children){
149
+ let msgCount=0;
150
+ item.children.forEach(subMenu=>{
151
+ if(subMenu.msgCount){
152
+ msgCount += Number(subMenu.msgCount);
153
+ }
154
+ })
155
+ item.msgCount = msgCount;
156
+ list.push(item)
157
+ }else{
158
+ // 如果子菜单全部隐藏了,但是父菜单显示写了自己的权限的话,只要有权限则展示父节点
159
+ if(menu.auth){
160
+ list.push(item);
161
+ }
162
+ }
163
+ // 如果子菜单都没有权限访问,则父菜单也没必要展示了
164
+ return;
161
165
  }
162
166
  list.push(item)
163
167
  }
164
168
  });
165
169
  if(menus == source){
166
- console.warn('[useRouteMenu]getMenu:',list)
170
+ CONSOLE_LOG(MODULE_NAME,'getMenu:',list)
167
171
  }
168
172
  return list
169
173
  }
@@ -193,7 +197,7 @@ const useRouteMenu=()=>{
193
197
  }
194
198
  if(matchMenu){
195
199
  const menus= getParentMenus(matchMenu);
196
- console.warn(`[useRouteMenu]openMenus:`,menus)
200
+ CONSOLE_LOG(MODULE_NAME,'openMenus:',menus)
197
201
  return menus;
198
202
  }
199
203
  return [];
@@ -225,6 +229,11 @@ const useRouteMenu=()=>{
225
229
  setSource([...source])
226
230
  }
227
231
 
232
+ refSelf.current={
233
+ setMenuConfig
234
+ }
235
+
236
+
228
237
  return {setSourceMap,getOpenMenus,getMenu,source,findMenuData,setMenuConfig}
229
238
  }
230
239
 
@@ -0,0 +1,42 @@
1
+ // @ts-ignore
2
+ import { useRef,useState,useMemo, useEffect } from 'react';
3
+
4
+ const useTimer=(ms)=>{
5
+ const [time,setTime] = useState(0);
6
+ const refTimer = useRef();
7
+ const refTime = useRef();
8
+
9
+ useEffect(()=>{
10
+ // @ts-ignore
11
+ refTime.current = {time,setTime};
12
+ })
13
+ useEffect(()=>{
14
+ return ()=>{
15
+ if(refTimer.current){
16
+ window.clearInterval(refTimer.current);
17
+ }
18
+ }
19
+ },[])
20
+ useEffect(()=>{
21
+ if(refTimer.current){
22
+ window.clearInterval(refTimer.current);
23
+ }
24
+ // @ts-ignore
25
+ refTimer.current = setInterval(()=>{
26
+ // @ts-ignore
27
+ refTime.current.setTime(v=>v+ms);
28
+ },ms);
29
+
30
+
31
+ },[ms]);
32
+
33
+ const actions=useMemo(()=>{
34
+ return {
35
+ time,
36
+ };
37
+ },[time]);
38
+
39
+ return actions;
40
+ }
41
+
42
+ export default useTimer;
@@ -9,6 +9,9 @@ import {HashRouter} from 'react-router-dom';
9
9
  import './_antd.less';
10
10
  import './_reset.less';
11
11
  import {RouteList} from './route';
12
+ // @ts-ignore
13
+ import moment from 'moment';
14
+ moment.locale('zh-cn');
12
15
 
13
16
  // @ts-ignore
14
17
  if(MOCK){
@@ -25,13 +28,13 @@ window.appLog=(txt)=>{
25
28
  /* eslint-disable */
26
29
  // @ts-ignore
27
30
  if(BUILD_ENV!='prod'){
28
- // @ts-ignore
29
- let VConsole = require('vconsole');
30
- // @ts-ignore
31
- const vConsole = new VConsole();
32
- setTimeout(() => {
33
- vConsole.setSwitchPosition(70, 10);
34
- }, 2000);
31
+ // // @ts-ignore
32
+ // let VConsole = require('vconsole');
33
+ // // @ts-ignore
34
+ // const vConsole = new VConsole();
35
+ // setTimeout(() => {
36
+ // vConsole.setSwitchPosition(70, 10);
37
+ // }, 2000);
35
38
  }
36
39
  // @ts-ignore
37
40
  if(BUILD_ENV){
@@ -0,0 +1,33 @@
1
+ import {GET_REQUEST,waitTime} from './utils';
2
+ import {RESPONSE_STRUCT} from '@/services';
3
+
4
+ async function KSSOLOGIN(req,res){
5
+ const params = GET_REQUEST(req);
6
+
7
+ await waitTime();
8
+ return {
9
+ "code": 0,
10
+ "msg": "操作成功",
11
+ "data": {
12
+ "authorities": [],
13
+ "details": {
14
+ "remoteAddress": "172.16.32.116",
15
+ "sessionId": null
16
+ },
17
+ "authenticated": false,
18
+ "principal": "changx",
19
+ "credentials": null,
20
+ "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJjaGFuZ3giLCJtb2RpZnkiOjAsInJlYWxOYW1lIjoi5bi45petIiwiY3JlYXRlZCI6MTcxMTQ0MTA5NzU2NSwidXNlck5hbWUiOiJjaGFuZ3giLCJleHAiOjE3MTE0ODQyOTcsInVzZXJJZCI6MTQsImp0aSI6MTQsImF1dGhvcml0aWVzIjpbeyJhdXRob3JpdHkiOiJncm91cC5kZWxldGUifSx7ImF1dGhvcml0eSI6InVzZXIudmlldyJ9LHsiYXV0aG9yaXR5Ijoicm9sZSJ9LHsiYXV0aG9yaXR5IjoicGVybWlzc2lvbi52aWV3In0seyJhdXRob3JpdHkiOiJkZXZpY2VfZ3JvdXAifSx7ImF1dGhvcml0eSI6InJvbGUudmlldyJ9LHsiYXV0aG9yaXR5IjoicGVybWlzc2lvbiJ9LHsiYXV0aG9yaXR5IjoiZ3JvdXAudmlldyJ9LHsiYXV0aG9yaXR5IjoiZGV2aWNlX2dyb3VwLmRlbGV0ZSJ9LHsiYXV0aG9yaXR5IjoidXNlci5lZGl0In0seyJhdXRob3JpdHkiOiJncm91cC5lZGl0In0seyJhdXRob3JpdHkiOiJkZXZpY2VfZ3JvdXAuYWRkIn0seyJhdXRob3JpdHkiOiJkZXZpY2VfZ3JvdXAuZWRpdCJ9LHsiYXV0aG9yaXR5IjoiZGV2aWNlX2dyb3VwLnZpZXcifSx7ImF1dGhvcml0eSI6InVzZXIifV19.aedlb-P96FuWt_xhqLuTOcudcZqThzloxcJpTmlanCB9bm2e_5RGlcPWxBbi7mdj5VGIQ36gCf1SDxy7aPewbw",
21
+ "userId": "14",
22
+ "username": "changx",
23
+ "realName": "常旭",
24
+ "isAdmin": false,
25
+ "modify": null,
26
+ "name": "changx"
27
+ }
28
+ }
29
+ }
30
+
31
+ export default {
32
+ '/api/ksso/auth':{post:KSSOLOGIN},
33
+ }
@@ -1,11 +1,9 @@
1
+ import qs from 'qs';
1
2
  import {GET_REQUEST,waitTime} from './utils';
2
3
  import {RESPONSE_STRUCT} from '@/services';
3
4
  // @ts-ignore
4
5
  import moment from 'moment';
5
6
 
6
- // @ts-ignore
7
- import avatar1 from '@/assets/images/avatars/1.png';
8
-
9
7
  const MAX_TOTAL=98;
10
8
  let UPDATE_COUNT=0;
11
9
  let CREATE_COUNT=0;
@@ -22,8 +20,18 @@ function updateListData(){
22
20
  name: `名称`+ `${id}`.padStart(2,'0'),
23
21
  phone: `1370000`+ `${id}`.padStart(4,'0'),
24
22
  date: moment().add(id,'minute').unix()*1000,//format('YYYY-MM-DD HH:mm:ss'),
23
+ dateRange: [moment().add(id,'minute').unix()*1000,moment().add(id,'day').unix()*1000],
25
24
  select: selectValue[id%selectValue.length],
26
25
  longName: `这是一个很长的名称`+ `${id}`.padStart(2,'0'),
26
+ imgName: 'https://nebula-api.oss-cn-shanghai.aliyuncs.com/20240329/24163932-85ea-4372-9ff7-ee7c71748bcb/1711691401353-95387929.jpeg',
27
+ previewSrcs:[
28
+ 'http://callcneter.oss-cn-shanghai.aliyuncs.com/140_zhangfan31711522544778-46413274',
29
+ 'http://callcneter.oss-cn-shanghai.aliyuncs.com/140_zhangfan31711522539477-71557179',
30
+ 'http://callcneter.oss-cn-shanghai.aliyuncs.com/140_zhangfan31711522552637-65222632',
31
+ 'http://callcneter.oss-cn-shanghai.aliyuncs.com/140_zhangfan31711522549224-81138313',
32
+ ],
33
+ videoName:'https://nebula-api.oss-cn-shanghai.aliyuncs.com/20240329/fc172bf8-1f61-4464-8d48-29b98a42fb4a/1711701991414-12827489.mp4',
34
+ disabled:id%2?true:false
27
35
  }
28
36
  };
29
37
 
@@ -106,79 +114,9 @@ async function GET_DETAIL(req){
106
114
  }
107
115
 
108
116
  }
109
-
110
-
111
- let GET_USER_INFO_COUNT=0;
112
- let USER_INFO={
113
- authorities:['leader','admin'],
114
- realName:'cx',
115
- name:'cx',
116
- avater:avatar1,
117
- unreadMsg:5,
118
- token:'token',
119
- username:'fanta',
120
- };
121
- function _GET_USER_INFO(){
122
- let req = {...USER_INFO};
123
- req.authorities = GET_USER_INFO_COUNT%2==0?['leader']:['leader','admin'];
124
- GET_USER_INFO_COUNT++;
125
- return req;
126
- }
127
- async function GET_USER_INFO(req){
128
- await waitTime();
129
-
130
- return {
131
- [RESPONSE_STRUCT.CODE]:0,
132
- [RESPONSE_STRUCT.DATA]:_GET_USER_INFO(),
133
- [RESPONSE_STRUCT.MSG]:''
134
- }
135
- }
136
-
137
-
138
- async function Login(req,res){
139
- const query = JSON.parse(req.body);
140
- await waitTime();
141
- return {
142
- [RESPONSE_STRUCT.CODE]:0,
143
- [RESPONSE_STRUCT.DATA]:_GET_USER_INFO(),
144
- [RESPONSE_STRUCT.MSG]:''
145
- }
146
- }
147
-
148
- async function KssoLogin(req,res){
149
- await waitTime();
150
- return {
151
- [RESPONSE_STRUCT.CODE]:0,
152
- [RESPONSE_STRUCT.DATA]:_GET_USER_INFO(),
153
- [RESPONSE_STRUCT.MSG]:''
154
- }
155
- }
156
-
157
-
158
- async function GET_ENUM_TYPE(req){
159
- await waitTime();
160
-
161
- return {
162
- [RESPONSE_STRUCT.CODE]:0,
163
- [RESPONSE_STRUCT.DATA]:[
164
- {label:'类型1',key:'type1',value:'value1'},
165
- {label:'类型2',key:'type2',value:'value2'},
166
- {label:'类型3',key:'type3',value:'value3'},
167
- ],
168
- [RESPONSE_STRUCT.MSG]:''
169
- }
170
- }
171
-
172
-
173
117
  export default {
174
118
  '/demo/list':{get:GET_LIST},
175
119
  '/demo/create':{post:CREATE},
176
120
  '/demo/update':{post:UPDATE},
177
- '/demo/detail':{get:GET_DETAIL},
178
- '/demo/userInfo':{get:GET_USER_INFO},
179
- '/demo/login':{post:Login},
180
- '/demo/ksso/auth':{post:KssoLogin},
181
- '/demo/enumType':{get:GET_ENUM_TYPE},
182
-
183
-
121
+ '/demo/detail':{get:GET_DETAIL}
184
122
  }
@@ -50,6 +50,7 @@ function regMock(list){
50
50
  })
51
51
  }
52
52
  }
53
+
53
54
  /* eslint-disable */
54
55
  // @ts-ignore
55
56
  if(MOCK){