resolver-egretimp-plus 0.0.10 → 0.0.28
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/dist/h5/index.js +2 -1
- package/dist/h5/index.js.LICENSE.txt +1 -0
- package/dist/theme/element/index.css +1 -1
- package/dist/theme/element/src/components/form.scss +4 -0
- package/dist/web/index.js +1 -1
- package/package.json +7 -3
- package/scripts/webpack.config.js +4 -2
- package/src/api/builtIn.js +4 -0
- package/src/components/helper/button-H5.js +17 -0
- package/src/components/icons/question-filled.vue +3 -2
- package/src/components/loading/index.js +6 -0
- package/src/components/loading/loading.js +98 -0
- package/src/components/loading/loading.scss +74 -0
- package/src/components/loading/loading.vue +89 -0
- package/src/components/packages-H5/CmiButton.vue +1 -1
- package/src/components/packages-H5/CmiCell.vue +4 -3
- package/src/components/packages-web/CustomComponentTabPane.vue +1 -1
- package/src/components/packages-web/CustomComponentTabs.vue +6 -3
- package/src/components/patchComponents-H5.js +2 -2
- package/src/enums/index.js +10 -0
- package/src/hooks/pageConfig.js +51 -1
- package/src/index.jsx +2 -2
- package/src/resolver-H5.vue +18 -2
- package/src/resolver-common.vue +45 -0
- package/src/resolver-web.vue +17 -2
- package/src/theme/element/components/form.scss +4 -0
- package/src/utils/cipher.js +141 -0
- package/src/utils/render.jsx +6 -11
- package/src/utils/request.js +123 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { decrypt as aesDecrypt, encrypt as aesEncrypt } from 'crypto-js/aes';
|
|
2
|
+
import UTF8 from 'crypto-js/enc-utf8';
|
|
3
|
+
import pkcs7 from 'crypto-js/pad-pkcs7';
|
|
4
|
+
import CTR from 'crypto-js/mode-ctr';
|
|
5
|
+
import Base64 from 'crypto-js/enc-base64';
|
|
6
|
+
import MD5 from 'crypto-js/md5';
|
|
7
|
+
import SHA256 from 'crypto-js/sha256';
|
|
8
|
+
import SHA512 from 'crypto-js/sha512';
|
|
9
|
+
|
|
10
|
+
class AesEncryption {
|
|
11
|
+
key;
|
|
12
|
+
iv;
|
|
13
|
+
constructor({ key, iv }) {
|
|
14
|
+
this.key = UTF8.parse(key);
|
|
15
|
+
this.iv = UTF8.parse(iv);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get getOptions() {
|
|
19
|
+
return {
|
|
20
|
+
mode: CTR,
|
|
21
|
+
padding: pkcs7,
|
|
22
|
+
iv: this.iv,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
encrypt(plainText) {
|
|
27
|
+
return aesEncrypt(plainText, this.key, this.getOptions).toString();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
decrypt(cipherText) {
|
|
31
|
+
return aesDecrypt(cipherText, this.key, this.getOptions).toString(UTF8);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Define a singleton class for Base64 encryption
|
|
36
|
+
class Base64Encryption{
|
|
37
|
+
instance;
|
|
38
|
+
|
|
39
|
+
constructor() {}
|
|
40
|
+
|
|
41
|
+
// Get the singleton instance
|
|
42
|
+
// 获取单例实例
|
|
43
|
+
getInstance() {
|
|
44
|
+
if (!Base64Encryption.instance) {
|
|
45
|
+
Base64Encryption.instance = new Base64Encryption();
|
|
46
|
+
}
|
|
47
|
+
return Base64Encryption.instance;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
encrypt(plainText) {
|
|
51
|
+
return UTF8.parse(plainText).toString(Base64);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
decrypt(cipherText) {
|
|
55
|
+
return Base64.parse(cipherText).toString(UTF8);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Define a singleton class for MD5 Hashing
|
|
60
|
+
class MD5Hashing {
|
|
61
|
+
instance;
|
|
62
|
+
|
|
63
|
+
constructor() {}
|
|
64
|
+
|
|
65
|
+
// Get the singleton instance
|
|
66
|
+
// 获取单例实例
|
|
67
|
+
static getInstance() {
|
|
68
|
+
if (!MD5Hashing.instance) {
|
|
69
|
+
MD5Hashing.instance = new MD5Hashing();
|
|
70
|
+
}
|
|
71
|
+
return MD5Hashing.instance;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
hash(plainText) {
|
|
75
|
+
return MD5(plainText).toString();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Define a singleton class for SHA256 Hashing
|
|
80
|
+
class SHA256Hashing {
|
|
81
|
+
static instance;
|
|
82
|
+
|
|
83
|
+
constructor() {}
|
|
84
|
+
|
|
85
|
+
// Get the singleton instance
|
|
86
|
+
// 获取单例实例
|
|
87
|
+
static getInstance() {
|
|
88
|
+
if (!SHA256Hashing.instance) {
|
|
89
|
+
SHA256Hashing.instance = new SHA256Hashing();
|
|
90
|
+
}
|
|
91
|
+
return SHA256Hashing.instance;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
hash(plainText) {
|
|
95
|
+
return SHA256(plainText).toString();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Define a singleton class for SHA512 Hashing
|
|
100
|
+
class SHA512Hashing {
|
|
101
|
+
static instance;
|
|
102
|
+
|
|
103
|
+
constructor() {}
|
|
104
|
+
|
|
105
|
+
// Get the singleton instance
|
|
106
|
+
// 获取单例实例
|
|
107
|
+
static getInstance() {
|
|
108
|
+
if (!SHA512Hashing.instance) {
|
|
109
|
+
SHA512Hashing.instance = new SHA512Hashing();
|
|
110
|
+
}
|
|
111
|
+
return SHA512Hashing.instance;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
hash(plainText) {
|
|
115
|
+
return SHA512(plainText).toString();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class EncryptionFactory {
|
|
120
|
+
static createAesEncryption(params) {
|
|
121
|
+
return new AesEncryption(params);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static createBase64Encryption() {
|
|
125
|
+
return Base64Encryption.getInstance();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export class HashingFactory {
|
|
130
|
+
static createMD5Hashing() {
|
|
131
|
+
return MD5Hashing.getInstance();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static createSHA256Hashing() {
|
|
135
|
+
return SHA256Hashing.getInstance();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static createSHA512Hashing() {
|
|
139
|
+
return SHA512Hashing.getInstance();
|
|
140
|
+
}
|
|
141
|
+
}
|
package/src/utils/render.jsx
CHANGED
|
@@ -660,7 +660,7 @@ function getFormItemMargins(config) {
|
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
function createFormLable(config, lang = 'zh') {
|
|
663
|
-
const
|
|
663
|
+
const ElTooltip = resolveComponent('el-tooltip')
|
|
664
664
|
const elIcon = resolveComponent('el-icon')
|
|
665
665
|
const required = config.requiredFlag === '1'
|
|
666
666
|
return (
|
|
@@ -669,20 +669,15 @@ function createFormLable(config, lang = 'zh') {
|
|
|
669
669
|
{required ? <span style="color: #f5222d; margin-right: 3px">*</span> : null}
|
|
670
670
|
<span>{lang.indexOf('zh') > -1 ? config.metaNameZh : config.metaNameEn}</span>
|
|
671
671
|
</span>
|
|
672
|
-
<
|
|
673
|
-
|
|
674
|
-
width="300"
|
|
675
|
-
trigger="hover"
|
|
672
|
+
<ElTooltip
|
|
673
|
+
effect="dark"
|
|
676
674
|
content={lang.indexOf('zh') > -1 ? config.hintContentZh : config.hintContentEn}
|
|
675
|
+
placement="top"
|
|
677
676
|
>
|
|
678
677
|
{
|
|
679
|
-
|
|
680
|
-
reference: () => {
|
|
681
|
-
return config.hintFlag == '1' ? <span class="label-tip"><elIcon><QuestionFilled /></elIcon></span> : null
|
|
682
|
-
}
|
|
683
|
-
}
|
|
678
|
+
config.hintFlag == '1' ? <span class="label-tip"><elIcon><QuestionFilled /></elIcon></span> : null
|
|
684
679
|
}
|
|
685
|
-
</
|
|
680
|
+
</ElTooltip>
|
|
686
681
|
</div>
|
|
687
682
|
)
|
|
688
683
|
}
|
package/src/utils/request.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import axios from 'axios'
|
|
2
|
+
import qs from 'qs'
|
|
3
|
+
import { AUTH_CODE, NOT_AUTH_APIS, PASSWORD, USER_NAME, USER_TYPE } from '../enums'
|
|
4
|
+
import { LCP_LOGIN, REFRESH_TOKEN } from '../api/builtIn'
|
|
5
|
+
import { HashingFactory } from './cipher'
|
|
6
|
+
import dayjs from 'dayjs'
|
|
2
7
|
|
|
3
8
|
export function generateRequester(config) {
|
|
4
9
|
const interceptors = config?.interceptors || {}
|
|
@@ -7,4 +12,122 @@ export function generateRequester(config) {
|
|
|
7
12
|
service.interceptors.request.use(interceptors?.requestThen, interceptors?.requestCatch)
|
|
8
13
|
service.interceptors.response.use(interceptors?.responseThen, interceptors?.responseCatch)
|
|
9
14
|
return service
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const THRESHOLD_TIME = 1000 * 60 * 10
|
|
18
|
+
let loginToken = ''
|
|
19
|
+
let EXPIRATION_Time = null
|
|
20
|
+
const service = axios.create({
|
|
21
|
+
timeout: 60000 // request timeout
|
|
22
|
+
})
|
|
23
|
+
service.interceptors.request.use(
|
|
24
|
+
config => {
|
|
25
|
+
let data = config.data
|
|
26
|
+
const url = config.url
|
|
27
|
+
if (
|
|
28
|
+
config && config.headers &&
|
|
29
|
+
(
|
|
30
|
+
config.headers['Content-type']?.includes('application/x-www-form-urlencoded')
|
|
31
|
+
)
|
|
32
|
+
) {
|
|
33
|
+
data = qs.stringify(data)
|
|
34
|
+
}
|
|
35
|
+
const reqConfig = {
|
|
36
|
+
...config,
|
|
37
|
+
data
|
|
38
|
+
}
|
|
39
|
+
return new Promise(async (resolve, reject) => {
|
|
40
|
+
try {
|
|
41
|
+
if ((!NOT_AUTH_APIS.includes(url) && !loginToken)) {
|
|
42
|
+
await simulatelogin()
|
|
43
|
+
reqConfig.headers = {
|
|
44
|
+
...(reqConfig.headers || {}),
|
|
45
|
+
Authorization: `Bearer ${loginToken}`
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
if (!NOT_AUTH_APIS.includes(url)) {
|
|
49
|
+
if ((EXPIRATION_Time.getTime() - new Date().getTime()) < THRESHOLD_TIME && REFRESH_TOKEN !== url) {
|
|
50
|
+
await refreshToken()
|
|
51
|
+
reqConfig.headers = {
|
|
52
|
+
...(reqConfig.headers || {}),
|
|
53
|
+
Authorization: `Bearer ${loginToken}`
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
reqConfig.headers = {
|
|
57
|
+
...(reqConfig.headers || {}),
|
|
58
|
+
Authorization: `Bearer ${loginToken}`
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
resolve(reqConfig)
|
|
64
|
+
} catch (error) {
|
|
65
|
+
reject()
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
},
|
|
69
|
+
error => {
|
|
70
|
+
return Promise.reject(error)
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
// response interceptor
|
|
75
|
+
service.interceptors.response.use(
|
|
76
|
+
response => {
|
|
77
|
+
// const { config } = response
|
|
78
|
+
return response
|
|
79
|
+
},
|
|
80
|
+
error => {
|
|
81
|
+
return error
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
export function buildInRequest(url, data, config = {}) {
|
|
86
|
+
const reqConfig = {
|
|
87
|
+
url,
|
|
88
|
+
...config
|
|
89
|
+
}
|
|
90
|
+
const method = String.prototype.toLocaleUpperCase.call((reqConfig.method || (reqConfig.method = 'POST')))
|
|
91
|
+
if (method === 'POST') {
|
|
92
|
+
reqConfig.data = data
|
|
93
|
+
}
|
|
94
|
+
if (method === 'GET') {
|
|
95
|
+
result.params = data
|
|
96
|
+
}
|
|
97
|
+
return service(reqConfig)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function simulatelogin() {
|
|
101
|
+
const MD5HashingInstance = HashingFactory.createMD5Hashing()
|
|
102
|
+
return buildInRequest(LCP_LOGIN, {
|
|
103
|
+
username: USER_NAME,
|
|
104
|
+
password: MD5HashingInstance.hash(PASSWORD),
|
|
105
|
+
userType: USER_TYPE,
|
|
106
|
+
onecode: AUTH_CODE,
|
|
107
|
+
}, {
|
|
108
|
+
headers: {
|
|
109
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
110
|
+
},
|
|
111
|
+
}).then(res => {
|
|
112
|
+
if (res.data && res.data.resultCode === '000000') {
|
|
113
|
+
loginToken = res.data.result.token
|
|
114
|
+
EXPIRATION_Time = dayjs(new Date()).add(2, 'hours').toDate()
|
|
115
|
+
return Promise.resolve(res)
|
|
116
|
+
} else {
|
|
117
|
+
return Promise.reject(res?.data?.resultMessage)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
function refreshToken() {
|
|
124
|
+
return buildInRequest(REFRESH_TOKEN).then(res => {
|
|
125
|
+
if (res.data && res.data.resultCode === '000000') {
|
|
126
|
+
loginToken = res.data.result
|
|
127
|
+
EXPIRATION_Time = dayjs(new Date()).add(2, 'hours').toDate()
|
|
128
|
+
return Promise.resolve(res)
|
|
129
|
+
} else {
|
|
130
|
+
return Promise.reject(res?.data?.resultMessage)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
10
133
|
}
|