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.
- package/build/package.json +1 -0
- package/package.json +1 -1
- package/readme.md +3 -0
- 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/src/.DS_Store +0 -0
- package/templates/template_admin/.gitignore +0 -6
- 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
- package/templates/template_app/.gitignore +0 -6
- package/templates/template_oa/.gitignore +0 -6
- package/templates/template_oa_jwt/.gitignore +0 -6
- package/templates/template_offcial/.gitignore +0 -6
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import {CONSOLE_LOG} from '@/utils';
|
|
4
|
+
const events={}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const MODULE_NAME='EventBus'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 监听消息
|
|
11
|
+
* @param {import('../enum').ENUM_EVENT_BUS_TYPE} type
|
|
12
|
+
* @param {(params:object)=>void} fn
|
|
13
|
+
*/
|
|
14
|
+
export const addEventListener=(type,fn)=>{
|
|
15
|
+
const list = events[type]=events[type]||[];
|
|
16
|
+
list.push(fn);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 移除监听消息
|
|
21
|
+
* @param {import('../enum').ENUM_EVENT_BUS_TYPE} type
|
|
22
|
+
* @param {(params:object)=>void} fn
|
|
23
|
+
*/
|
|
24
|
+
export const removeEventListener=(type,fn)=>{
|
|
25
|
+
const list = events[type]=events[type]||[];
|
|
26
|
+
for(let i=0;i<list.length;i++){
|
|
27
|
+
let _fn = list[i];
|
|
28
|
+
if(fn==_fn){
|
|
29
|
+
list.splice(i,1);
|
|
30
|
+
i--;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 广播消息
|
|
37
|
+
* @param {import('../enum').ENUM_EVENT_BUS_TYPE} type
|
|
38
|
+
* @param {object} params
|
|
39
|
+
*/
|
|
40
|
+
export const broadcast=(type,params)=>{
|
|
41
|
+
CONSOLE_LOG(MODULE_NAME,'广播',type,params)
|
|
42
|
+
const list = events[type]=events[type]||[];
|
|
43
|
+
for(let i=0;i<list.length;i++){
|
|
44
|
+
let _fn = list[i];
|
|
45
|
+
_fn(params);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
addEventListener,
|
|
53
|
+
removeEventListener,
|
|
54
|
+
broadcast
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import moment from 'moment';
|
|
1
3
|
|
|
2
4
|
/**
|
|
3
5
|
* 格式化为货币格式
|
|
@@ -48,4 +50,86 @@ export const formatPhone=(value,extra={noValue:'-'})=>{
|
|
|
48
50
|
return value.replace(/(\d)(?=(\d{4})+$)/g, '$1-');
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
/**
|
|
54
|
+
* 文件大小展示转化为B、KB、MB
|
|
55
|
+
* @param {number} fileSize - 文件大小,单位bit
|
|
56
|
+
*/
|
|
57
|
+
export const formatFileSize=(fileSize)=>{
|
|
58
|
+
if(fileSize<1024){
|
|
59
|
+
return fileSize+'B';
|
|
60
|
+
}
|
|
61
|
+
if(fileSize<(1024*1024)){
|
|
62
|
+
const size=(fileSize/1024).toFixed(1);
|
|
63
|
+
return size + 'KB';
|
|
64
|
+
}
|
|
65
|
+
if(fileSize < (1024 * 1024 * 1024)){
|
|
66
|
+
const size=(fileSize/(1024 * 1024)).toFixed(1);
|
|
67
|
+
return size+'M';
|
|
68
|
+
}
|
|
69
|
+
const size=(fileSize/(1024*1024*1024)).toFixed(1);
|
|
70
|
+
return size+'G';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 格式化用户名称
|
|
76
|
+
* @param {object} user
|
|
77
|
+
* @returns {string}
|
|
78
|
+
*/
|
|
79
|
+
export const formatUserName=(user)=>{
|
|
80
|
+
if(user.status==0){
|
|
81
|
+
return `${user.name}[已禁用]`;
|
|
82
|
+
}
|
|
83
|
+
return user.name;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param {moment|string} momentTime
|
|
89
|
+
* @param {string} type='minute' 'minute':精确到分钟 ,默认:精确到最大单位
|
|
90
|
+
*
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
export const fromNow=(momentTime,type='minute')=>{
|
|
94
|
+
var now = moment();
|
|
95
|
+
if(!moment.isMoment(momentTime)){
|
|
96
|
+
momentTime = moment(momentTime)
|
|
97
|
+
}
|
|
98
|
+
var duration = moment.duration(now.diff(momentTime));
|
|
99
|
+
|
|
100
|
+
// 获取小时和分钟
|
|
101
|
+
var days = Math.floor(duration.asDays());
|
|
102
|
+
var months = Math.floor(duration.asMonths());
|
|
103
|
+
var years = Math.floor(duration.asYears());
|
|
104
|
+
|
|
105
|
+
var hours = Math.floor(duration.asHours());
|
|
106
|
+
var minutes = duration.minutes();
|
|
107
|
+
// var seconds = duration.seconds();
|
|
108
|
+
|
|
109
|
+
if(years>0){
|
|
110
|
+
return momentTime.format('YYYY-MM-DD')
|
|
111
|
+
return `${years}年前`;
|
|
112
|
+
}
|
|
113
|
+
if(months>0){
|
|
114
|
+
return momentTime.format('MM-DD');
|
|
115
|
+
return `${months}个月前`;
|
|
116
|
+
}
|
|
117
|
+
if(days>0){
|
|
118
|
+
return `${days}天前`;
|
|
119
|
+
}
|
|
120
|
+
if(hours>0){
|
|
121
|
+
if(type=='hour'){
|
|
122
|
+
return `${hours}小时前`;
|
|
123
|
+
}
|
|
124
|
+
if(minutes<=0){
|
|
125
|
+
return `${hours}小时前`;
|
|
126
|
+
}else{
|
|
127
|
+
return `${hours}小时${minutes}分钟前`;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if(minutes>0){
|
|
131
|
+
return `${minutes}分钟前`;
|
|
132
|
+
}
|
|
133
|
+
return '刚刚';
|
|
134
|
+
}
|
|
51
135
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import JSZip from 'jszip';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import moment from 'moment';
|
|
2
5
|
/**
|
|
3
6
|
* 打开一个第三方链接
|
|
4
7
|
* @param {string} link - 链接地址
|
|
@@ -68,6 +71,8 @@ export const jumpUrl=(url,options={})=>{
|
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
|
|
74
|
+
|
|
75
|
+
|
|
71
76
|
// 关闭页面
|
|
72
77
|
export const closeWindow = () => {
|
|
73
78
|
// @ts-ignore
|
|
@@ -79,4 +84,211 @@ export const closeWindow = () => {
|
|
|
79
84
|
window.close();
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
|
-
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
export const px2rem=(px)=>{
|
|
91
|
+
px=+px/100+'rem';
|
|
92
|
+
return px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 获取字符串字节数(中文字符字节数由编码方式角色,utf-8是3个字节)
|
|
97
|
+
*/
|
|
98
|
+
export const getStrByteLen=(str)=>{
|
|
99
|
+
if(!str){
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
const len=encodeURIComponent(str).replace(/%../g,"a").length;
|
|
103
|
+
return len;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 下载文件
|
|
108
|
+
* @param {string} url - 文件地址
|
|
109
|
+
* @param {string} [filename] - 文件名
|
|
110
|
+
*/
|
|
111
|
+
export const downloadFile = (url,filename)=> {
|
|
112
|
+
// 使用fetch API获取资源
|
|
113
|
+
fetch(url)
|
|
114
|
+
.then(response => {
|
|
115
|
+
return response.blob();
|
|
116
|
+
}) // 将响应转换为Blob对象
|
|
117
|
+
.then(blob => {
|
|
118
|
+
// 创建一个指向该Blob的URL
|
|
119
|
+
const blobUrl=window.URL.createObjectURL(blob);
|
|
120
|
+
// 创建一个<a>标签用于下载
|
|
121
|
+
const link=document.createElement('a');
|
|
122
|
+
link.href=blobUrl;
|
|
123
|
+
link.download=filename||''; // 设置下载文件名,如果没有览器将使用URL的最后一部分作为文件名
|
|
124
|
+
link.style.display='none';
|
|
125
|
+
// 触发下载
|
|
126
|
+
document.body.appendChild(link);
|
|
127
|
+
link.click();
|
|
128
|
+
|
|
129
|
+
// 清理并移除<a>标签
|
|
130
|
+
document.body.removeChild(link);
|
|
131
|
+
window.URL.revokeObjectURL(blobUrl);
|
|
132
|
+
})
|
|
133
|
+
.catch(error => {
|
|
134
|
+
console.error('下载资源失败:',error);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* 下载多个文件并打包成zip
|
|
140
|
+
* @param {Array} urls - 文件地址数组
|
|
141
|
+
* @param {string} [zipName] - zip文件名
|
|
142
|
+
*/
|
|
143
|
+
export const downloadFilesAsZip = async(urls, zipName) => {
|
|
144
|
+
const zip=new JSZip();
|
|
145
|
+
|
|
146
|
+
await Promise.all(
|
|
147
|
+
urls.map(async (item) =>(
|
|
148
|
+
fetch(item?.url)
|
|
149
|
+
.then(response => response.blob())
|
|
150
|
+
.then(blob => {
|
|
151
|
+
const fileName=item?.name;
|
|
152
|
+
zip.file(fileName,blob);
|
|
153
|
+
})
|
|
154
|
+
))
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// 生成ZIP Blob对象
|
|
158
|
+
const zipBlob=await zip.generateAsync({type: 'blob'});
|
|
159
|
+
// 创建一个指向ZIP Blob的URL
|
|
160
|
+
const blobUrl=window.URL.createObjectURL(zipBlob);
|
|
161
|
+
const link=document.createElement('a');
|
|
162
|
+
link.href=blobUrl;
|
|
163
|
+
link.download=zipName??'download';
|
|
164
|
+
link.style.display='none';
|
|
165
|
+
document.body.appendChild(link);
|
|
166
|
+
link.click();
|
|
167
|
+
document.body.removeChild(link);
|
|
168
|
+
URL.revokeObjectURL(blobUrl);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
const CONSOLE_CONFIG={
|
|
173
|
+
'useRouteMenu':false,
|
|
174
|
+
'ProviderTimelines':true,
|
|
175
|
+
'Websocket':true,
|
|
176
|
+
'EventBus':true,
|
|
177
|
+
'MessageWall':true,
|
|
178
|
+
'ProviderApp':true
|
|
179
|
+
}
|
|
180
|
+
export const CONSOLE_LOG=(moduleName, txt, ...other)=>{
|
|
181
|
+
if(!CONSOLE_CONFIG[moduleName]){return;}
|
|
182
|
+
console.log(`[${moduleName}]${txt}`, ...other)
|
|
183
|
+
}
|
|
184
|
+
CONSOLE_LOG.warn = (moduleName, txt, ...other)=>{
|
|
185
|
+
if(!CONSOLE_CONFIG[moduleName]){return;}
|
|
186
|
+
console.warn(`[${moduleName}]${txt}`, ...other)
|
|
187
|
+
}
|
|
188
|
+
CONSOLE_LOG.error = (moduleName, txt, ...other)=>{
|
|
189
|
+
if(!CONSOLE_CONFIG[moduleName]){return;}
|
|
190
|
+
console.error(`[${moduleName}]${txt}`, ...other)
|
|
191
|
+
}
|
|
192
|
+
CONSOLE_LOG.info = (moduleName, txt, ...other)=>{
|
|
193
|
+
if(!CONSOLE_CONFIG[moduleName]){return;}
|
|
194
|
+
console.info(`[${moduleName}]${txt}`, ...other)
|
|
195
|
+
}
|
|
196
|
+
CONSOLE_LOG.log = (moduleName, txt, ...other)=>{
|
|
197
|
+
if(!CONSOLE_CONFIG[moduleName]){return;}
|
|
198
|
+
console.log(`[${moduleName}]${txt}`, ...other)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export const WriteLog=(text)=>{
|
|
202
|
+
let log = localStorage.getItem('nebulaLog');
|
|
203
|
+
let logs=[];
|
|
204
|
+
text = `[${moment().format('MM-DD HH:mm:ss')}]:${text}`;
|
|
205
|
+
if(log){
|
|
206
|
+
logs = log.split('\n');
|
|
207
|
+
}else{
|
|
208
|
+
log = text;
|
|
209
|
+
}
|
|
210
|
+
logs.splice(0,0,text);
|
|
211
|
+
localStorage.setItem('nebulaLog',logs.join('\n'));
|
|
212
|
+
}
|
|
213
|
+
export const Storage={
|
|
214
|
+
/**
|
|
215
|
+
* @param {string} name
|
|
216
|
+
* @returns {object|null}
|
|
217
|
+
*/
|
|
218
|
+
get:(name)=>{
|
|
219
|
+
let req = localStorage.getItem(name);
|
|
220
|
+
try{
|
|
221
|
+
if(req){
|
|
222
|
+
req = JSON.parse(req);
|
|
223
|
+
return req;
|
|
224
|
+
}
|
|
225
|
+
}catch(ex){
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
/**
|
|
230
|
+
* @param {string} name
|
|
231
|
+
* @param {object} item
|
|
232
|
+
*/
|
|
233
|
+
set:(name,item)=>{
|
|
234
|
+
let value='';
|
|
235
|
+
if(item){
|
|
236
|
+
value = JSON.stringify(item);
|
|
237
|
+
}
|
|
238
|
+
localStorage.setItem(name,value);
|
|
239
|
+
},
|
|
240
|
+
clear:(name)=>{
|
|
241
|
+
localStorage.removeItem(name);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export const StorageName={
|
|
245
|
+
UserListFilterMenu:'userListFilterMenu',
|
|
246
|
+
AccountConfig:'AccountConfig'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* 给返回Promise的函数增加节流功能
|
|
253
|
+
* @param {(any)=>Promise} fn
|
|
254
|
+
* @param {number} ms - 防抖时间
|
|
255
|
+
* @returns {Function}
|
|
256
|
+
*/
|
|
257
|
+
export function throttlePromise(fn, ms) {
|
|
258
|
+
const pendingPromises = new Map();
|
|
259
|
+
return function(params) {
|
|
260
|
+
const key = JSON.stringify(params);
|
|
261
|
+
|
|
262
|
+
if (pendingPromises.has(key)) {
|
|
263
|
+
return pendingPromises.get(key);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const promise = new Promise((resolve, reject) => {
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
pendingPromises.delete(key);
|
|
269
|
+
fn(params).then(resolve).catch(reject);
|
|
270
|
+
}, ms);
|
|
271
|
+
});
|
|
272
|
+
pendingPromises.set(key, promise);
|
|
273
|
+
return promise;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
export const delayLoader=(loader,ms=5000)=>{
|
|
279
|
+
return new Promise(resolve=>{
|
|
280
|
+
loader.then(req=>{
|
|
281
|
+
setTimeout(()=>{
|
|
282
|
+
resolve(req);
|
|
283
|
+
},ms)
|
|
284
|
+
})
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export const delay=(ms=1000)=>{
|
|
289
|
+
return new Promise(resolve=>{
|
|
290
|
+
setTimeout(()=>{
|
|
291
|
+
resolve();
|
|
292
|
+
},ms)
|
|
293
|
+
})
|
|
294
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<title></title>
|
|
13
13
|
<script>
|
|
14
14
|
var url = location.protocol + '//' + location.host+'/#/login';
|
|
15
|
-
location.replace('https://ksso.kingnet.com/oauth2/auth?client_id=
|
|
15
|
+
location.replace('https://ksso.kingnet.com/oauth2/auth?client_id=30000716&response_type=code&redirect_uri=' + encodeURIComponent(url));
|
|
16
16
|
</script>
|
|
17
17
|
</head>
|
|
18
18
|
|
|
@@ -5,17 +5,24 @@ const configs = {
|
|
|
5
5
|
},
|
|
6
6
|
// cicd构建时研发环境
|
|
7
7
|
dev: {
|
|
8
|
-
API_HOST: '
|
|
8
|
+
API_HOST: 'https://dev-nebula-api.kingnet.com',
|
|
9
|
+
DEVICE_HOST: 'wss://dev-nebula-adb.kyhub.cn',
|
|
10
|
+
ADB_HOST: 'https://dev-nebula-adb.kyhub.cn',
|
|
11
|
+
WS_HOST: 'wss://dev-nebula-connector.kingnet.com/ws',
|
|
9
12
|
},
|
|
10
13
|
// cicd构建时生产环境
|
|
11
14
|
prod: {
|
|
12
|
-
API_HOST: '
|
|
15
|
+
API_HOST: 'https://nebula-api.kingnet.com',
|
|
16
|
+
DEVICE_HOST: 'wss://nebula-adb.kingnet.com',
|
|
17
|
+
ADB_HOST: 'https://nebula-adb.kingnet.com',
|
|
18
|
+
WS_HOST: 'wss://nebula-connector.kingnet.com/ws',
|
|
13
19
|
},
|
|
14
20
|
};
|
|
15
21
|
|
|
22
|
+
|
|
16
23
|
const API_PROXY= {
|
|
17
24
|
'/api/**': {
|
|
18
|
-
target: 'http://
|
|
25
|
+
target: 'http://192.168.92.117:8080',
|
|
19
26
|
changeOrigin: true,
|
|
20
27
|
logLevel: 'debug',
|
|
21
28
|
pathRewrite: {
|
|
@@ -24,6 +31,7 @@ const API_PROXY= {
|
|
|
24
31
|
},
|
|
25
32
|
};
|
|
26
33
|
|
|
34
|
+
// @ts-ignore
|
|
27
35
|
const env = process.env.build_env||'localdebug';
|
|
28
36
|
|
|
29
37
|
|
package/src/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import styles from './index.less';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 居中定位的layout
|
|
9
|
-
* @param {object} props
|
|
10
|
-
* @param {string} [props.className] - 扩展类样式
|
|
11
|
-
* @param {string} [props.layout='normal'] - 布局样式,xy-center|x-center|y-center
|
|
12
|
-
* @param {JSX.Element|string} [props.children] - 容器内的子组件
|
|
13
|
-
*
|
|
14
|
-
* @returns {JSX.Element}
|
|
15
|
-
*/
|
|
16
|
-
const LayoutCenterBody=(props)=>{
|
|
17
|
-
const {className,layout='normal'} = props;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<section data-layout={layout} className={ className?`${styles.contentBody} ${className}`:styles.contentBody }>
|
|
21
|
-
{props.children}
|
|
22
|
-
</section>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
export default LayoutCenterBody;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
@import '~@/_variable.less';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
.contentBody{
|
|
5
|
-
width:100%;
|
|
6
|
-
height:100%;
|
|
7
|
-
&[data-layout='xy-center']{
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
align-items: center;
|
|
12
|
-
}
|
|
13
|
-
&[data-layout='x-center']{
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
align-items: center;
|
|
17
|
-
}
|
|
18
|
-
&[data-layout='y-center']{
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
body[data-debug-layout]{
|
|
26
|
-
.contentBody{
|
|
27
|
-
border:1px solid red;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
@import '~@/_variable.less';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
.nav{
|
|
5
|
-
width: var(--nav-width);
|
|
6
|
-
height:100%;
|
|
7
|
-
background-color: var(--color-primary-dark);
|
|
8
|
-
transition: all .2s;
|
|
9
|
-
z-index: var(--z-nav-mobile);
|
|
10
|
-
overflow-y: auto;
|
|
11
|
-
&[data-nav-hide='true']{
|
|
12
|
-
display: none;
|
|
13
|
-
}
|
|
14
|
-
&[data-nav-mode='mobile']{
|
|
15
|
-
position: fixed;
|
|
16
|
-
z-index: var(--z-nav-mobile);
|
|
17
|
-
box-shadow: 0 0 20px #444;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import React, { useState,useEffect, useRef} from 'react';
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import { useLocation,useNavigate } from 'react-router-dom';
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
import { Menu,Dropdown,Badge } from 'antd';
|
|
9
|
-
|
|
10
|
-
import ProviderApp from '@/provider/app';
|
|
11
|
-
import ProviderMenu from '@/provider/menu';
|
|
12
|
-
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
import imgAvatar from '@/assets/images/avatar.png';
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
import styles from './index.less';
|
|
17
|
-
|
|
18
|
-
const TopMenu=()=>{
|
|
19
|
-
const app = ProviderApp.useContainer();
|
|
20
|
-
const providerMenu = ProviderMenu.useContainer();
|
|
21
|
-
const navigate = useNavigate();
|
|
22
|
-
|
|
23
|
-
const [menus,setMenus]=useState([]);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const translateMenu=(list)=>{
|
|
27
|
-
if(!list||list.length<=0)return [];
|
|
28
|
-
let req=list.map(menu=>{
|
|
29
|
-
const {key,name:label,icon,url,msgCount}=menu;
|
|
30
|
-
|
|
31
|
-
let item={
|
|
32
|
-
key,label,icon,url
|
|
33
|
-
}
|
|
34
|
-
if(msgCount&&msgCount>0){
|
|
35
|
-
item.label=<span>{label}<Badge size='small' count={msgCount} offset={[5,-5]} /></span>
|
|
36
|
-
}
|
|
37
|
-
if(menu.children){
|
|
38
|
-
item.children = translateMenu(menu.children)
|
|
39
|
-
}
|
|
40
|
-
return item;
|
|
41
|
-
})
|
|
42
|
-
return req;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const reload= async ()=>{
|
|
47
|
-
providerMenu.reload();
|
|
48
|
-
}
|
|
49
|
-
useEffect(()=>{
|
|
50
|
-
let menuList = translateMenu(providerMenu.topMenu);
|
|
51
|
-
menuList.forEach(menu=>{
|
|
52
|
-
menu.children=null;//顶级菜单这里设计为不需要展示子菜单
|
|
53
|
-
})
|
|
54
|
-
setMenus(menuList);
|
|
55
|
-
},[providerMenu.topMenu]);
|
|
56
|
-
|
|
57
|
-
useEffect(()=>{
|
|
58
|
-
providerMenu.setUserAuth(app.user.authorities||[]);
|
|
59
|
-
},[app.user])
|
|
60
|
-
|
|
61
|
-
useEffect(()=>{
|
|
62
|
-
reload();
|
|
63
|
-
},[])
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// 推出登录
|
|
67
|
-
const onAvatarClick = (key)=>{
|
|
68
|
-
if(key==='user'){
|
|
69
|
-
app.updateUserInfo();
|
|
70
|
-
}
|
|
71
|
-
else if (key === 'logout') {
|
|
72
|
-
app.logout();
|
|
73
|
-
}else if(key=='relogin'){
|
|
74
|
-
navigate('/superAdminLogin')
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const onHome=()=>{
|
|
78
|
-
navigate('/');
|
|
79
|
-
}
|
|
80
|
-
const onClickMenuItem=(e)=>{
|
|
81
|
-
const { item, key, keyPath, domEvent } = e;
|
|
82
|
-
let menu = providerMenu.findMenuData(key);
|
|
83
|
-
navigate(menu.url);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<section className={styles.topMenu}>
|
|
89
|
-
<div className={styles.left}>
|
|
90
|
-
<span className={styles.title} onClick={onHome}>后管系统</span>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
<div className={styles.center}>
|
|
94
|
-
{
|
|
95
|
-
menus&&menus.length>=1&&
|
|
96
|
-
<Menu
|
|
97
|
-
items={menus}
|
|
98
|
-
mode="horizontal"
|
|
99
|
-
onClick={onClickMenuItem}
|
|
100
|
-
selectedKeys={providerMenu.selectMenus.keys}
|
|
101
|
-
className={styles.menu}
|
|
102
|
-
/>
|
|
103
|
-
}
|
|
104
|
-
</div>
|
|
105
|
-
<div className={styles.right}>
|
|
106
|
-
|
|
107
|
-
<span className={styles.username}>Hi,{app?.user?.username||''}!</span>
|
|
108
|
-
<Dropdown menu={{items:[
|
|
109
|
-
{
|
|
110
|
-
key:'user',
|
|
111
|
-
label:<span onClick={onAvatarClick.bind(this,'user')}><UserOutlined />刷新用户权限</span>
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
key:'relogin',
|
|
115
|
-
label:<span onClick={onAvatarClick.bind(this,'relogin')}><UserOutlined />重新登录</span>
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
key:'logout',
|
|
119
|
-
label:<span onClick={onAvatarClick.bind(this,'logout')}><LogoutOutlined />退出登录</span>
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
]}}>
|
|
123
|
-
<img className={styles.avatar} src={imgAvatar}/>
|
|
124
|
-
</Dropdown>
|
|
125
|
-
|
|
126
|
-
</div>
|
|
127
|
-
|
|
128
|
-
</section>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export default TopMenu;
|