@lambo-design/shared 1.0.0-beta.248 → 1.0.0-beta.249
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/themes/atrovirens/atrovirens.css +576 -576
- package/config/themes/blue/blue.css +576 -576
- package/config/themes/blue-white/blue-white.css +576 -576
- package/config/themes/blue-white-tight/blue-white-tight.css +577 -577
- package/config/themes/danqing/danqing.css +576 -576
- package/config/themes/deep/deep.css +576 -576
- package/config/themes/default/default.css +576 -576
- package/config/themes/eap/eap.css +576 -576
- package/config/themes/gold/gold.css +576 -576
- package/config/themes/lime/lime.css +576 -576
- package/config/themes/orange/orange.css +576 -576
- package/config/themes/red/red.css +576 -576
- package/config/themes/white/white.css +576 -576
- package/package.json +1 -1
- package/utils/ajax/sseFetchUtil.js +104 -104
- package/utils/platform.js +24 -3
package/package.json
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
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
|
-
do {
|
|
18
|
-
({done, value} = await reader.read());
|
|
19
|
-
if (done) {
|
|
20
|
-
this.dispatchEvent('message_finished');
|
|
21
|
-
} else {
|
|
22
|
-
const decoder = new TextDecoder('utf-8');
|
|
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
|
-
this.dispatchEvent('message', { data: data });
|
|
32
|
-
}
|
|
33
|
-
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
34
|
-
this.dispatchEvent('message', { data: line });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
} while (!done);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
connect() {
|
|
43
|
-
fetch(this.url, { ...this.options, method: 'POST' })
|
|
44
|
-
.then(response => {
|
|
45
|
-
if (response.ok && response.body) {
|
|
46
|
-
const reader = response.body.getReader();
|
|
47
|
-
this.read(reader);
|
|
48
|
-
} else {
|
|
49
|
-
throw new Error('Failed to connect to the SSE endpoint.');
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
.catch(error => {
|
|
53
|
-
console.error('Connection error:', error);
|
|
54
|
-
this.dispatchEvent('message_finished',error);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
read(reader) {
|
|
59
|
-
reader.read().then(({done,value}) => {
|
|
60
|
-
if (done) {
|
|
61
|
-
this.dispatchEvent('message_finished');
|
|
62
|
-
} else {
|
|
63
|
-
const decoder = new TextDecoder('utf-8');
|
|
64
|
-
const chunk = decoder.decode(value, { stream: true });
|
|
65
|
-
if (chunk) {
|
|
66
|
-
const lines = chunk.split('\n');
|
|
67
|
-
for (let line of lines) {
|
|
68
|
-
if (line.startsWith('data:')) {
|
|
69
|
-
const data = line.substring(5).trim(); // 去掉 'data:' 前缀
|
|
70
|
-
if (data) {
|
|
71
|
-
this.dispatchEvent('message', { data: data });
|
|
72
|
-
}
|
|
73
|
-
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
74
|
-
this.dispatchEvent('message', { data: line });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.read(reader);
|
|
80
|
-
}
|
|
81
|
-
}).catch(error => {
|
|
82
|
-
console.error('Read error:', error);
|
|
83
|
-
this.dispatchEvent('message_finished',error);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
addEventListener(type, listener) {
|
|
88
|
-
if (!this.listeners[type]) {
|
|
89
|
-
this.listeners[type] = [];
|
|
90
|
-
}
|
|
91
|
-
this.listeners[type].push(listener);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
dispatchEvent(type, event) {
|
|
95
|
-
if (this.listeners[type]) {
|
|
96
|
-
this.listeners[type].forEach(listener => listener(event));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default CustomEventSource;
|
|
102
|
-
export {
|
|
103
|
-
CustomEventSource
|
|
104
|
-
}
|
|
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
|
+
do {
|
|
18
|
+
({done, value} = await reader.read());
|
|
19
|
+
if (done) {
|
|
20
|
+
this.dispatchEvent('message_finished');
|
|
21
|
+
} else {
|
|
22
|
+
const decoder = new TextDecoder('utf-8');
|
|
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
|
+
this.dispatchEvent('message', { data: data });
|
|
32
|
+
}
|
|
33
|
+
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
34
|
+
this.dispatchEvent('message', { data: line });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} while (!done);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
connect() {
|
|
43
|
+
fetch(this.url, { ...this.options, method: 'POST' })
|
|
44
|
+
.then(response => {
|
|
45
|
+
if (response.ok && response.body) {
|
|
46
|
+
const reader = response.body.getReader();
|
|
47
|
+
this.read(reader);
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error('Failed to connect to the SSE endpoint.');
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.catch(error => {
|
|
53
|
+
console.error('Connection error:', error);
|
|
54
|
+
this.dispatchEvent('message_finished',error);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
read(reader) {
|
|
59
|
+
reader.read().then(({done,value}) => {
|
|
60
|
+
if (done) {
|
|
61
|
+
this.dispatchEvent('message_finished');
|
|
62
|
+
} else {
|
|
63
|
+
const decoder = new TextDecoder('utf-8');
|
|
64
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
65
|
+
if (chunk) {
|
|
66
|
+
const lines = chunk.split('\n');
|
|
67
|
+
for (let line of lines) {
|
|
68
|
+
if (line.startsWith('data:')) {
|
|
69
|
+
const data = line.substring(5).trim(); // 去掉 'data:' 前缀
|
|
70
|
+
if (data) {
|
|
71
|
+
this.dispatchEvent('message', { data: data });
|
|
72
|
+
}
|
|
73
|
+
} else if (line.startsWith("{") && line.endsWith("}")) {
|
|
74
|
+
this.dispatchEvent('message', { data: line });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this.read(reader);
|
|
80
|
+
}
|
|
81
|
+
}).catch(error => {
|
|
82
|
+
console.error('Read error:', error);
|
|
83
|
+
this.dispatchEvent('message_finished',error);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
addEventListener(type, listener) {
|
|
88
|
+
if (!this.listeners[type]) {
|
|
89
|
+
this.listeners[type] = [];
|
|
90
|
+
}
|
|
91
|
+
this.listeners[type].push(listener);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
dispatchEvent(type, event) {
|
|
95
|
+
if (this.listeners[type]) {
|
|
96
|
+
this.listeners[type].forEach(listener => listener(event));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default CustomEventSource;
|
|
102
|
+
export {
|
|
103
|
+
CustomEventSource
|
|
104
|
+
}
|
package/utils/platform.js
CHANGED
|
@@ -5,11 +5,32 @@ import systemLogo from '../styles/image/inspur.png';
|
|
|
5
5
|
import {changeByThemeKey, changeThemeByThemeId} from "./theme";
|
|
6
6
|
import ajax from "./ajax";
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export let TOKEN_KEY = "lambo-token"
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export let getTokenKey = function () {
|
|
11
|
+
if (config.tokenKey) {
|
|
12
|
+
return config.tokenKey
|
|
13
|
+
}
|
|
14
|
+
return "lambo-token"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export let COOKIE_KEY = "lambo-sso-key"
|
|
11
18
|
|
|
12
|
-
export
|
|
19
|
+
export let getCookieKey = function () {
|
|
20
|
+
if (config.cookieKey) {
|
|
21
|
+
return config.cookieKey
|
|
22
|
+
}
|
|
23
|
+
return "lambo-sso-key"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export let SSO_TOKEN_KEY = "lambo-sso-token"
|
|
27
|
+
|
|
28
|
+
export let getSsoTokenKey = function () {
|
|
29
|
+
if (config.ssoTokenKey) {
|
|
30
|
+
return config.ssoTokenKey
|
|
31
|
+
}
|
|
32
|
+
return "lambo-sso-token"
|
|
33
|
+
}
|
|
13
34
|
|
|
14
35
|
export function objEqual(obj1, obj2) {
|
|
15
36
|
const keysArr1 = Object.keys(obj1)
|