ls-pro-common 1.0.12 → 1.0.15
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/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/http/index.d.ts +12 -6
- package/es/http/index.js +50 -11
- package/es/utils/index.d.ts +3 -1
- package/es/utils/index.js +7 -2
- package/lib/http/index.d.ts +12 -6
- package/lib/http/index.js +50 -11
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.js +7 -2
- package/package.json +2 -2
package/es/http/index.d.ts
CHANGED
|
@@ -3,37 +3,42 @@ declare const request: import("umi-request").RequestMethod<false>;
|
|
|
3
3
|
* get请求
|
|
4
4
|
* @param url 接口
|
|
5
5
|
* @param params 参数{key:value}
|
|
6
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
6
7
|
* @returns Promise<ApiResponse>
|
|
7
8
|
*/
|
|
8
|
-
export declare function httpGet(url: string, params?: Record<string, any
|
|
9
|
+
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
9
10
|
/**
|
|
10
11
|
* post请求
|
|
11
12
|
* @param url 接口
|
|
12
13
|
* @param data 参数{key:value}
|
|
13
14
|
* @param isJson json请求还是form请求,默认为json请求
|
|
15
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
14
16
|
* @returns Promise<ApiResponse>
|
|
15
17
|
*/
|
|
16
|
-
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean): Promise<any>;
|
|
18
|
+
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean): Promise<any>;
|
|
17
19
|
/**
|
|
18
20
|
* put 请求
|
|
19
21
|
* @param url 接口
|
|
20
22
|
* @param data 参数{key:value}
|
|
23
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
21
24
|
* @returns Promise<ApiResponse>
|
|
22
25
|
*/
|
|
23
|
-
export declare function httpPut(url: string, data?: Record<string, any
|
|
26
|
+
export declare function httpPut(url: string, data?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
24
27
|
/**
|
|
25
28
|
* delete 请求
|
|
26
29
|
* @param url 接口
|
|
27
30
|
* @param data 参数[]
|
|
31
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
28
32
|
* @returns Promise<ApiResponse>
|
|
29
33
|
*/
|
|
30
|
-
export declare function httpDelete(url: string, data: any): Promise<any>;
|
|
34
|
+
export declare function httpDelete(url: string, data: any, needGateWay?: boolean): Promise<any>;
|
|
31
35
|
/**
|
|
32
36
|
* 读取数据字典
|
|
33
37
|
* @param dictCode 字典编码
|
|
38
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
34
39
|
* @returns Promise<Record<string,string>>
|
|
35
40
|
*/
|
|
36
|
-
export declare function getDict(dictCode: string, showValue?: boolean): Promise<any>;
|
|
41
|
+
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
37
42
|
/**
|
|
38
43
|
* 加载下拉框的数据源
|
|
39
44
|
* @param url 后端接口
|
|
@@ -41,7 +46,8 @@ export declare function getDict(dictCode: string, showValue?: boolean): Promise<
|
|
|
41
46
|
* @param valueField 值字段
|
|
42
47
|
* @param labelField 显示字段
|
|
43
48
|
* @param showValue 显示值
|
|
49
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
44
50
|
* @returns
|
|
45
51
|
*/
|
|
46
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean): Promise<any>;
|
|
52
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
47
53
|
export default request;
|
package/es/http/index.js
CHANGED
|
@@ -23,7 +23,7 @@ request.interceptors.request.use(function (url, options) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
|
-
url:
|
|
26
|
+
url: url,
|
|
27
27
|
options: opts
|
|
28
28
|
};
|
|
29
29
|
});
|
|
@@ -84,6 +84,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
84
84
|
* get请求
|
|
85
85
|
* @param url 接口
|
|
86
86
|
* @param params 参数{key:value}
|
|
87
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
87
88
|
* @returns Promise<ApiResponse>
|
|
88
89
|
*/
|
|
89
90
|
|
|
@@ -95,23 +96,31 @@ export function httpGet(_x3) {
|
|
|
95
96
|
* @param url 接口
|
|
96
97
|
* @param data 参数{key:value}
|
|
97
98
|
* @param isJson json请求还是form请求,默认为json请求
|
|
99
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
98
100
|
* @returns Promise<ApiResponse>
|
|
99
101
|
*/
|
|
100
102
|
|
|
101
103
|
function _httpGet() {
|
|
102
104
|
_httpGet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url) {
|
|
103
105
|
var params,
|
|
106
|
+
needGateWay,
|
|
104
107
|
_args2 = arguments;
|
|
105
108
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
106
109
|
while (1) {
|
|
107
110
|
switch (_context2.prev = _context2.next) {
|
|
108
111
|
case 0:
|
|
109
112
|
params = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
113
|
+
needGateWay = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
114
|
+
|
|
115
|
+
if (needGateWay) {
|
|
116
|
+
url = toGatewayUrl(url);
|
|
117
|
+
}
|
|
118
|
+
|
|
110
119
|
return _context2.abrupt("return", request.get(url, {
|
|
111
120
|
params: params
|
|
112
121
|
}));
|
|
113
122
|
|
|
114
|
-
case
|
|
123
|
+
case 4:
|
|
115
124
|
case "end":
|
|
116
125
|
return _context2.stop();
|
|
117
126
|
}
|
|
@@ -128,6 +137,7 @@ export function httpPost(_x4) {
|
|
|
128
137
|
* put 请求
|
|
129
138
|
* @param url 接口
|
|
130
139
|
* @param data 参数{key:value}
|
|
140
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
131
141
|
* @returns Promise<ApiResponse>
|
|
132
142
|
*/
|
|
133
143
|
|
|
@@ -135,6 +145,7 @@ function _httpPost() {
|
|
|
135
145
|
_httpPost = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(url) {
|
|
136
146
|
var data,
|
|
137
147
|
isJson,
|
|
148
|
+
needGateWay,
|
|
138
149
|
_args3 = arguments;
|
|
139
150
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
140
151
|
while (1) {
|
|
@@ -142,12 +153,18 @@ function _httpPost() {
|
|
|
142
153
|
case 0:
|
|
143
154
|
data = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
144
155
|
isJson = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
156
|
+
needGateWay = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : true;
|
|
157
|
+
|
|
158
|
+
if (needGateWay) {
|
|
159
|
+
url = toGatewayUrl(url);
|
|
160
|
+
}
|
|
161
|
+
|
|
145
162
|
return _context3.abrupt("return", request.post(url, {
|
|
146
163
|
data: data,
|
|
147
164
|
requestType: isJson ? 'json' : 'form'
|
|
148
165
|
}));
|
|
149
166
|
|
|
150
|
-
case
|
|
167
|
+
case 5:
|
|
151
168
|
case "end":
|
|
152
169
|
return _context3.stop();
|
|
153
170
|
}
|
|
@@ -164,23 +181,31 @@ export function httpPut(_x5) {
|
|
|
164
181
|
* delete 请求
|
|
165
182
|
* @param url 接口
|
|
166
183
|
* @param data 参数[]
|
|
184
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
167
185
|
* @returns Promise<ApiResponse>
|
|
168
186
|
*/
|
|
169
187
|
|
|
170
188
|
function _httpPut() {
|
|
171
189
|
_httpPut = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url) {
|
|
172
190
|
var data,
|
|
191
|
+
needGateWay,
|
|
173
192
|
_args4 = arguments;
|
|
174
193
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
175
194
|
while (1) {
|
|
176
195
|
switch (_context4.prev = _context4.next) {
|
|
177
196
|
case 0:
|
|
178
197
|
data = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
198
|
+
needGateWay = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
|
|
199
|
+
|
|
200
|
+
if (needGateWay) {
|
|
201
|
+
url = toGatewayUrl(url);
|
|
202
|
+
}
|
|
203
|
+
|
|
179
204
|
return _context4.abrupt("return", request.put(url, {
|
|
180
205
|
data: data
|
|
181
206
|
}));
|
|
182
207
|
|
|
183
|
-
case
|
|
208
|
+
case 4:
|
|
184
209
|
case "end":
|
|
185
210
|
return _context4.stop();
|
|
186
211
|
}
|
|
@@ -196,20 +221,29 @@ export function httpDelete(_x6, _x7) {
|
|
|
196
221
|
/**
|
|
197
222
|
* 读取数据字典
|
|
198
223
|
* @param dictCode 字典编码
|
|
224
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
199
225
|
* @returns Promise<Record<string,string>>
|
|
200
226
|
*/
|
|
201
227
|
|
|
202
228
|
function _httpDelete() {
|
|
203
229
|
_httpDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url, data) {
|
|
230
|
+
var needGateWay,
|
|
231
|
+
_args5 = arguments;
|
|
204
232
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
205
233
|
while (1) {
|
|
206
234
|
switch (_context5.prev = _context5.next) {
|
|
207
235
|
case 0:
|
|
236
|
+
needGateWay = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : true;
|
|
237
|
+
|
|
238
|
+
if (needGateWay) {
|
|
239
|
+
url = toGatewayUrl(url);
|
|
240
|
+
}
|
|
241
|
+
|
|
208
242
|
return _context5.abrupt("return", request.delete(url, {
|
|
209
243
|
data: data
|
|
210
244
|
}));
|
|
211
245
|
|
|
212
|
-
case
|
|
246
|
+
case 3:
|
|
213
247
|
case "end":
|
|
214
248
|
return _context5.stop();
|
|
215
249
|
}
|
|
@@ -229,12 +263,14 @@ export function getDict(_x8) {
|
|
|
229
263
|
* @param valueField 值字段
|
|
230
264
|
* @param labelField 显示字段
|
|
231
265
|
* @param showValue 显示值
|
|
266
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
232
267
|
* @returns
|
|
233
268
|
*/
|
|
234
269
|
|
|
235
270
|
function _getDict() {
|
|
236
271
|
_getDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(dictCode) {
|
|
237
272
|
var showValue,
|
|
273
|
+
needGateWay,
|
|
238
274
|
api,
|
|
239
275
|
param,
|
|
240
276
|
_args6 = arguments;
|
|
@@ -243,6 +279,7 @@ function _getDict() {
|
|
|
243
279
|
switch (_context6.prev = _context6.next) {
|
|
244
280
|
case 0:
|
|
245
281
|
showValue = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : true;
|
|
282
|
+
needGateWay = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
246
283
|
api = '/lesoon-integration/sysDictDtl';
|
|
247
284
|
param = {
|
|
248
285
|
where: {
|
|
@@ -250,9 +287,9 @@ function _getDict() {
|
|
|
250
287
|
},
|
|
251
288
|
ifPage: 0
|
|
252
289
|
};
|
|
253
|
-
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue));
|
|
290
|
+
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay));
|
|
254
291
|
|
|
255
|
-
case
|
|
292
|
+
case 5:
|
|
256
293
|
case "end":
|
|
257
294
|
return _context6.stop();
|
|
258
295
|
}
|
|
@@ -269,6 +306,7 @@ export function fetchOptions(_x9, _x10, _x11, _x12) {
|
|
|
269
306
|
function _fetchOptions() {
|
|
270
307
|
_fetchOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param, valueField, labelField) {
|
|
271
308
|
var showValue,
|
|
309
|
+
needGateWay,
|
|
272
310
|
_yield$httpGet,
|
|
273
311
|
_yield$httpGet$rows,
|
|
274
312
|
rows,
|
|
@@ -280,10 +318,11 @@ function _fetchOptions() {
|
|
|
280
318
|
switch (_context7.prev = _context7.next) {
|
|
281
319
|
case 0:
|
|
282
320
|
showValue = _args7.length > 4 && _args7[4] !== undefined ? _args7[4] : true;
|
|
283
|
-
|
|
284
|
-
|
|
321
|
+
needGateWay = _args7.length > 5 && _args7[5] !== undefined ? _args7[5] : true;
|
|
322
|
+
_context7.next = 4;
|
|
323
|
+
return httpGet(url, param, needGateWay);
|
|
285
324
|
|
|
286
|
-
case
|
|
325
|
+
case 4:
|
|
287
326
|
_yield$httpGet = _context7.sent;
|
|
288
327
|
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
289
328
|
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
@@ -297,7 +336,7 @@ function _fetchOptions() {
|
|
|
297
336
|
});
|
|
298
337
|
return _context7.abrupt("return", data);
|
|
299
338
|
|
|
300
|
-
case
|
|
339
|
+
case 9:
|
|
301
340
|
case "end":
|
|
302
341
|
return _context7.stop();
|
|
303
342
|
}
|
package/es/utils/index.d.ts
CHANGED
|
@@ -27,11 +27,13 @@ export declare const isLogin: () => boolean;
|
|
|
27
27
|
* 设置本地缓存
|
|
28
28
|
* @param { String } key 关键字
|
|
29
29
|
* @param { Object } data 值
|
|
30
|
+
* @param { Boolean } session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
30
31
|
*/
|
|
31
|
-
export declare const setCache: (key: string, data: any) => void;
|
|
32
|
+
export declare const setCache: (key: string, data: any, session?: boolean) => void;
|
|
32
33
|
/**
|
|
33
34
|
* 读取本地缓存
|
|
34
35
|
* @param { String } key 关键字
|
|
36
|
+
* @param { boolean } session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
35
37
|
* @returns 关键字对应的值
|
|
36
38
|
*/
|
|
37
39
|
export declare const getCache: any;
|
package/es/utils/index.js
CHANGED
|
@@ -58,23 +58,28 @@ export var isLogin = function isLogin() {
|
|
|
58
58
|
* 设置本地缓存
|
|
59
59
|
* @param { String } key 关键字
|
|
60
60
|
* @param { Object } data 值
|
|
61
|
+
* @param { Boolean } session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
61
62
|
*/
|
|
62
63
|
|
|
63
64
|
export var setCache = function setCache(key, data) {
|
|
65
|
+
var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
66
|
+
|
|
64
67
|
if (_typeof(data) === 'object') {
|
|
65
68
|
data = JSON.stringify(data);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
localStorage.setItem(key, data);
|
|
71
|
+
session ? sessionStorage.setItem(key, data) : localStorage.setItem(key, data);
|
|
69
72
|
};
|
|
70
73
|
/**
|
|
71
74
|
* 读取本地缓存
|
|
72
75
|
* @param { String } key 关键字
|
|
76
|
+
* @param { boolean } session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
73
77
|
* @returns 关键字对应的值
|
|
74
78
|
*/
|
|
75
79
|
|
|
76
80
|
export var getCache = function getCache(key) {
|
|
77
|
-
var
|
|
81
|
+
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
82
|
+
var data = session ? sessionStorage.getItem(key) : localStorage.getItem(key);
|
|
78
83
|
|
|
79
84
|
if (data && (data.startsWith('{') || data.startsWith('['))) {
|
|
80
85
|
data = JSON.parse(data);
|
package/lib/http/index.d.ts
CHANGED
|
@@ -3,37 +3,42 @@ declare const request: import("umi-request").RequestMethod<false>;
|
|
|
3
3
|
* get请求
|
|
4
4
|
* @param url 接口
|
|
5
5
|
* @param params 参数{key:value}
|
|
6
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
6
7
|
* @returns Promise<ApiResponse>
|
|
7
8
|
*/
|
|
8
|
-
export declare function httpGet(url: string, params?: Record<string, any
|
|
9
|
+
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
9
10
|
/**
|
|
10
11
|
* post请求
|
|
11
12
|
* @param url 接口
|
|
12
13
|
* @param data 参数{key:value}
|
|
13
14
|
* @param isJson json请求还是form请求,默认为json请求
|
|
15
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
14
16
|
* @returns Promise<ApiResponse>
|
|
15
17
|
*/
|
|
16
|
-
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean): Promise<any>;
|
|
18
|
+
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean): Promise<any>;
|
|
17
19
|
/**
|
|
18
20
|
* put 请求
|
|
19
21
|
* @param url 接口
|
|
20
22
|
* @param data 参数{key:value}
|
|
23
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
21
24
|
* @returns Promise<ApiResponse>
|
|
22
25
|
*/
|
|
23
|
-
export declare function httpPut(url: string, data?: Record<string, any
|
|
26
|
+
export declare function httpPut(url: string, data?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
24
27
|
/**
|
|
25
28
|
* delete 请求
|
|
26
29
|
* @param url 接口
|
|
27
30
|
* @param data 参数[]
|
|
31
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
28
32
|
* @returns Promise<ApiResponse>
|
|
29
33
|
*/
|
|
30
|
-
export declare function httpDelete(url: string, data: any): Promise<any>;
|
|
34
|
+
export declare function httpDelete(url: string, data: any, needGateWay?: boolean): Promise<any>;
|
|
31
35
|
/**
|
|
32
36
|
* 读取数据字典
|
|
33
37
|
* @param dictCode 字典编码
|
|
38
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
34
39
|
* @returns Promise<Record<string,string>>
|
|
35
40
|
*/
|
|
36
|
-
export declare function getDict(dictCode: string, showValue?: boolean): Promise<any>;
|
|
41
|
+
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
37
42
|
/**
|
|
38
43
|
* 加载下拉框的数据源
|
|
39
44
|
* @param url 后端接口
|
|
@@ -41,7 +46,8 @@ export declare function getDict(dictCode: string, showValue?: boolean): Promise<
|
|
|
41
46
|
* @param valueField 值字段
|
|
42
47
|
* @param labelField 显示字段
|
|
43
48
|
* @param showValue 显示值
|
|
49
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
44
50
|
* @returns
|
|
45
51
|
*/
|
|
46
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean): Promise<any>;
|
|
52
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
47
53
|
export default request;
|
package/lib/http/index.js
CHANGED
|
@@ -42,7 +42,7 @@ request.interceptors.request.use(function (url, options) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return {
|
|
45
|
-
url:
|
|
45
|
+
url: url,
|
|
46
46
|
options: opts
|
|
47
47
|
};
|
|
48
48
|
});
|
|
@@ -103,6 +103,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
103
103
|
* get请求
|
|
104
104
|
* @param url 接口
|
|
105
105
|
* @param params 参数{key:value}
|
|
106
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
106
107
|
* @returns Promise<ApiResponse>
|
|
107
108
|
*/
|
|
108
109
|
|
|
@@ -114,6 +115,7 @@ function httpGet(_x3) {
|
|
|
114
115
|
* @param url 接口
|
|
115
116
|
* @param data 参数{key:value}
|
|
116
117
|
* @param isJson json请求还是form请求,默认为json请求
|
|
118
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
117
119
|
* @returns Promise<ApiResponse>
|
|
118
120
|
*/
|
|
119
121
|
|
|
@@ -121,17 +123,24 @@ function httpGet(_x3) {
|
|
|
121
123
|
function _httpGet() {
|
|
122
124
|
_httpGet = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url) {
|
|
123
125
|
var params,
|
|
126
|
+
needGateWay,
|
|
124
127
|
_args2 = arguments;
|
|
125
128
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
126
129
|
while (1) {
|
|
127
130
|
switch (_context2.prev = _context2.next) {
|
|
128
131
|
case 0:
|
|
129
132
|
params = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
133
|
+
needGateWay = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
134
|
+
|
|
135
|
+
if (needGateWay) {
|
|
136
|
+
url = (0, _utils.toGatewayUrl)(url);
|
|
137
|
+
}
|
|
138
|
+
|
|
130
139
|
return _context2.abrupt("return", request.get(url, {
|
|
131
140
|
params: params
|
|
132
141
|
}));
|
|
133
142
|
|
|
134
|
-
case
|
|
143
|
+
case 4:
|
|
135
144
|
case "end":
|
|
136
145
|
return _context2.stop();
|
|
137
146
|
}
|
|
@@ -148,6 +157,7 @@ function httpPost(_x4) {
|
|
|
148
157
|
* put 请求
|
|
149
158
|
* @param url 接口
|
|
150
159
|
* @param data 参数{key:value}
|
|
160
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
151
161
|
* @returns Promise<ApiResponse>
|
|
152
162
|
*/
|
|
153
163
|
|
|
@@ -156,6 +166,7 @@ function _httpPost() {
|
|
|
156
166
|
_httpPost = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
|
|
157
167
|
var data,
|
|
158
168
|
isJson,
|
|
169
|
+
needGateWay,
|
|
159
170
|
_args3 = arguments;
|
|
160
171
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
161
172
|
while (1) {
|
|
@@ -163,12 +174,18 @@ function _httpPost() {
|
|
|
163
174
|
case 0:
|
|
164
175
|
data = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
165
176
|
isJson = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
177
|
+
needGateWay = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : true;
|
|
178
|
+
|
|
179
|
+
if (needGateWay) {
|
|
180
|
+
url = (0, _utils.toGatewayUrl)(url);
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
return _context3.abrupt("return", request.post(url, {
|
|
167
184
|
data: data,
|
|
168
185
|
requestType: isJson ? 'json' : 'form'
|
|
169
186
|
}));
|
|
170
187
|
|
|
171
|
-
case
|
|
188
|
+
case 5:
|
|
172
189
|
case "end":
|
|
173
190
|
return _context3.stop();
|
|
174
191
|
}
|
|
@@ -185,6 +202,7 @@ function httpPut(_x5) {
|
|
|
185
202
|
* delete 请求
|
|
186
203
|
* @param url 接口
|
|
187
204
|
* @param data 参数[]
|
|
205
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
188
206
|
* @returns Promise<ApiResponse>
|
|
189
207
|
*/
|
|
190
208
|
|
|
@@ -192,17 +210,24 @@ function httpPut(_x5) {
|
|
|
192
210
|
function _httpPut() {
|
|
193
211
|
_httpPut = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(url) {
|
|
194
212
|
var data,
|
|
213
|
+
needGateWay,
|
|
195
214
|
_args4 = arguments;
|
|
196
215
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
197
216
|
while (1) {
|
|
198
217
|
switch (_context4.prev = _context4.next) {
|
|
199
218
|
case 0:
|
|
200
219
|
data = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
220
|
+
needGateWay = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : true;
|
|
221
|
+
|
|
222
|
+
if (needGateWay) {
|
|
223
|
+
url = (0, _utils.toGatewayUrl)(url);
|
|
224
|
+
}
|
|
225
|
+
|
|
201
226
|
return _context4.abrupt("return", request.put(url, {
|
|
202
227
|
data: data
|
|
203
228
|
}));
|
|
204
229
|
|
|
205
|
-
case
|
|
230
|
+
case 4:
|
|
206
231
|
case "end":
|
|
207
232
|
return _context4.stop();
|
|
208
233
|
}
|
|
@@ -218,21 +243,30 @@ function httpDelete(_x6, _x7) {
|
|
|
218
243
|
/**
|
|
219
244
|
* 读取数据字典
|
|
220
245
|
* @param dictCode 字典编码
|
|
246
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
221
247
|
* @returns Promise<Record<string,string>>
|
|
222
248
|
*/
|
|
223
249
|
|
|
224
250
|
|
|
225
251
|
function _httpDelete() {
|
|
226
252
|
_httpDelete = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(url, data) {
|
|
253
|
+
var needGateWay,
|
|
254
|
+
_args5 = arguments;
|
|
227
255
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
228
256
|
while (1) {
|
|
229
257
|
switch (_context5.prev = _context5.next) {
|
|
230
258
|
case 0:
|
|
259
|
+
needGateWay = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : true;
|
|
260
|
+
|
|
261
|
+
if (needGateWay) {
|
|
262
|
+
url = (0, _utils.toGatewayUrl)(url);
|
|
263
|
+
}
|
|
264
|
+
|
|
231
265
|
return _context5.abrupt("return", request.delete(url, {
|
|
232
266
|
data: data
|
|
233
267
|
}));
|
|
234
268
|
|
|
235
|
-
case
|
|
269
|
+
case 3:
|
|
236
270
|
case "end":
|
|
237
271
|
return _context5.stop();
|
|
238
272
|
}
|
|
@@ -252,6 +286,7 @@ function getDict(_x8) {
|
|
|
252
286
|
* @param valueField 值字段
|
|
253
287
|
* @param labelField 显示字段
|
|
254
288
|
* @param showValue 显示值
|
|
289
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
255
290
|
* @returns
|
|
256
291
|
*/
|
|
257
292
|
|
|
@@ -259,6 +294,7 @@ function getDict(_x8) {
|
|
|
259
294
|
function _getDict() {
|
|
260
295
|
_getDict = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(dictCode) {
|
|
261
296
|
var showValue,
|
|
297
|
+
needGateWay,
|
|
262
298
|
api,
|
|
263
299
|
param,
|
|
264
300
|
_args6 = arguments;
|
|
@@ -267,6 +303,7 @@ function _getDict() {
|
|
|
267
303
|
switch (_context6.prev = _context6.next) {
|
|
268
304
|
case 0:
|
|
269
305
|
showValue = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : true;
|
|
306
|
+
needGateWay = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
270
307
|
api = '/lesoon-integration/sysDictDtl';
|
|
271
308
|
param = {
|
|
272
309
|
where: {
|
|
@@ -274,9 +311,9 @@ function _getDict() {
|
|
|
274
311
|
},
|
|
275
312
|
ifPage: 0
|
|
276
313
|
};
|
|
277
|
-
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue));
|
|
314
|
+
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay));
|
|
278
315
|
|
|
279
|
-
case
|
|
316
|
+
case 5:
|
|
280
317
|
case "end":
|
|
281
318
|
return _context6.stop();
|
|
282
319
|
}
|
|
@@ -293,6 +330,7 @@ function fetchOptions(_x9, _x10, _x11, _x12) {
|
|
|
293
330
|
function _fetchOptions() {
|
|
294
331
|
_fetchOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(url, param, valueField, labelField) {
|
|
295
332
|
var showValue,
|
|
333
|
+
needGateWay,
|
|
296
334
|
_yield$httpGet,
|
|
297
335
|
_yield$httpGet$rows,
|
|
298
336
|
rows,
|
|
@@ -304,10 +342,11 @@ function _fetchOptions() {
|
|
|
304
342
|
switch (_context7.prev = _context7.next) {
|
|
305
343
|
case 0:
|
|
306
344
|
showValue = _args7.length > 4 && _args7[4] !== undefined ? _args7[4] : true;
|
|
307
|
-
|
|
308
|
-
|
|
345
|
+
needGateWay = _args7.length > 5 && _args7[5] !== undefined ? _args7[5] : true;
|
|
346
|
+
_context7.next = 4;
|
|
347
|
+
return httpGet(url, param, needGateWay);
|
|
309
348
|
|
|
310
|
-
case
|
|
349
|
+
case 4:
|
|
311
350
|
_yield$httpGet = _context7.sent;
|
|
312
351
|
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
313
352
|
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
@@ -321,7 +360,7 @@ function _fetchOptions() {
|
|
|
321
360
|
});
|
|
322
361
|
return _context7.abrupt("return", data);
|
|
323
362
|
|
|
324
|
-
case
|
|
363
|
+
case 9:
|
|
325
364
|
case "end":
|
|
326
365
|
return _context7.stop();
|
|
327
366
|
}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -27,11 +27,13 @@ export declare const isLogin: () => boolean;
|
|
|
27
27
|
* 设置本地缓存
|
|
28
28
|
* @param { String } key 关键字
|
|
29
29
|
* @param { Object } data 值
|
|
30
|
+
* @param { Boolean } session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
30
31
|
*/
|
|
31
|
-
export declare const setCache: (key: string, data: any) => void;
|
|
32
|
+
export declare const setCache: (key: string, data: any, session?: boolean) => void;
|
|
32
33
|
/**
|
|
33
34
|
* 读取本地缓存
|
|
34
35
|
* @param { String } key 关键字
|
|
36
|
+
* @param { boolean } session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
35
37
|
* @returns 关键字对应的值
|
|
36
38
|
*/
|
|
37
39
|
export declare const getCache: any;
|
package/lib/utils/index.js
CHANGED
|
@@ -117,21 +117,25 @@ var isLogin = function isLogin() {
|
|
|
117
117
|
* 设置本地缓存
|
|
118
118
|
* @param { String } key 关键字
|
|
119
119
|
* @param { Object } data 值
|
|
120
|
+
* @param { Boolean } session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
120
121
|
*/
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
exports.isLogin = isLogin;
|
|
124
125
|
|
|
125
126
|
var setCache = function setCache(key, data) {
|
|
127
|
+
var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
128
|
+
|
|
126
129
|
if ((0, _typeof2.default)(data) === 'object') {
|
|
127
130
|
data = JSON.stringify(data);
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
localStorage.setItem(key, data);
|
|
133
|
+
session ? sessionStorage.setItem(key, data) : localStorage.setItem(key, data);
|
|
131
134
|
};
|
|
132
135
|
/**
|
|
133
136
|
* 读取本地缓存
|
|
134
137
|
* @param { String } key 关键字
|
|
138
|
+
* @param { boolean } session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
135
139
|
* @returns 关键字对应的值
|
|
136
140
|
*/
|
|
137
141
|
|
|
@@ -139,7 +143,8 @@ var setCache = function setCache(key, data) {
|
|
|
139
143
|
exports.setCache = setCache;
|
|
140
144
|
|
|
141
145
|
var getCache = function getCache(key) {
|
|
142
|
-
var
|
|
146
|
+
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
147
|
+
var data = session ? sessionStorage.getItem(key) : localStorage.getItem(key);
|
|
143
148
|
|
|
144
149
|
if (data && (data.startsWith('{') || data.startsWith('['))) {
|
|
145
150
|
data = JSON.parse(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ls-pro-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "ls-pro-common",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antd",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ant-design/icons": "^4.3.0",
|
|
31
|
-
"ls-pro-table": "2.62.
|
|
31
|
+
"ls-pro-table": "2.62.20",
|
|
32
32
|
"ls-pro-form": "1.52.20",
|
|
33
33
|
"@babel/runtime": "^7.16.3",
|
|
34
34
|
"classnames": "^2.2.6",
|