@lambo-design/shared 1.0.0-beta.29 → 1.0.0-beta.291
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/config/config.js +20 -3
- package/config/index.js +7 -2
- package/config/locale.js +61 -0
- package/config/themes/atrovirens/atrovirens.css +578 -0
- package/config/themes/atrovirens/atrovirens.css.map +1 -0
- package/config/themes/atrovirens/atrovirens.less +673 -0
- package/config/themes/atrovirens/var.less +680 -0
- package/config/themes/blue/blue.css +578 -0
- package/config/themes/blue/blue.css.map +1 -0
- package/config/themes/blue/blue.less +675 -0
- package/config/themes/blue/var.less +683 -0
- package/config/themes/blue-white/blue-white.css +582 -0
- package/config/themes/blue-white/blue-white.css.map +1 -0
- package/config/themes/blue-white/blue-white.less +675 -0
- package/config/themes/blue-white/var.less +681 -0
- package/config/themes/blue-white-big/blue-white-big.css +582 -0
- package/config/themes/blue-white-big/blue-white-big.css.map +1 -0
- package/config/themes/blue-white-big/blue-white-big.less +675 -0
- package/config/themes/blue-white-big/var.less +681 -0
- package/config/themes/blue-white-tight/blue-white-tight.css +579 -0
- package/config/themes/blue-white-tight/blue-white-tight.css.map +1 -0
- package/config/themes/blue-white-tight/blue-white-tight.less +676 -0
- package/config/themes/blue-white-tight/var.less +683 -0
- package/config/themes/cuiwei/cuiwei.css +578 -0
- package/config/themes/cuiwei/cuiwei.css.map +10 -0
- package/config/themes/cuiwei/cuiwei.less +673 -0
- package/config/themes/cuiwei/var.less +683 -0
- package/config/themes/danqing/danqing.css +578 -0
- package/config/themes/danqing/danqing.css.map +1 -0
- package/config/themes/danqing/danqing.less +673 -0
- package/config/themes/danqing/danqing.wxss +576 -0
- package/config/themes/danqing/var.less +684 -0
- package/config/themes/deep/deep.css +578 -0
- package/config/themes/deep/deep.css.map +1 -0
- package/config/themes/deep/deep.less +673 -0
- package/config/themes/deep/var.less +683 -0
- package/config/themes/default/default.css +393 -58
- package/config/themes/default/default.css.map +1 -1
- package/config/themes/default/default.less +371 -16
- package/config/themes/default/var.less +380 -11
- package/config/themes/eap/eap.css +578 -0
- package/config/themes/eap/eap.css.map +1 -0
- package/config/themes/eap/eap.less +676 -0
- package/config/themes/eap/var.less +683 -0
- package/config/themes/gold/gold.css +578 -0
- package/config/themes/gold/gold.css.map +1 -0
- package/config/themes/gold/gold.less +676 -0
- package/config/themes/gold/var.less +374 -5
- package/config/themes/index.js +22 -4
- package/config/themes/lime/lime.css +578 -0
- package/config/themes/lime/lime.css.map +1 -0
- package/config/themes/lime/lime.less +676 -0
- package/config/themes/lime/var.less +374 -5
- package/config/themes/orange/orange.css +343 -8
- package/config/themes/orange/orange.css.map +1 -1
- package/config/themes/orange/orange.less +356 -0
- package/config/themes/orange/var.less +375 -5
- package/config/themes/red/red.css +343 -8
- package/config/themes/red/red.css.map +1 -1
- package/config/themes/red/red.less +356 -0
- package/config/themes/red/var.less +374 -5
- package/config/themes/theme-atrovirens.js +564 -0
- package/config/themes/theme-blue.js +564 -0
- package/config/themes/theme-bw.js +568 -0
- package/config/themes/theme-bwb.js +565 -0
- package/config/themes/theme-bwt.js +565 -0
- package/config/themes/theme-cuiwei.js +566 -0
- package/config/themes/theme-danqing.js +570 -0
- package/config/themes/theme-deep.js +564 -0
- package/config/themes/theme-default.js +371 -60
- package/config/themes/theme-eap.js +564 -0
- package/config/themes/theme-gold.js +319 -8
- package/config/themes/theme-lime.js +319 -8
- package/config/themes/theme-orange.js +553 -29
- package/config/themes/theme-red.js +556 -33
- package/config/themes/theme-white.js +564 -0
- package/config/themes/white/var.less +683 -0
- package/config/themes/white/white.css +578 -0
- package/config/themes/white/white.css.map +1 -0
- package/config/themes/white/white.less +675 -0
- package/directives/module/print.js +1 -0
- package/directives/module/vue-print-nb/README.md +63 -0
- package/directives/module/vue-print-nb/print.js +94 -0
- package/directives/module/vue-print-nb/printarea.js +532 -0
- package/index.js +7 -1
- package/nstyles/common.less +197 -0
- package/nstyles/components/404.less +46 -0
- package/nstyles/components/button.less +34 -0
- package/nstyles/components/date-picker.less +41 -0
- package/nstyles/components/drawer.less +20 -0
- package/nstyles/components/dropdown.less +18 -0
- package/nstyles/components/excel-flow.less +72 -0
- package/nstyles/components/form.less +313 -0
- package/nstyles/components/index.less +23 -0
- package/nstyles/components/layout/collect.less +10 -0
- package/nstyles/components/layout/detail-view.less +107 -0
- package/nstyles/components/layout/full-screen.less +7 -0
- package/nstyles/components/layout/index.less +7 -0
- package/nstyles/components/layout/other-menu.less +142 -0
- package/nstyles/components/layout/page-view.less +101 -0
- package/nstyles/components/layout/sider-trigger.less +41 -0
- package/nstyles/components/layout/tags-nav.less +113 -0
- package/nstyles/components/modal.less +90 -0
- package/nstyles/components/n-button.less +131 -0
- package/nstyles/components/n-image-preview.less +131 -0
- package/nstyles/components/n-model/index.less +19 -0
- package/nstyles/components/n-model/report-index.less +43 -0
- package/nstyles/components/n-panel.less +41 -0
- package/nstyles/components/n-picker.less +37 -0
- package/nstyles/components/n-sign.less +17 -0
- package/nstyles/components/n-tooltip.less +10 -0
- package/nstyles/components/panel.less +31 -0
- package/nstyles/components/select.less +3 -0
- package/nstyles/components/sign.less +27 -0
- package/nstyles/components/table.less +318 -0
- package/nstyles/components/tree.less +159 -0
- package/nstyles/components/upload.less +174 -0
- package/nstyles/index.less +5 -0
- package/nstyles/reset.less +73 -0
- package/nstyles/third/ag.less +174 -0
- package/nstyles/third/icons/sort-desc.svg +1 -0
- package/nstyles/third/icons/sort-up.svg +1 -0
- package/nstyles/third/icons/sorting.svg +1 -0
- package/nstyles/third/index.less +11 -0
- package/nstyles/third/view-design.less +375 -0
- package/nstyles/variables/base.less +143 -0
- package/nstyles/variables/index.less +4 -0
- package/nstyles/variables/theme/default/button.less +7 -0
- package/nstyles/variables/theme/default/common.less +57 -0
- package/nstyles/variables/theme/default/index.less +7 -0
- package/nstyles/variables/theme/default/layout.less +40 -0
- package/nstyles/variables/theme/default/table.less +37 -0
- package/nstyles/variables/theme/default/tag.less +3 -0
- package/nstyles/variables/theme/default/upload.less +3 -0
- package/nstyles/variables/theme/index.less +13 -0
- package/nstyles/variables/theme/lsv/button.less +7 -0
- package/nstyles/variables/theme/lsv/common.less +39 -0
- package/nstyles/variables/theme/lsv/index.less +5 -0
- package/nstyles/variables/theme/lsv/layout.less +21 -0
- package/nstyles/variables/theme/lsv/table.less +20 -0
- package/nstyles/variables/theme/lsv/tag.less +3 -0
- package/nstyles/variables/theme/small/button.less +7 -0
- package/nstyles/variables/theme/small/common.less +39 -0
- package/nstyles/variables/theme/small/index.less +5 -0
- package/nstyles/variables/theme/small/layout.less +21 -0
- package/nstyles/variables/theme/small/table.less +17 -0
- package/nstyles/variables/theme/small/tag.less +3 -0
- package/package.json +28 -7
- package/plugin/index.js +12 -0
- package/plugin/module/date-format.js +30 -0
- package/plugin/module/loading.js +26 -0
- package/plugin/module/warn-handler.js +11 -0
- package/styles/image/inspur.png +0 -0
- package/styles/image/lan_navigator.png +0 -0
- package/styles/image/layout-header-bg-cuiwei.png +0 -0
- package/styles/image/lv_navigator.png +0 -0
- package/utils/ajax/content-type.js +30 -0
- package/utils/ajax/headers.js +11 -0
- package/utils/ajax/interceptors.js +12 -4
- package/utils/ajax/sseFetchUtil.js +118 -0
- package/utils/assist.js +155 -27
- package/utils/base64.js +126 -0
- package/utils/blob.js +47 -0
- package/utils/context-menu.js +65 -0
- package/utils/crypto/aes.js +23 -0
- package/utils/crypto/index.js +10 -0
- package/utils/crypto/rsa.js +23 -0
- package/utils/date.js +334 -305
- package/utils/dict/built-in-dict.js +20 -0
- package/utils/dict/index.js +191 -0
- package/utils/event.js +72 -0
- package/utils/excel.js +373 -241
- package/utils/file.js +19 -0
- package/utils/form/validate.js +29 -0
- package/utils/half-year.js +68 -0
- package/utils/index.js +37 -0
- package/utils/json.js +29 -0
- package/utils/locale/en-US.js +169 -0
- package/utils/locale/zh-CN.js +169 -0
- package/utils/lodop.js +5 -0
- package/utils/menu/index.js +292 -15
- package/utils/mime_type.js +67 -0
- package/utils/modelerUtil.js +4 -1
- package/utils/n/api.js +38 -0
- package/utils/n/date.js +57 -0
- package/utils/n/index.js +10 -0
- package/utils/n/is-type.js +176 -0
- package/utils/n/number.js +144 -0
- package/utils/n/permission-cache.js +11 -0
- package/utils/n/reuqest/axiosN.js +17 -0
- package/utils/n/reuqest/content-type.js +19 -0
- package/utils/n/reuqest/interceptors.js +95 -0
- package/utils/n/reuqest/url-params.js +12 -0
- package/utils/n/storage.js +51 -0
- package/utils/n/token.js +51 -0
- package/utils/n/user-cache.js +11 -0
- package/utils/n/user.js +34 -0
- package/utils/n/uuid.js +16 -0
- package/utils/n-generator-routers.js +208 -0
- package/utils/n-router.js +205 -0
- package/utils/n-theme.js +30 -0
- package/utils/number.js +72 -15
- package/utils/oss.js +57 -0
- package/utils/platform.js +824 -30
- package/utils/quarter.js +58 -0
- package/utils/storage.js +198 -0
- package/utils/style.js +24 -0
- package/utils/theme.js +98 -3
- package/utils/transfer-queue.js +7 -0
- package/utils/transform.js +205 -0
- package/utils/type.js +102 -0
- package/utils/util.js +795 -0
- package/utils/vForm.js +349 -0
- package/utils/validator.js +181 -0
- package/config/themes/gold/default.css +0 -243
- package/config/themes/gold/default.css.map +0 -1
- package/config/themes/gold/default.less +0 -320
- package/config/themes/lime/default.css +0 -243
- package/config/themes/lime/default.css.map +0 -1
- package/config/themes/lime/default.less +0 -320
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const contentTypeKey = 'Content-Type'
|
|
2
|
+
|
|
3
|
+
export function getContentType(config) {
|
|
4
|
+
// let type = config?.[contentTypeKey] || config?.['content-type'] || ''
|
|
5
|
+
let type = '';
|
|
6
|
+
|
|
7
|
+
if (config && config[contentTypeKey]) {
|
|
8
|
+
type = config[contentTypeKey];
|
|
9
|
+
} else if (config && config['content-type']) {
|
|
10
|
+
type = config['content-type'];
|
|
11
|
+
}
|
|
12
|
+
const suffixIdx = type.indexOf(';')
|
|
13
|
+
if (suffixIdx !== -1) {
|
|
14
|
+
type = type.substring(0, suffixIdx)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return type
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function setContentType(headers, type) {
|
|
21
|
+
headers[contentTypeKey] = type
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const CONTENT_TYPE = {
|
|
25
|
+
form: 'application/x-www-form-urlencoded',
|
|
26
|
+
multiForm: 'multipart/form-data',
|
|
27
|
+
body: 'application/json',
|
|
28
|
+
os: 'application/octet-stream',
|
|
29
|
+
json: 'application/json',
|
|
30
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import qs from 'qs'
|
|
2
2
|
import cacheRules from "./cacheconf";
|
|
3
|
-
import {getToken,getUrlParams} from '../platform'
|
|
3
|
+
import {getLocalStorage, getToken, getUrlParams} from '../platform'
|
|
4
4
|
import Bus from '../bus';
|
|
5
|
-
|
|
5
|
+
import headers from './headers';
|
|
6
6
|
|
|
7
7
|
let timer1, timer2;
|
|
8
8
|
let hasDialog = false;
|
|
@@ -12,13 +12,21 @@ function requestInterceptors(config) {
|
|
|
12
12
|
|
|
13
13
|
let token = getToken();
|
|
14
14
|
if (token) {
|
|
15
|
-
config.headers.token = token;
|
|
15
|
+
config.headers[headers.auth.token] = token;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let systemType = getLocalStorage('systemType')
|
|
19
|
+
let tenantCode = getLocalStorage('tenantCode')
|
|
20
|
+
|
|
21
|
+
if(systemType && tenantCode){
|
|
22
|
+
config.headers[headers.tenant.tenantCode] = tenantCode;
|
|
23
|
+
config.headers[headers.tenant.systemType] = systemType;
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
//sso_token认证
|
|
19
27
|
if (params.hasOwnProperty('sso_token')||sessionStorage.getItem('sso_token')) {
|
|
20
28
|
config.params = Object.assign({
|
|
21
|
-
sso_token: params.sso_token||sessionStorage.getItem('sso_token')
|
|
29
|
+
sso_token: params.sso_token||sessionStorage.getItem('sso_token'),
|
|
22
30
|
sso_id: params.sso_id
|
|
23
31
|
}, config.params)
|
|
24
32
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
class CustomEventSource {
|
|
2
|
+
constructor(url, options) {
|
|
3
|
+
this.url = url;
|
|
4
|
+
this.options = options || {};
|
|
5
|
+
this.listeners = {};
|
|
6
|
+
this.awaitConnect()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async awaitConnect() {
|
|
10
|
+
const response = await fetch(this.url, { ...this.options, method: 'POST' });
|
|
11
|
+
const reader = response.body.getReader();
|
|
12
|
+
await this.readStream(reader);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async readStream(reader) {
|
|
16
|
+
let done, value, chunk = '';
|
|
17
|
+
const decoder = new TextDecoder('utf-8');
|
|
18
|
+
do {
|
|
19
|
+
({done, value} = await reader.read());
|
|
20
|
+
if (done) {
|
|
21
|
+
this.dispatchEvent('message_finished');
|
|
22
|
+
} else {
|
|
23
|
+
chunk += decoder.decode(value, { stream: true })
|
|
24
|
+
if (chunk && chunk.trim().endsWith("}")) {
|
|
25
|
+
const lines = chunk.split('\n');
|
|
26
|
+
// chunk = '';
|
|
27
|
+
for (let line of lines) {
|
|
28
|
+
if (line.startsWith('data:')) {
|
|
29
|
+
const data = line.substring(5).trim(); // 去掉 'data:' 前缀
|
|
30
|
+
if (data) {
|
|
31
|
+
try {
|
|
32
|
+
const jsonData = JSON.parse(data);
|
|
33
|
+
}catch (e) {
|
|
34
|
+
// 解析失败,说明数据可能不完整,等待更多数据
|
|
35
|
+
console.warn("JSON 解析失败,等待更多数据:", e);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
this.dispatchEvent('message', { data: data });
|
|
39
|
+
}
|
|
40
|
+
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
41
|
+
try {
|
|
42
|
+
const jsonData = JSON.parse(line);
|
|
43
|
+
}catch (e) {
|
|
44
|
+
console.warn("JSON 解析失败,等待更多数据:", e);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
this.dispatchEvent('message', { data: line });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
chunk = '';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} while (!done);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
connect() {
|
|
57
|
+
fetch(this.url, { ...this.options, method: 'POST' })
|
|
58
|
+
.then(response => {
|
|
59
|
+
if (response.ok && response.body) {
|
|
60
|
+
const reader = response.body.getReader();
|
|
61
|
+
this.read(reader);
|
|
62
|
+
} else {
|
|
63
|
+
throw new Error('Failed to connect to the SSE endpoint.');
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch(error => {
|
|
67
|
+
console.error('Connection error:', error);
|
|
68
|
+
this.dispatchEvent('message_finished',error);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
read(reader) {
|
|
73
|
+
reader.read().then(({done,value}) => {
|
|
74
|
+
if (done) {
|
|
75
|
+
this.dispatchEvent('message_finished');
|
|
76
|
+
} else {
|
|
77
|
+
const decoder = new TextDecoder('utf-8');
|
|
78
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
79
|
+
if (chunk) {
|
|
80
|
+
const lines = chunk.split('\n');
|
|
81
|
+
for (let line of lines) {
|
|
82
|
+
if (line.startsWith('data:')) {
|
|
83
|
+
const data = line.substring(5).trim(); // 去掉 'data:' 前缀
|
|
84
|
+
if (data) {
|
|
85
|
+
this.dispatchEvent('message', { data: data });
|
|
86
|
+
}
|
|
87
|
+
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
88
|
+
this.dispatchEvent('message', { data: line });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.read(reader);
|
|
94
|
+
}
|
|
95
|
+
}).catch(error => {
|
|
96
|
+
console.error('Read error:', error);
|
|
97
|
+
this.dispatchEvent('message_finished',error);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
addEventListener(type, listener) {
|
|
102
|
+
if (!this.listeners[type]) {
|
|
103
|
+
this.listeners[type] = [];
|
|
104
|
+
}
|
|
105
|
+
this.listeners[type].push(listener);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
dispatchEvent(type, event) {
|
|
109
|
+
if (this.listeners[type]) {
|
|
110
|
+
this.listeners[type].forEach(listener => listener(event));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default CustomEventSource;
|
|
116
|
+
export {
|
|
117
|
+
CustomEventSource
|
|
118
|
+
}
|
package/utils/assist.js
CHANGED
|
@@ -25,6 +25,23 @@ export function deepCopy(data) {
|
|
|
25
25
|
}
|
|
26
26
|
return o;
|
|
27
27
|
}
|
|
28
|
+
export function deepMerge(target, ...sources) {
|
|
29
|
+
if (!sources.length) return target;
|
|
30
|
+
const source = sources.shift();
|
|
31
|
+
|
|
32
|
+
if (isObject(target) && isObject(source)) {
|
|
33
|
+
for (const key in source) {
|
|
34
|
+
if (isObject(source[key])) {
|
|
35
|
+
if (!target[key]) Object.assign(target, { [key]: {} });
|
|
36
|
+
deepMerge(target[key], source[key]);
|
|
37
|
+
} else {
|
|
38
|
+
Object.assign(target, { [key]: source[key] });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return deepMerge(target, ...sources);
|
|
44
|
+
}
|
|
28
45
|
|
|
29
46
|
export function typeOf(obj) {
|
|
30
47
|
const toString = Object.prototype.toString;
|
|
@@ -43,42 +60,153 @@ export function typeOf(obj) {
|
|
|
43
60
|
return map[toString.call(obj)];
|
|
44
61
|
}
|
|
45
62
|
|
|
46
|
-
export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
on: {
|
|
61
|
-
'click': () => {
|
|
62
|
-
operation(vm, currentRow);
|
|
63
|
-
}
|
|
63
|
+
export function operateBtn(vm, h, currentRow, operationName, operation, type, permission, disabled = false) {
|
|
64
|
+
let renderOption = {
|
|
65
|
+
props: {
|
|
66
|
+
type: type,
|
|
67
|
+
size: "small",
|
|
68
|
+
ghost: true,
|
|
69
|
+
disabled: disabled
|
|
70
|
+
},
|
|
71
|
+
style: {
|
|
72
|
+
margin: '0 2px'
|
|
73
|
+
},
|
|
74
|
+
on: {
|
|
75
|
+
'click': () => {
|
|
76
|
+
operation(vm, currentRow);
|
|
64
77
|
}
|
|
65
|
-
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if(permission){
|
|
81
|
+
renderOption['directives'] = [{
|
|
82
|
+
name: "permission",
|
|
83
|
+
value: permission
|
|
84
|
+
}]
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return h('Button', renderOption, operationName);
|
|
66
88
|
|
|
67
89
|
}
|
|
68
90
|
|
|
69
|
-
export function operateHref(vm, h, currentRow, operationName, operation) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
export function operateHref(vm, h, currentRow, operationName, operation, type, permission, disabled = false) {
|
|
92
|
+
let renderOption = {
|
|
93
|
+
style: {
|
|
94
|
+
margin: '0 4px',
|
|
95
|
+
color: disabled ? '#ccc' : '',
|
|
96
|
+
cursor: disabled ? 'not-allowed' : '',
|
|
97
|
+
pointerEvents: disabled ? 'none' : ''
|
|
98
|
+
},
|
|
74
99
|
on: {
|
|
75
100
|
'click': () => {
|
|
76
101
|
operation(vm, currentRow);
|
|
77
102
|
}
|
|
78
103
|
}
|
|
79
|
-
}
|
|
104
|
+
}
|
|
105
|
+
if(permission){
|
|
106
|
+
renderOption['directives'] = [{
|
|
107
|
+
name: "permission",
|
|
108
|
+
value: permission
|
|
109
|
+
}]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return h('a', renderOption, operationName);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function operateMore(vm, h, operation) {
|
|
116
|
+
return h("Dropdown", {
|
|
117
|
+
style: {
|
|
118
|
+
marginLeft: "4px",
|
|
119
|
+
},
|
|
120
|
+
props: {
|
|
121
|
+
transfer: true,
|
|
122
|
+
}
|
|
123
|
+
}, [
|
|
124
|
+
h("a", {
|
|
125
|
+
style: {
|
|
126
|
+
margin: '0 4px',
|
|
127
|
+
borderBottom: '0px solid #CC9900',
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
h("span", "更多"),
|
|
131
|
+
h("Icon", {
|
|
132
|
+
props: {
|
|
133
|
+
type: "ios-arrow-down"
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
]),
|
|
137
|
+
h('DropdownMenu', {
|
|
138
|
+
slot: "list",
|
|
139
|
+
}, operation)
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function renderTooltip(vm, h, content , { theme= 'dark', maxWidth= 300 }) {
|
|
144
|
+
return h("Tooltip", {
|
|
145
|
+
props: {
|
|
146
|
+
maxWidth: maxWidth,
|
|
147
|
+
theme: theme,
|
|
148
|
+
content: content
|
|
149
|
+
},
|
|
150
|
+
class:"ivu-table-cell-tooltip"
|
|
151
|
+
}, [
|
|
152
|
+
h('span', {
|
|
153
|
+
class:"ivu-table-cell-tooltip-content"
|
|
154
|
+
}, content)
|
|
155
|
+
]);
|
|
80
156
|
}
|
|
81
157
|
|
|
82
158
|
export function isJson(arg) {
|
|
83
|
-
return typeof (arg) == "object" && Object.prototype.toString.call(arg).toLowerCase()
|
|
84
|
-
}
|
|
159
|
+
return typeof (arg) == "object" && Object.prototype.toString.call(arg).toLowerCase() === "[object object]" && !arg.length
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
export function isObject(item) {
|
|
164
|
+
return (item && typeof item === 'object' && !Array.isArray(item));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function copyToClipboard(text){
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
// 现代浏览器方案
|
|
170
|
+
if (navigator.clipboard) {
|
|
171
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
172
|
+
resolve(true);
|
|
173
|
+
}).catch(err => {
|
|
174
|
+
// 现代API失败时尝试传统方案
|
|
175
|
+
fallbackCopy(text, resolve, reject);
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
// 传统浏览器方案
|
|
179
|
+
fallbackCopy(text, resolve, reject);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function fallbackCopy(text, resolve, reject) {
|
|
185
|
+
try {
|
|
186
|
+
const textArea = document.createElement('textarea');
|
|
187
|
+
textArea.value = text;
|
|
188
|
+
textArea.style.position = 'fixed'; // 避免触发滚动
|
|
189
|
+
textArea.style.left = '-9999px';
|
|
190
|
+
textArea.setAttribute('readonly', '');
|
|
191
|
+
document.body.appendChild(textArea);
|
|
192
|
+
textArea.select();
|
|
193
|
+
// 兼容移动端
|
|
194
|
+
if (textArea.setSelectionRange) {
|
|
195
|
+
const range = document.createRange();
|
|
196
|
+
range.selectNodeContents(textArea);
|
|
197
|
+
const sel = window.getSelection();
|
|
198
|
+
sel.removeAllRanges();
|
|
199
|
+
sel.addRange(range);
|
|
200
|
+
textArea.setSelectionRange(0, textArea.value.length);
|
|
201
|
+
}
|
|
202
|
+
const success = document.execCommand('copy');
|
|
203
|
+
document.body.removeChild(textArea);
|
|
204
|
+
if (success) {
|
|
205
|
+
resolve(true);
|
|
206
|
+
} else {
|
|
207
|
+
reject(new Error('复制失败'));
|
|
208
|
+
}
|
|
209
|
+
} catch (err) {
|
|
210
|
+
reject(err);
|
|
211
|
+
}
|
|
212
|
+
}
|
package/utils/base64.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
let Base64 = {
|
|
2
|
+
Base64Chars:
|
|
3
|
+
"abcdefghijklmnopqrstuv" +
|
|
4
|
+
"wxyzABCDEFGHIJKLMNOP" +
|
|
5
|
+
"QRSTUVWXYZ0123456789@*-",
|
|
6
|
+
/**
|
|
7
|
+
* Encode a string to a Base64 string follow Bse64 regular.
|
|
8
|
+
* @param s, a normal string
|
|
9
|
+
* @return a Base64 string
|
|
10
|
+
*/
|
|
11
|
+
encode: function (s) {
|
|
12
|
+
if (!s || s.length == 0) return s;
|
|
13
|
+
|
|
14
|
+
var d = "";
|
|
15
|
+
var b = this.ucs2_utf8(s);
|
|
16
|
+
var b0, b1, b2, b3;
|
|
17
|
+
var len = b.length;
|
|
18
|
+
var i = 0;
|
|
19
|
+
while (i < len) {
|
|
20
|
+
var tmp = b[i++];
|
|
21
|
+
b0 = (tmp & 0xfc) >> 2;
|
|
22
|
+
b1 = (tmp & 0x03) << 4;
|
|
23
|
+
if (i < len) {
|
|
24
|
+
tmp = b[i++];
|
|
25
|
+
b1 |= (tmp & 0xf0) >> 4;
|
|
26
|
+
b2 = (tmp & 0x0f) << 2;
|
|
27
|
+
if (i < len) {
|
|
28
|
+
tmp = b[i++];
|
|
29
|
+
b2 |= (tmp & 0xc0) >> 6;
|
|
30
|
+
b3 = tmp & 0x3f;
|
|
31
|
+
} else {
|
|
32
|
+
b3 = 64; // 1 byte "-" is supplement
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
b2 = b3 = 64; // 2 bytes "-" are supplement
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
d += this.Base64Chars.charAt(b0);
|
|
41
|
+
d += this.Base64Chars.charAt(b1);
|
|
42
|
+
d += this.Base64Chars.charAt(b2);
|
|
43
|
+
d += this.Base64Chars.charAt(b3);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return d;
|
|
47
|
+
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Encodes a ucs2 string to a utf8 integer array.
|
|
52
|
+
* @param s, a string
|
|
53
|
+
* @return an integer array
|
|
54
|
+
*/
|
|
55
|
+
ucs2_utf8: function (s) {
|
|
56
|
+
if (!s) return null;
|
|
57
|
+
var d = new Array();
|
|
58
|
+
if (s == "") return d;
|
|
59
|
+
|
|
60
|
+
var c = 0, i = 0, j = 0;
|
|
61
|
+
var len = s.length;
|
|
62
|
+
while (i < len) {
|
|
63
|
+
c = s.charCodeAt(i++);
|
|
64
|
+
if (c <= 0x7f) {
|
|
65
|
+
// 1 byte
|
|
66
|
+
|
|
67
|
+
d[j++] = c;
|
|
68
|
+
} else if ((c >= 0x80) && (c <= 0x7ff)) {
|
|
69
|
+
// 2 bytes
|
|
70
|
+
|
|
71
|
+
d[j++] = ((c >> 6) & 0x1f) | 0xc0;
|
|
72
|
+
d[j++] = (c & 0x3f) | 0x80;
|
|
73
|
+
} else {
|
|
74
|
+
// 3 bytes
|
|
75
|
+
|
|
76
|
+
d[j++] = (c >> 12) | 0xe0;
|
|
77
|
+
d[j++] = ((c >> 6) & 0x3f) | 0x80;
|
|
78
|
+
d[j++] = (c & 0x3f) | 0x80;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return d;
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* Encodes a utf8 integer array to a ucs2 string.
|
|
86
|
+
* @param s, an integer array
|
|
87
|
+
* @return a string
|
|
88
|
+
*/
|
|
89
|
+
utf8_ucs2: function (s) {
|
|
90
|
+
if (!s) return null;
|
|
91
|
+
var len = s.length;
|
|
92
|
+
if (len == 0) return "";
|
|
93
|
+
|
|
94
|
+
var d = "";
|
|
95
|
+
var c = 0, i = 0, tmp = 0;
|
|
96
|
+
while (i < len) {
|
|
97
|
+
c = s[i++];
|
|
98
|
+
if ((c & 0xe0) == 0xe0) {
|
|
99
|
+
// 3 bytes
|
|
100
|
+
|
|
101
|
+
tmp = (c & 0x0f) << 12;
|
|
102
|
+
c = s[i++];
|
|
103
|
+
tmp |= ((c & 0x3f) << 6);
|
|
104
|
+
c = s[i++];
|
|
105
|
+
tmp |= (c & 0x3f);
|
|
106
|
+
} else if ((c & 0xc0) == 0xc0) {
|
|
107
|
+
// 2 bytes
|
|
108
|
+
|
|
109
|
+
tmp = (c & 0x1f) << 6;
|
|
110
|
+
c = s[i++];
|
|
111
|
+
tmp |= (c & 0x3f);
|
|
112
|
+
} else {
|
|
113
|
+
// 1 byte
|
|
114
|
+
|
|
115
|
+
tmp = c;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
d += String.fromCharCode(tmp);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return d;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
export {
|
|
125
|
+
Base64
|
|
126
|
+
}
|
package/utils/blob.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将base64转换为Blob
|
|
3
|
+
*
|
|
4
|
+
* @param base64Data base64数据
|
|
5
|
+
* @param contentType 数据的MIME Type,如 png 为 image/png
|
|
6
|
+
* @returns Blob数据
|
|
7
|
+
*/
|
|
8
|
+
export function base64ToBlob(base64Data, contentType) {
|
|
9
|
+
contentType = contentType || ''
|
|
10
|
+
const sliceSize = 1024
|
|
11
|
+
const byteCharacters = atob(base64Data)
|
|
12
|
+
const bytesLength = byteCharacters.length
|
|
13
|
+
const slicesCount = Math.ceil(bytesLength / sliceSize)
|
|
14
|
+
const byteArrays = new Array(slicesCount)
|
|
15
|
+
|
|
16
|
+
for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
|
17
|
+
const begin = sliceIndex * sliceSize
|
|
18
|
+
const end = Math.min(begin + sliceSize, bytesLength)
|
|
19
|
+
|
|
20
|
+
const bytes = new Array(end - begin)
|
|
21
|
+
for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
|
|
22
|
+
bytes[i] = byteCharacters[offset].charCodeAt(0)
|
|
23
|
+
}
|
|
24
|
+
byteArrays[sliceIndex] = new Uint8Array(bytes)
|
|
25
|
+
}
|
|
26
|
+
return new Blob(byteArrays, { type: contentType })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function blobToBase64(blob, hasPrefix = true) {
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
const reader = new FileReader()
|
|
32
|
+
reader.onload = function () {
|
|
33
|
+
// const base64Data = (reader?.result || '')
|
|
34
|
+
let base64Data = '';
|
|
35
|
+
if (reader !== null && reader !== undefined) {
|
|
36
|
+
base64Data = reader.result || '';
|
|
37
|
+
}
|
|
38
|
+
if (hasPrefix) {
|
|
39
|
+
resolve(base64Data)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
const base64WithoutPrefix = base64Data.split(',')[1]
|
|
43
|
+
resolve(base64WithoutPrefix)
|
|
44
|
+
}
|
|
45
|
+
reader.readAsDataURL(blob)
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 禁用浏览器右键菜单
|
|
3
|
+
*
|
|
4
|
+
* 此函数会禁用整个文档的右键菜单(上下文菜单)
|
|
5
|
+
* 可以通过传递元素参数来限制禁用范围
|
|
6
|
+
*
|
|
7
|
+
* @param {HTMLElement} [element=document] - 要禁用右键菜单的元素,默认为整个文档
|
|
8
|
+
*/
|
|
9
|
+
export function disableRightClick(element = document) {
|
|
10
|
+
// 添加事件监听器
|
|
11
|
+
element.addEventListener('contextmenu', preventRightClick);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 启用浏览器右键菜单
|
|
17
|
+
*
|
|
18
|
+
* 此函数会移除之前添加的右键菜单禁用
|
|
19
|
+
*
|
|
20
|
+
* @param {HTMLElement} [element=document] - 要重新启用右键菜单的元素
|
|
21
|
+
*/
|
|
22
|
+
export function enableRightClick(element = document) {
|
|
23
|
+
// 移除事件监听器
|
|
24
|
+
element.removeEventListener('contextmenu', preventRightClick);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 禁用右键菜单的事件处理函数
|
|
29
|
+
* 这是一个独立的命名函数,可以被引用和移除
|
|
30
|
+
*/
|
|
31
|
+
function preventRightClick(event) {
|
|
32
|
+
// 阻止默认的右键菜单行为
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
|
|
35
|
+
// 可选:显示自定义提示
|
|
36
|
+
showNotification("右键菜单已被禁用");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 显示通知
|
|
40
|
+
*
|
|
41
|
+
* @param {string} message - 要显示的消息内容
|
|
42
|
+
*/
|
|
43
|
+
function showNotification(message) {
|
|
44
|
+
const notification = document.createElement('div');
|
|
45
|
+
notification.className = 'notification';
|
|
46
|
+
notification.textContent = message;
|
|
47
|
+
notification.id = 'contextmenu';
|
|
48
|
+
let exists = document.getElementById('contextmenu')
|
|
49
|
+
if(!exists){
|
|
50
|
+
document.body.appendChild(notification);
|
|
51
|
+
// 显示通知
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
notification.classList.add('show');
|
|
54
|
+
}, 10);
|
|
55
|
+
|
|
56
|
+
// 2秒后隐藏并移除通知
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
notification.classList.remove('show');
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
document.body.removeChild(notification);
|
|
61
|
+
}, 500);
|
|
62
|
+
}, 2000);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as CryptoJS from 'crypto-js';
|
|
2
|
+
|
|
3
|
+
const AES_KEY = 'gYj2iqBV5AzxC8H0';
|
|
4
|
+
const AES_IV = 'z5c8fSuHX1PxWtIg';
|
|
5
|
+
|
|
6
|
+
let aes = {
|
|
7
|
+
encrypt(message,key = AES_KEY,iv = AES_IV) {
|
|
8
|
+
return CryptoJS.AES.encrypt(message, key, {
|
|
9
|
+
mode: CryptoJS.mode.CBC,
|
|
10
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
11
|
+
iv: iv
|
|
12
|
+
})
|
|
13
|
+
},
|
|
14
|
+
decrypt(ciphertext,key = AES_IV,iv = AES_IV) {
|
|
15
|
+
return CryptoJS.AES.decrypt(ciphertext, key, {
|
|
16
|
+
mode: CryptoJS.mode.CBC,
|
|
17
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
18
|
+
iv: iv
|
|
19
|
+
}).toString(CryptoJS.enc.Utf8)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default aes;
|
package/utils/crypto/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import sm3 from "./sm3";
|
|
2
2
|
import md5 from "./md5";
|
|
3
|
+
import NodeRSA from "node-rsa";
|
|
4
|
+
import {Base64} from '../base64'
|
|
3
5
|
|
|
4
6
|
let crypto = {}
|
|
5
7
|
crypto.sm3 = function (s) {
|
|
@@ -35,4 +37,12 @@ crypto.md5 = function (s, add) {
|
|
|
35
37
|
return md5.MD5(s);
|
|
36
38
|
};
|
|
37
39
|
|
|
40
|
+
crypto.encodePwd = function (s,pk){
|
|
41
|
+
if (!pk) {
|
|
42
|
+
pk = `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDD2iolFHi+6bUh+V6JPr2gFJQsC0QNsq2EwI0MAPlI5AaizBHRVMjX1H73ptuDSiT3QZh4kk74w+eDLyYj4JXo1SvvDw5w378SLhUIDzH0zrlt3oleT3kiPQxC17yM3Os/wrtHO7IC+KGo9qrg+LJFyR/fYYHcyH9i+JAejBEnJQIDAQAB`
|
|
43
|
+
}
|
|
44
|
+
let nodeRSA = new NodeRSA(pk, "pkcs8-public");
|
|
45
|
+
return Base64.encode(nodeRSA.encrypt(s, 'base64'));
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
export default crypto;
|