@lambo-design/shared 1.0.0-beta.250 → 1.0.0-beta.252

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.
@@ -83,3 +83,8 @@
83
83
  border: 1px solid var(--ind-border-color);
84
84
  }
85
85
  }
86
+
87
+ ::-webkit-scrollbar {
88
+ width: 14px !important;
89
+ display: block !important;
90
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/shared",
3
- "version": "1.0.0-beta.250",
3
+ "version": "1.0.0-beta.252",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -0,0 +1,11 @@
1
+ let headers = {}
2
+ headers.tenant = {
3
+ tenantCode: 'tenant-code',
4
+ systemType: 'system-type',
5
+ }
6
+
7
+ headers.auth = {
8
+ token: 'token'
9
+ }
10
+
11
+ export default headers
@@ -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
  }
@@ -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/assist.js CHANGED
@@ -88,10 +88,13 @@ export function operateBtn(vm, h, currentRow, operationName, operation, type, pe
88
88
 
89
89
  }
90
90
 
91
- export function operateHref(vm, h, currentRow, operationName, operation, type, permission) {
91
+ export function operateHref(vm, h, currentRow, operationName, operation, type, permission, disabled = false) {
92
92
  let renderOption = {
93
93
  style: {
94
- margin: '0 4px'
94
+ margin: '0 4px',
95
+ color: disabled ? '#ccc' : '',
96
+ cursor: disabled ? 'not-allowed' : '',
97
+ pointerEvents: disabled ? 'none' : ''
95
98
  },
96
99
  on: {
97
100
  'click': () => {
@@ -0,0 +1,23 @@
1
+ import * as CryptoJS from 'crypto-js';
2
+
3
+ const AES_KEY = 'gYj2iqBV5AzxC8H0';
4
+ const AES_IV = 'z5c8fSuHX1PxWtIg';
5
+
6
+ crypto.aes = {
7
+ encrypt(message) {
8
+ return CryptoJS.AES.encrypt(message, AES_KEY, {
9
+ mode: CryptoJS.mode.CBC,
10
+ padding: CryptoJS.pad.Pkcs7,
11
+ iv: AES_IV
12
+ })
13
+ },
14
+ decrypt(ciphertext) {
15
+ return CryptoJS.AES.decrypt(ciphertext, AES_KEY, {
16
+ mode: CryptoJS.mode.CBC,
17
+ padding: CryptoJS.pad.Pkcs7,
18
+ iv: AES_IV
19
+ }).toString(CryptoJS.enc.Utf8)
20
+ }
21
+ }
22
+
23
+ export default crypto.aes;
@@ -0,0 +1,16 @@
1
+ import NodeRSA from "node-rsa";
2
+
3
+ const publicKey = `-----BEGIN PUBLIC KEY-----
4
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyhhlApSAjPWRjzg+wSIfALbrC
5
+ Ti4GVBYYBjfMYKU0O9z6EGQAXSLPW+S4VYm4LKtKXuKoeF441KU2HvnGM63cTIYt
6
+ T4lGbTGeYfsbeWNs1u9G9J+DrfKK8HsVB1IZIqhbMf0x7KGMeoQ2SN4KtbaPIwhl
7
+ IPfXzuLZiCW90l+a/wIDAQAB
8
+ -----END PUBLIC KEY-----`;
9
+
10
+ // 创建NodeRSA实例并指定公钥格式
11
+ const key = new NodeRSA(publicKey, "pkcs8-public");
12
+
13
+ // 加密函数
14
+ function rsa(data) {
15
+ return key.encrypt(data, "base64");
16
+ }