kn-cli 1.0.97 → 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.
- package/package.json +1 -1
- package/templates/template_admin/cli.config.js +4 -1
- package/templates/template_admin/package.json +7 -1
- package/templates/template_admin/public/favicon.png +0 -0
- package/templates/template_admin/public/index.html +6 -4
- package/templates/template_admin/public/src/_antd.less +30 -3
- package/templates/template_admin/public/src/_mixin.less +41 -0
- package/templates/template_admin/public/src/_reset.less +28 -20
- package/templates/template_admin/public/src/_variable.less +11 -6
- package/templates/template_admin/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.less +60 -8
- package/templates/template_admin/public/src/assets/iconfont/iconfont.svg +57 -18
- package/templates/template_admin/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_admin/public/src/assets/images/arrow.png +0 -0
- package/templates/template_admin/public/src/assets/images/icon-notice.png +0 -0
- package/templates/template_admin/public/src/assets/images/icon-user.png +0 -0
- package/templates/template_admin/public/src/assets/images/loadFail.png +0 -0
- package/templates/template_admin/public/src/assets/images/login/bg.png +0 -0
- package/templates/template_admin/public/src/assets/images/login/logo.png +0 -0
- package/templates/template_admin/public/src/assets/images/login/slogan.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-dep-active.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-dep.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-log-active.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-log.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-loginlog-active.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-loginlog.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-role-active.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-role.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-user-active.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/icon-user.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/nav-toggle.png +0 -0
- package/templates/template_admin/public/src/assets/images/nav/slogan.png +0 -0
- package/templates/template_admin/public/src/assets/images/noData.png +0 -0
- package/templates/template_admin/public/src/assets/images/noSelect.png +0 -0
- package/templates/template_admin/public/src/components/auth/index.jsx +7 -3
- package/templates/template_admin/public/src/components/auth/index.less +7 -0
- package/templates/template_admin/public/src/components/badge/index.jsx +47 -0
- package/templates/template_admin/public/src/components/badge/index.less +44 -0
- package/templates/template_admin/public/src/components/debug/index.jsx +27 -0
- package/templates/template_admin/public/src/components/debug/index.less +9 -0
- package/templates/template_admin/public/src/components/empty/index.jsx +28 -0
- package/templates/template_admin/public/src/components/empty/index.less +20 -0
- package/templates/template_admin/public/src/components/image/index.jsx +73 -0
- package/templates/template_admin/public/src/components/image/index.less +117 -0
- package/templates/template_admin/public/src/components/image/preview.jsx +85 -0
- package/templates/template_admin/public/src/components/layout/basic/index.jsx +24 -11
- package/templates/template_admin/public/src/components/layout/basic/index.less +58 -19
- package/templates/template_admin/public/src/components/layout/index.jsx +20 -17
- package/templates/template_admin/public/src/components/layout/index.less +4 -4
- package/templates/template_admin/public/src/components/layout/provider/index.jsx +19 -6
- package/templates/template_admin/public/src/components/{menu → leftMenu}/index.jsx +20 -28
- package/templates/template_admin/public/src/components/leftMenu/index.less +42 -0
- package/templates/template_admin/public/src/components/popup/index.jsx +25 -0
- package/templates/template_admin/public/src/components/table/column.jsx +47 -0
- package/templates/template_admin/public/src/components/table/column.less +12 -0
- package/templates/template_admin/public/src/components/table/index.jsx +22 -13
- package/templates/template_admin/public/src/components/table/index.less +15 -0
- package/templates/template_admin/public/src/components/text/index.jsx +98 -0
- package/templates/template_admin/public/src/components/text/index.less +13 -0
- package/templates/template_admin/public/src/components/topMenu/index.jsx +97 -0
- package/templates/template_admin/public/src/components/topMenu/index.less +80 -0
- package/templates/template_admin/public/src/components/topMenu/topBar/index.jsx +76 -0
- package/templates/template_admin/public/src/components/topMenu/topBar/index.less +88 -0
- package/templates/template_admin/public/src/components/video/index.jsx +96 -0
- package/templates/template_admin/public/src/components/video/index.less +132 -0
- package/templates/template_admin/public/src/components/video/preview.jsx +38 -0
- package/templates/template_admin/public/src/dictionary/index.js +108 -39
- package/templates/template_admin/public/src/enum.js +41 -0
- package/templates/template_admin/public/src/hooks/index.jsx +8 -6
- package/templates/template_admin/public/src/hooks/useDebounceFn.jsx +33 -0
- package/templates/template_admin/public/src/hooks/useInToView.jsx +58 -0
- package/templates/template_admin/public/src/hooks/useRouteMenu.jsx +37 -28
- package/templates/template_admin/public/src/hooks/useTimer.jsx +42 -0
- package/templates/template_admin/public/src/index.jsx +10 -7
- package/templates/template_admin/public/src/mock/auth.js +33 -0
- package/templates/template_admin/public/src/mock/demo.js +12 -74
- package/templates/template_admin/public/src/mock/index.js +1 -0
- package/templates/template_admin/public/src/pages/auth/user/create/index.jsx +55 -0
- package/templates/template_admin/public/src/pages/auth/user/create/index.less +6 -0
- package/templates/template_admin/public/src/pages/auth/user/dialog/index.jsx +96 -0
- package/templates/template_admin/public/src/pages/auth/user/index.jsx +271 -0
- package/templates/template_admin/public/src/pages/components/layout/index.jsx +75 -0
- package/templates/template_admin/public/src/pages/components/layout/index.less +78 -0
- package/templates/template_admin/public/src/pages/components/layout/titleBar/index.jsx +28 -0
- package/templates/template_admin/public/src/pages/components/layout/titleBar/index.less +44 -0
- package/templates/template_admin/public/src/pages/components/select/account/index.jsx +114 -0
- package/templates/template_admin/public/src/pages/components/select/device/index.jsx +83 -0
- package/templates/template_admin/public/src/pages/components/select/groupUser/index.jsx +172 -0
- package/templates/template_admin/public/src/pages/components/select/user/index.jsx +119 -0
- package/templates/template_admin/public/src/pages/home.jsx +79 -0
- package/templates/template_admin/public/src/pages/home.less +6 -0
- package/templates/template_admin/public/src/pages/login/index.jsx +90 -6
- package/templates/template_admin/public/src/pages/login/index.less +133 -24
- package/templates/template_admin/public/src/provider/app.jsx +72 -66
- package/templates/template_admin/public/src/provider/loading.jsx +47 -0
- package/templates/template_admin/public/src/provider/menu.jsx +117 -83
- package/templates/template_admin/public/src/provider/menu.less +35 -0
- package/templates/template_admin/public/src/route.jsx +41 -40
- package/templates/template_admin/public/src/services/auth.js +39 -0
- package/templates/template_admin/public/src/services/demo.js +3 -37
- package/templates/template_admin/public/src/services/index.js +139 -13
- package/templates/template_admin/public/src/services/login.js +37 -0
- package/templates/template_admin/public/src/services/socket/index.jsx +100 -0
- package/templates/template_admin/public/src/type.js +36 -19
- package/templates/template_admin/public/src/utils/event.js +58 -0
- package/templates/template_admin/public/src/utils/format.js +84 -0
- package/templates/template_admin/public/src/utils/index.js +214 -2
- package/templates/template_admin/public/src/utils/rule.js +3 -0
- package/templates/template_admin/public/static/kssoLogin.html +1 -1
- package/templates/template_admin/webpack.api.js +11 -3
- package/templates/template_admin/public/favicon.ico +0 -0
- package/templates/template_admin/public/src/assets/images/avatars/1.png +0 -0
- package/templates/template_admin/public/src/assets/images/avatars/2.png +0 -0
- package/templates/template_admin/public/src/assets/images/avatars/3.png +0 -0
- package/templates/template_admin/public/src/components/layout/centerBody/index.jsx +0 -25
- package/templates/template_admin/public/src/components/layout/centerBody/index.less +0 -30
- package/templates/template_admin/public/src/components/menu/index.less +0 -19
- package/templates/template_admin/public/src/components/menu/topMenu/index.jsx +0 -132
- package/templates/template_admin/public/src/components/menu/topMenu/index.less +0 -105
- package/templates/template_admin/public/src/pages/demo/detail/index.jsx +0 -27
- package/templates/template_admin/public/src/pages/demo/edit/index.jsx +0 -109
- package/templates/template_admin/public/src/pages/demo/index.less +0 -9
- package/templates/template_admin/public/src/pages/demo/page1.jsx +0 -161
- package/templates/template_admin/public/src/pages/superAdminLogin/index.jsx +0 -64
- package/templates/template_admin/public/src/pages/superAdminLogin/index.less +0 -44
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Space,
|
|
4
|
+
Form,
|
|
5
|
+
Button,
|
|
6
|
+
Input,
|
|
7
|
+
Select,
|
|
8
|
+
Tabs,
|
|
9
|
+
Badge
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
} from 'antd';
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
import {PlusOutlined} from '@ant-design/icons';
|
|
14
|
+
|
|
15
|
+
import ruler from '@/utils/rule';
|
|
16
|
+
import {px2rem} from '@/utils';
|
|
17
|
+
import {Layout,SearchBar,TitleBar,Content,Panel} from '@/pages/components/layout'
|
|
18
|
+
import {emUserState} from '@/dictionary';
|
|
19
|
+
import Table from '@/components/table';
|
|
20
|
+
import { usePaginationWithForm } from '@/hooks';
|
|
21
|
+
import Link from '@/components/link';
|
|
22
|
+
import {FormatTableService,FormatGetRequest} from '@/services'
|
|
23
|
+
import {
|
|
24
|
+
GET_LIST,
|
|
25
|
+
} from '@/services/demo';
|
|
26
|
+
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
import styles from './index.less';
|
|
29
|
+
|
|
30
|
+
const AuthUserCreate = () => {
|
|
31
|
+
return (
|
|
32
|
+
<Layout>
|
|
33
|
+
<SearchBar>
|
|
34
|
+
<TitleBar label='新建用户' showBack optionRight={
|
|
35
|
+
<div className={styles.btns}>
|
|
36
|
+
<Button type='primary'>保存</Button>
|
|
37
|
+
<Button>取消</Button>
|
|
38
|
+
</div>
|
|
39
|
+
}/>
|
|
40
|
+
</SearchBar>
|
|
41
|
+
|
|
42
|
+
<Content>
|
|
43
|
+
<Panel title='基础信息'>
|
|
44
|
+
<div>123123</div>
|
|
45
|
+
</Panel>
|
|
46
|
+
<Panel title='权限配置'>
|
|
47
|
+
<div>123123</div>
|
|
48
|
+
</Panel>
|
|
49
|
+
</Content>
|
|
50
|
+
|
|
51
|
+
</Layout>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default AuthUserCreate;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import ReactDom from 'react-dom';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { Modal, Form, Input, message,Spin } from 'antd';
|
|
5
|
+
import Popup from '@/components/popup';
|
|
6
|
+
import { UPDATE,GET_DETAIL } from '@/services/demo';
|
|
7
|
+
import rule from '@/utils/rule';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const DialogEdit = (props) => {
|
|
13
|
+
const { destory, id=null } = props;
|
|
14
|
+
const [form] = Form.useForm();
|
|
15
|
+
const [record,setRecord]=useState(null)
|
|
16
|
+
|
|
17
|
+
const init=async ()=>{
|
|
18
|
+
if(id){
|
|
19
|
+
const req= await GET_DETAIL({id})
|
|
20
|
+
if(req?.code==0 && req?.data){
|
|
21
|
+
let item= req.data;
|
|
22
|
+
setRecord(item);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
setRecord({})
|
|
27
|
+
}
|
|
28
|
+
const onOk = async () => {
|
|
29
|
+
try {
|
|
30
|
+
const values = await form.validateFields();
|
|
31
|
+
const params = {
|
|
32
|
+
...values,
|
|
33
|
+
};
|
|
34
|
+
let res = null;
|
|
35
|
+
if (id) {
|
|
36
|
+
res = await UPDATE({id,...params});
|
|
37
|
+
}
|
|
38
|
+
if (res?.code === 0) {
|
|
39
|
+
message.success('成功');
|
|
40
|
+
destory && destory(true);
|
|
41
|
+
}
|
|
42
|
+
} catch (errorInfo) {
|
|
43
|
+
console.log('Failed:', errorInfo);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const onCancel = () => {
|
|
48
|
+
form.resetFields();
|
|
49
|
+
destory && destory(false);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
useEffect(()=>{
|
|
53
|
+
init();
|
|
54
|
+
},[])
|
|
55
|
+
const isEdit=id?true:false;
|
|
56
|
+
return (
|
|
57
|
+
<Modal
|
|
58
|
+
maskClosable={false}
|
|
59
|
+
title={isEdit? '编辑用户' : '新增用户'}
|
|
60
|
+
width={600}
|
|
61
|
+
open={true}
|
|
62
|
+
onOk={onOk}
|
|
63
|
+
onCancel={onCancel}
|
|
64
|
+
>
|
|
65
|
+
{
|
|
66
|
+
!record?
|
|
67
|
+
<Spin/>:
|
|
68
|
+
<Form labelCol={{ span: 5 }} wrapperCol={{ span: 19 }} form={form} initialValues={record||{}}>
|
|
69
|
+
<Form.Item
|
|
70
|
+
label="姓名"
|
|
71
|
+
name="userId"
|
|
72
|
+
ruler={rule.INPUT}
|
|
73
|
+
required
|
|
74
|
+
>
|
|
75
|
+
<Input placeholder="请输入" disabled={isEdit}/>
|
|
76
|
+
</Form.Item>
|
|
77
|
+
<Form.Item label="昵称" name="bindNickname" ruler={rule.INPUT}>
|
|
78
|
+
<Input placeholder="请输入" />
|
|
79
|
+
</Form.Item>
|
|
80
|
+
|
|
81
|
+
</Form>
|
|
82
|
+
}
|
|
83
|
+
</Modal>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const ShowEdit = (props = {}) => {
|
|
88
|
+
return new Promise((resolve) => {
|
|
89
|
+
let popup = Popup(resolve);
|
|
90
|
+
ReactDom.render(
|
|
91
|
+
<DialogEdit destory={popup.destory} {...props} />,
|
|
92
|
+
popup.dom
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export default ShowEdit;
|