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
@@ -0,0 +1,114 @@
1
+
2
+ import React, { useEffect, useState } from 'react';
3
+ // @ts-ignore
4
+ import { Select } from 'antd';
5
+ import {GET_LIST} from '@/services/demo';
6
+
7
+
8
+ /**
9
+ * 账号选择
10
+ * 数据来源:服务设置-账号管理-所有枚举
11
+ * @param {object} props
12
+ * @param {'single'|'multiple'} [props.mode='single'] - 单选/多选模式
13
+ * @param {(value:string|string[],items:object[])=>void} [props.onChange] - 选择发生变化时的回调
14
+ * @param {string|string[]} [props.value] - 选择发生变化时的回调
15
+ * @param {boolean} [props.withData=false] - 返回的数据是否包含原始用户数据
16
+ * @param {object} [props.style={}] - 样式
17
+ * @param {string} [props.placeholder] - 提示
18
+ * @param {boolean} [props.allowClear=falsse] - 一键删除按钮
19
+ *
20
+ *
21
+ *
22
+ * @returns {JSX.Element}
23
+ */
24
+ const SelectAccount=(props)=>{
25
+ const {mode='single',value:_value,onChange,withData=false,style:_style={},placeholder='',allowClear=false} = props;
26
+ const [list,setList]= useState([]);
27
+
28
+ const [value,setValue]=useState(mode=='single'?'':[]);
29
+
30
+ const init = async ()=>{
31
+ const req = await GET_LIST();
32
+ if(req?.code==0){
33
+ let users= req.data.map(user=>{
34
+ const {id,name} = user;
35
+
36
+ // return <Select.Option value={`${id}`} data={user}>{`${name}(${account})`}</Select.Option>
37
+ return {
38
+ label:`${name}`,
39
+ value:`${id}`,
40
+ data:user
41
+ }
42
+ })
43
+ setList(users);
44
+ }else{setList([])}
45
+ }
46
+
47
+
48
+ const onUserChange=(newValue,options)=>{
49
+ if(onChange)onChange(newValue,options);
50
+ }
51
+
52
+ const onFilter=(input,option)=>{
53
+ const {label,value}= option;
54
+ if( `${label}`.toLocaleLowerCase().indexOf(input.toLocaleLowerCase()) >=0 ){
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+
60
+ // useEffect(()=>{
61
+ // if(list&&list.length>0){
62
+ // if(mode=='single'){
63
+ // let find = list.filter(user=>user.value == value);
64
+ // if(!find || !find[0]){
65
+ // if(onChange)onChange(undefined);
66
+ // }
67
+ // }else{
68
+ // let newValue=[];
69
+ // value.forEach(id=>{
70
+ // let find = list.filter(user=>user.value == id);
71
+ // if(find && find[0]){
72
+ // newValue.push(id);
73
+ // }
74
+ // })
75
+ // if(onChange)onChange(newValue);
76
+
77
+ // }
78
+ // }
79
+ // },[list])
80
+
81
+ useEffect(()=>{
82
+ init();
83
+ },[])
84
+ useEffect(()=>{
85
+ if(!_value){
86
+ setValue(undefined);
87
+ return;
88
+ }
89
+ let req;
90
+ if(mode=='multiple' && Array.isArray(_value)){
91
+ req= _value.map(id=>`${id}`)
92
+ }else{
93
+ req = `${_value}`
94
+ }
95
+ setValue(req)
96
+ },[_value]);
97
+
98
+ return (
99
+ <Select
100
+ style={{..._style}}
101
+ placeholder={placeholder}
102
+ allowClear={allowClear?true:false}
103
+ // @ts-ignore
104
+ mode={mode}
105
+ showSearch
106
+ value={value}
107
+ options={list}
108
+ onChange={onUserChange}
109
+ filterOption={onFilter}
110
+ />
111
+ );
112
+ }
113
+
114
+ export default SelectAccount;
@@ -0,0 +1,83 @@
1
+
2
+ import React, { useEffect, useState } from 'react';
3
+ // @ts-ignore
4
+ import { Select } from 'antd';
5
+ import {DEVICE_ENUM} from '@/services/device';
6
+
7
+
8
+
9
+ /**
10
+ * 设备选择框
11
+ * 数据来源:手机管理-所有枚举
12
+ * @param {object} props
13
+ * @param {'single'|'multiple'} [props.mode='single'] - 单选/多选模式
14
+ * @param {(value:string|string[])=>void} [props.onChange] - 选择发生变化时的回调
15
+ * @param {string|string[]} [props.value] - 选择发生变化时的回调
16
+ * @param {object} [props.deviceType={}] - 调用枚举接口可用的传参
17
+ *
18
+ * @returns {JSX.Element}
19
+ */
20
+ const SelectDevice=(props)=>{
21
+ const {mode='single',value:_value,deviceType={},onChange} = props;
22
+ const [list,setList]= useState([]);
23
+
24
+ const [value,setValue]=useState(mode=='single'?'':[]);
25
+
26
+ const init = async ()=>{
27
+ const req = await DEVICE_ENUM(deviceType);
28
+ if(req?.code==0){
29
+ let devices= req.data.map(device=>{
30
+ const {id,title} = device;
31
+ let strId = `${id}`.padStart(2,'0');
32
+ return {
33
+ label:`[${strId}]${title}`,
34
+ value:`${id}`,
35
+ data:device
36
+ }
37
+ })
38
+ setList(devices);
39
+ }else{setList([])}
40
+ }
41
+ const onDeviceChange=(newValue)=>{
42
+ if(onChange)onChange(newValue);
43
+ }
44
+
45
+ const onFilter=(input,option)=>{
46
+ const {label,value}= option;
47
+ if( `${label}`.indexOf(input) >=0 ||
48
+ `${value}`.indexOf(input) >=0
49
+ ){
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ useEffect(()=>{
56
+ init();
57
+ },[])
58
+ useEffect(()=>{
59
+ if(!_value){
60
+ setValue(mode=='multiple'?[]:'');
61
+ return;
62
+ }
63
+ let req;
64
+ if(mode=='multiple' && Array.isArray(_value) ){
65
+ req= _value.map(id=>`${id}`)
66
+ }else{
67
+ req = `${_value}`
68
+ }
69
+ setValue(req)
70
+ },[_value]);
71
+ return (
72
+ <Select
73
+ mode={mode}
74
+ showSearch
75
+ value={value}
76
+ options={list}
77
+ onChange={onDeviceChange}
78
+ filterOption={onFilter}
79
+ />
80
+ );
81
+ }
82
+
83
+ export default SelectDevice;
@@ -0,0 +1,172 @@
1
+
2
+ import React, { useEffect, useState } from 'react';
3
+ // @ts-ignore
4
+ import { Select } from 'antd';
5
+
6
+ import {USERGROUP_ENUM} from '@/services/authAdmin/userGroup';
7
+ import {USER_ENUM} from '@/services/authAdmin/user';
8
+ import {formatUserName} from '@/utils/format';
9
+
10
+ const GROUP_PRE_NAME='group-';
11
+
12
+ /**
13
+ * 将组ID和用户ID,转义为 SelectGroupUser 能识别的id
14
+ * @param {number[]|number|string|string[]} groupId - 组ID列表
15
+ * @param {number[]|number|string|string[]} groupId - 用户ID列表
16
+ * @returns {string[]}
17
+ */
18
+ const encodeValue=(groupId=[],userId=[])=>{
19
+ let req=[];
20
+ if(Array.isArray(groupId)){
21
+ req = groupId.map(id=>`${GROUP_PRE_NAME}${id}`);
22
+ }else{
23
+ if(groupId){
24
+ req.push(`${GROUP_PRE_NAME}${groupId}`)
25
+ }
26
+ }
27
+ if(Array.isArray(userId)){
28
+ let temp= userId.map(id=>`${id}`);
29
+ req=[...req,...temp]
30
+ }else{
31
+ if(userId){
32
+ req.push(`${userId}`)
33
+ }
34
+ }
35
+ return req;
36
+ }
37
+
38
+ /***
39
+ * 将 SelectGroupUser 组件的值转义回需要提交给接口的 groupId和userId
40
+ * @param {string[]|string} value - 当前选中的值
41
+ *
42
+ * @returns {{groupId:string[],userId:string[]}}
43
+ */
44
+ const decodeValue=(value)=>{
45
+ let groupId=[];
46
+ let userId=[];
47
+
48
+ if(Array.isArray(value)){
49
+ value.forEach(v=>{
50
+ if(`${v}`.indexOf(GROUP_PRE_NAME)>=0){
51
+ groupId.push(`${v}`.split(GROUP_PRE_NAME)[1]);
52
+ }else{
53
+ userId.push(`${v}`);
54
+ }
55
+ })
56
+ }else{
57
+ if(`${value}`.indexOf(GROUP_PRE_NAME)>=0){
58
+ groupId.push( `${value}`.split(GROUP_PRE_NAME)[1] );
59
+ }
60
+ }
61
+ return {groupId,userId}
62
+ }
63
+
64
+ export const convert = {setValue:encodeValue,getValue:decodeValue};
65
+
66
+ /**
67
+ * 选择用户组和用户的下拉选择框组件
68
+ * @param {object} props
69
+ * @param {string|string[]} [props.value] - 值,值为组ID和用户ID混合的,组ID由group-前缀打头:['group-组id','用户id'],所以需要进行转义
70
+ * @param {(newValue:string[])=>void} [props.onChange] - 值
71
+ *
72
+ * @returns {JSX.Element}
73
+ */
74
+ const SelectGroupUser=(props)=>{
75
+ const {value:_value,onChange=null}= props;
76
+
77
+ const [groupList,setGroupList] = useState([]);
78
+
79
+ const [value,setValue]=useState(_value||[]);
80
+
81
+ const init=async ()=>{
82
+ let req1 = USERGROUP_ENUM();
83
+ let req2 = USER_ENUM({status:1});
84
+
85
+ /**
86
+ * @type {ServicesResponse}
87
+ */
88
+ let reqUserGroup = await req1;
89
+ /**
90
+ * @type {ServicesResponse}
91
+ */
92
+ let reqUsers = await req2;
93
+ let list=[];
94
+ if(reqUserGroup?.code==0){
95
+ const groupList = reqUserGroup.data.map(group=>{
96
+ const {id,name:label}=group;
97
+ let groupId = `${GROUP_PRE_NAME}${id}`;
98
+ const groupInfo = {
99
+ label,
100
+ value:groupId,
101
+ }
102
+ return groupInfo;
103
+ });
104
+ list.push({
105
+ label:'用户组',
106
+ title:'group',
107
+ options:groupList
108
+ });
109
+ }
110
+ if(reqUsers?.code==0){
111
+ const userList = reqUsers.data.map(user=>{
112
+ const {id:value,name:label}=user;
113
+ let userName = formatUserName(user);
114
+ const userInfo = {
115
+ label:userName,
116
+ value:`${value}`,
117
+ data:user
118
+ }
119
+ return userInfo;
120
+ });
121
+
122
+ list.push({
123
+ label:'用户',
124
+ title:'users',
125
+ options:userList
126
+ });
127
+ }
128
+ setGroupList(list);
129
+ }
130
+
131
+ const onGroupUserChange = (newValue) => {
132
+ console.log('onChange ', newValue);
133
+ if(onChange)onChange(newValue);
134
+ };
135
+
136
+ const onFilter=(input,option)=>{
137
+ if(option.options)return false;
138
+ const {label,value,data}= option;
139
+ if( `${label}`.indexOf(input) >=0 ||
140
+ `${value}`.indexOf(input) >=0
141
+ ){
142
+ return true;
143
+ }
144
+ if(data && data.account.indexOf(input) >=0 ){
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+
150
+ useEffect(()=>{
151
+ if(!_value){setValue([]);return;}
152
+ setValue(_value)
153
+ },[_value]);
154
+
155
+ useEffect(()=>{
156
+ init();
157
+ },[])
158
+
159
+ return (
160
+ <Select
161
+ mode="multiple"
162
+ showSearch
163
+ value={value}
164
+ options={groupList}
165
+ onChange={onGroupUserChange}
166
+ filterOption={onFilter}
167
+ placeholder='请选择组名或用户名'
168
+ />
169
+ )
170
+ }
171
+
172
+ export default SelectGroupUser;
@@ -0,0 +1,119 @@
1
+
2
+ import React, { useEffect, useState } from 'react';
3
+ // @ts-ignore
4
+ import { Select } from 'antd';
5
+ import {USER_ENUM} from '@/services/authAdmin/user';
6
+
7
+ /**
8
+ * @typedef userEnumPrams
9
+ * @property {1|0|''} status - 1启用中的 0禁用中的 空为所有
10
+ */
11
+
12
+ /**
13
+ * 用户选择框
14
+ * 数据来源:用户管理-所有枚举
15
+ * @param {object} props
16
+ * @param {'single'|'multiple'} [props.mode='single'] - 单选/多选模式
17
+ * @param {(value:string|string[],items:object[])=>void} [props.onChange] - 选择发生变化时的回调
18
+ * @param {string|string[]} [props.value] - 选择发生变化时的回调
19
+ * @param {userEnumPrams} [props.userType={status:1}] - 选择发生变化时的回调
20
+ * @param {boolean} [props.withData=false] - 返回的数据是否包含原始用户数据
21
+ * @param {object} [props.style={}] - 样式
22
+ * @param {string} [props.placeholder] - 提示
23
+ * @param {boolean} [props.allowClear=falsse] - 一键删除按钮
24
+ *
25
+ *
26
+ *
27
+ * @returns {JSX.Element}
28
+ */
29
+ const SelectUser=(props)=>{
30
+ const {mode='single',value:_value,userType={status:1},onChange,withData=false,style:_style={},placeholder='',allowClear=false} = props;
31
+ const [list,setList]= useState([]);
32
+
33
+ const [value,setValue]=useState(mode=='single'?'':[]);
34
+
35
+ const init = async ()=>{
36
+ const req = await USER_ENUM(userType);
37
+ if(req?.code==0){
38
+ let users= req.data.map(user=>{
39
+ const {id,name,account,status} = user;
40
+
41
+ // return <Select.Option value={`${id}`} data={user}>{`${name}(${account})`}</Select.Option>
42
+ return {
43
+ label:status==0?`${name}(${account})[已禁用]`:`${name}(${account})`,
44
+ value:`${id}`,
45
+ data:user
46
+ }
47
+ })
48
+ setList(users);
49
+ }else{setList([])}
50
+ }
51
+
52
+
53
+ const onUserChange=(newValue,options)=>{
54
+ if(onChange)onChange(newValue,options);
55
+ }
56
+
57
+ const onFilter=(input,option)=>{
58
+ const {label,value}= option;
59
+ if( `${label}`.indexOf(input) >=0 ){
60
+ return true;
61
+ }
62
+ return false;
63
+ }
64
+
65
+ // useEffect(()=>{
66
+ // if(list&&list.length>0){
67
+ // if(mode=='single'){
68
+ // let find = list.filter(user=>user.value == value);
69
+ // if(!find || !find[0]){
70
+ // if(onChange)onChange(undefined);
71
+ // }
72
+ // }else{
73
+ // let newValue=[];
74
+ // value.forEach(id=>{
75
+ // let find = list.filter(user=>user.value == id);
76
+ // if(find && find[0]){
77
+ // newValue.push(id);
78
+ // }
79
+ // })
80
+ // if(onChange)onChange(newValue);
81
+
82
+ // }
83
+ // }
84
+ // },[list])
85
+
86
+ useEffect(()=>{
87
+ init();
88
+ },[])
89
+ useEffect(()=>{
90
+ if(!_value){
91
+ setValue(undefined);
92
+ return;
93
+ }
94
+ let req;
95
+ if(mode=='multiple' && Array.isArray(_value)){
96
+ req= _value.map(id=>`${id}`)
97
+ }else{
98
+ req = `${_value}`
99
+ }
100
+ setValue(req)
101
+ },[_value]);
102
+
103
+ return (
104
+ <Select
105
+ style={{..._style}}
106
+ placeholder={placeholder}
107
+ allowClear={allowClear?true:false}
108
+ // @ts-ignore
109
+ mode={mode}
110
+ showSearch
111
+ value={value}
112
+ options={list}
113
+ onChange={onUserChange}
114
+ filterOption={onFilter}
115
+ />
116
+ );
117
+ }
118
+
119
+ export default SelectUser;
@@ -0,0 +1,79 @@
1
+ import React, { useRef } from 'react';
2
+
3
+ import {
4
+ Button
5
+ // @ts-ignore
6
+ } from 'antd';
7
+
8
+ import {Layout,SearchBar,TitleBar,Content,Panel} from './components/layout'
9
+
10
+ import AppProvider from '@/provider/app';
11
+ import MenuProvider from '@/provider/menu';
12
+ import { AuthShow } from '@/components/auth';
13
+ // @ts-ignore
14
+ import styles from './home.less';
15
+
16
+ const Home = () => {
17
+
18
+ const app = AppProvider.useContainer();
19
+ const menu = MenuProvider.useContainer();
20
+
21
+ /**
22
+ * @type {React.MutableRefObject<number>}
23
+ */
24
+ const refMenuCount= useRef(1);
25
+
26
+ const onMenuMessage=()=>{
27
+ /**
28
+ * @type {MenuConfig[]}
29
+ */
30
+ let config=[
31
+ {
32
+ primaryId:'authUser',
33
+ key:'msgCount',
34
+ value:refMenuCount.current++
35
+ },
36
+ ];
37
+ menu.setMenuConfig(config);
38
+ }
39
+
40
+ const onAuthAdd=()=>{
41
+ let newAuth = [...app.auths];
42
+ if(newAuth.includes('authA'))return;
43
+ newAuth.push('authA');
44
+ app.setAuths(newAuth)
45
+ }
46
+ const onAuthRemove=()=>{
47
+ let newAuth = [...app.auths];
48
+ if(!newAuth.includes('authA'))return;
49
+ let idx = newAuth.indexOf('authA');
50
+ newAuth.splice(idx,1);
51
+ app.setAuths([...newAuth])
52
+ }
53
+ return (
54
+ <Layout>
55
+ <SearchBar>
56
+ <TitleBar label='首页'/>
57
+ </SearchBar>
58
+
59
+ <Content>
60
+ <Panel>
61
+ <section className={styles.row}>
62
+ <Button onClick={onMenuMessage}>增加菜单未读消息数</Button>
63
+
64
+ <Button onClick={onAuthAdd}>增加权限A</Button>
65
+ <AuthShow name='authA'><Button onClick={onAuthRemove}>去除权限A(有authA时才能看见)</Button></AuthShow>
66
+
67
+
68
+ </section>
69
+
70
+
71
+
72
+ </Panel>
73
+ </Content>
74
+
75
+ </Layout>
76
+ )
77
+ }
78
+
79
+ export default Home;
@@ -0,0 +1,6 @@
1
+
2
+ .row{
3
+ display: flex;
4
+ column-gap: 12px;
5
+ align-items: center;
6
+ }
@@ -1,26 +1,110 @@
1
- import React, { useEffect, useState, useRef } from 'react';
2
- // @ts-ignore
3
- import { useSearchParams } from 'react-router-dom';
1
+ import React, { useState, useEffect } from 'react';
4
2
  import ProviderApp from '@/provider/app';
3
+ // @ts-ignore
4
+ import { useSearchParams } from 'react-router-dom';
5
5
 
6
+ import ruler from '@/utils/rule';
7
+ // @ts-ignore
8
+ import {Button,Tabs,Form,Input} from 'antd';
6
9
  // @ts-ignore
7
10
  import styles from './index.less';
8
11
 
12
+ import {jumpUrl} from '@/utils';
13
+ // @ts-ignore
14
+ import imgSlogan from '@/assets/images/login/slogan.png';
15
+ // @ts-ignore
16
+ import imgLogo2 from '@/assets/images/login/logo.png';
17
+
18
+
9
19
  const Page = () => {
10
- const [search] = useSearchParams();
11
20
  const providerApp = ProviderApp.useContainer();
21
+ const [search] = useSearchParams();
22
+
23
+ const [state,setState]=useState('')
12
24
 
25
+ const [form] = Form.useForm();
26
+
13
27
  const kssoLogin=async ()=>{
14
28
  const req= await providerApp.kssoLogin();
15
29
  if(!req){
30
+ setState('login');
16
31
  return;
17
32
  }
18
33
  }
19
- useEffect(()=>{kssoLogin()},[])
34
+ const onLogin= async ()=>{
35
+ jumpUrl(`${location.protocol}//${location.host}/static/kssoLogin.html`,{replace:true})
36
+ }
37
+
38
+ const tabs=[
39
+ {
40
+ key: '1',
41
+ label: '内部账号',
42
+ children: <section className={styles.kssoLogin}>
43
+ <Button type='primary' block onClick={onLogin} size='large'>一键登录</Button>
44
+ </section>,
45
+ },
46
+ {
47
+ key: '2',
48
+ label: '外部账号',
49
+ children: (
50
+ <section className={styles.phoneLogin}>
51
+ <Form form={form} layout="vertical" initialValues={{status:'',keyword:'',dep:'',role:''}}>
52
+
53
+ <label className={styles.inputLabel}>手机号码<span className={styles.required}>*</span></label>
54
+
55
+ <Form.Item name={'phone'} rules={ruler.PHONE}>
56
+ <Input size='large' placeholder="请输入"/>
57
+ </Form.Item>
58
+
59
+ <hgroup className={styles.codeGroup}>
60
+ <label className={styles.inputLabel}>
61
+ 验证码<span className={styles.required}>*</span>
62
+ </label>
63
+ <label className={styles.sendCode}>发送验证码</label>
64
+ </hgroup>
65
+ <Form.Item name={'code'} rules={ruler.INPUT}>
66
+ <Input size='large' placeholder="请输入验证码"/>
67
+ </Form.Item>
68
+ <Button type='primary' block onClick={onLogin} size='large'>登录</Button>
69
+ </Form>
70
+ </section>
71
+ ),
72
+
73
+ },
74
+ ];
75
+ const onTab=()=>{}
76
+
77
+ useEffect(()=>{
78
+ let code = search.get('code');
79
+ if(code){
80
+ kssoLogin();
81
+ }else{
82
+ providerApp.clearLoginInfo();
83
+ setState('login')
84
+ }
85
+ },[])
20
86
 
21
87
  return (
22
88
  <section className={styles.body}>
23
- ksso登录跳转中...
89
+ {/* 左上角slogan */}
90
+ <section className={styles.sloganWrap}>
91
+ <img src={imgSlogan} className={styles.slogan} />
92
+ </section>
93
+
94
+ <section className={styles.loginWrap}>
95
+
96
+ <div className={styles.centerWrap}>
97
+ <img src={imgLogo2} className={styles.logo} data-run={state!='login'} />
98
+ <p className={styles.title}>欢迎登录<b>宙斯系统</b></p>
99
+ {
100
+ state=='login'?<Tabs defaultActiveKey='1' items={tabs} onChange={onTab} />
101
+ :<p className={styles.logining}>登录中...</p>
102
+ }
103
+
104
+
105
+ </div>
106
+ </section>
107
+
24
108
  </section>
25
109
  )
26
110
  }