zmdms-utils 0.0.6 → 0.0.8
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/README.md +10 -0
- package/dist/es/baseUrl.d.ts +2 -2
- package/dist/es/baseUrl.js +2 -2
- package/dist/es/common.d.ts +1 -1
- package/dist/es/common.js +26 -8
- package/dist/es/microAppCreator.js +3 -5
- package/dist/es/request.d.ts +9 -0
- package/dist/es/request.js +1 -1
- package/package.json +1 -1
- package/src/baseUrl.ts +2 -2
- package/src/common.ts +22 -7
- package/src/microAppCreator.ts +1 -2
- package/src/request.ts +31 -13
package/README.md
CHANGED
package/dist/es/baseUrl.d.ts
CHANGED
package/dist/es/baseUrl.js
CHANGED
|
@@ -17,8 +17,8 @@ function getBaseUrl(processObj) {
|
|
|
17
17
|
};
|
|
18
18
|
var currentKey = ENV.toLowerCase() || "dev";
|
|
19
19
|
return {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
API_URL: apiBaseUrlObj[currentKey],
|
|
21
|
+
FILE_URL: fileBaseUrlObj[currentKey],
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
package/dist/es/common.d.ts
CHANGED
|
@@ -34,6 +34,6 @@ declare function unescapeString(input: string): string;
|
|
|
34
34
|
* 将内容复制到粘贴板中
|
|
35
35
|
* @param text 需要复制的内容
|
|
36
36
|
*/
|
|
37
|
-
declare function copyToClipboard(text: string): void;
|
|
37
|
+
declare function copyToClipboard(text: string, callback?: any): void;
|
|
38
38
|
|
|
39
39
|
export { addThousedSeparator, copyToClipboard, delay, emitter, parseQueryParams, unescapeString };
|
package/dist/es/common.js
CHANGED
|
@@ -112,14 +112,32 @@ function unescapeString(input) {
|
|
|
112
112
|
* 将内容复制到粘贴板中
|
|
113
113
|
* @param text 需要复制的内容
|
|
114
114
|
*/
|
|
115
|
-
function copyToClipboard(text) {
|
|
116
|
-
var _a;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
function copyToClipboard(text, callback) {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
try {
|
|
118
|
+
if ((navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) && window.isSecureContext) {
|
|
119
|
+
(_b = (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(text)) === null || _b === void 0 ? void 0 : _b.then(function () {
|
|
120
|
+
callback && callback(1);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
var textarea = document.createElement("textarea");
|
|
125
|
+
textarea.value = text;
|
|
126
|
+
document.body.appendChild(textarea);
|
|
127
|
+
textarea.select();
|
|
128
|
+
if (document.execCommand) {
|
|
129
|
+
callback && callback(1);
|
|
130
|
+
document.execCommand("copy");
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
callback && callback(0);
|
|
134
|
+
}
|
|
135
|
+
document.body.removeChild(textarea);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
callback && callback(0);
|
|
140
|
+
}
|
|
123
141
|
}
|
|
124
142
|
|
|
125
143
|
export { addThousedSeparator, copyToClipboard, delay, emitter, parseQueryParams, unescapeString };
|
|
@@ -15,7 +15,7 @@ function initMicroApp(render, microAppOptions) {
|
|
|
15
15
|
return {};
|
|
16
16
|
}
|
|
17
17
|
// 2. 进入微前端环境的运行逻辑
|
|
18
|
-
var microAppKey = microAppOptions.microAppKey
|
|
18
|
+
var microAppKey = microAppOptions.microAppKey; microAppOptions.microAppRoot; var microAppMountHandle = microAppOptions.microAppMountHandle, microAppUnMountHandle = microAppOptions.microAppUnMountHandle;
|
|
19
19
|
// 唯一key没传 给出开发提示
|
|
20
20
|
if (!microAppKey) {
|
|
21
21
|
throw Error("\u6CA1\u6709\u914D\u7F6E\u5FAE\u5E94\u7528\u7684\u552F\u4E00key\u503C\uFF0C\u8FD9\u4F1A\u5BFC\u81F4\u5FAE\u524D\u7AEF\u8FD0\u884C\u51FA\u9519\uFF01");
|
|
@@ -49,12 +49,10 @@ function initMicroApp(render, microAppOptions) {
|
|
|
49
49
|
* 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
|
|
50
50
|
*/
|
|
51
51
|
function unmount(props) {
|
|
52
|
-
var _a;
|
|
53
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
return __generator(this, function (
|
|
55
|
-
console.log("微应用 unmount");
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
console.log("微应用 unmount", props);
|
|
56
55
|
microAppUnMountHandle && microAppUnMountHandle(props);
|
|
57
|
-
(_a = microAppRoot === null || microAppRoot === void 0 ? void 0 : microAppRoot.unmount) === null || _a === void 0 ? void 0 : _a.call(microAppRoot);
|
|
58
56
|
return [2 /*return*/];
|
|
59
57
|
});
|
|
60
58
|
});
|
package/dist/es/request.d.ts
CHANGED
|
@@ -24,8 +24,17 @@ declare class AxiosRequest {
|
|
|
24
24
|
}
|
|
25
25
|
interface IOptions extends AxiosRequestConfig {
|
|
26
26
|
isFormData?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 是否需要携带请求头默认携带
|
|
29
|
+
*/
|
|
27
30
|
isAuth?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 是否对传输数据开启加密模式
|
|
33
|
+
*/
|
|
28
34
|
isCrypto?: boolean | "aes" | "des";
|
|
35
|
+
/**
|
|
36
|
+
* 是否交给实例处理异常
|
|
37
|
+
*/
|
|
29
38
|
isErrorMessage?: boolean;
|
|
30
39
|
}
|
|
31
40
|
interface IOtherOptions {
|
package/dist/es/request.js
CHANGED
|
@@ -52,7 +52,7 @@ var AxiosRequest = /** @class */ (function () {
|
|
|
52
52
|
var _this = this;
|
|
53
53
|
axios.interceptors.response.use(function (response) {
|
|
54
54
|
var _a;
|
|
55
|
-
console.log(response);
|
|
55
|
+
// console.log(response);
|
|
56
56
|
// 对返回数据进行解密后 返回给客户端
|
|
57
57
|
if ((_a = response.config) === null || _a === void 0 ? void 0 : _a.isCrypto) ;
|
|
58
58
|
return response;
|
package/package.json
CHANGED
package/src/baseUrl.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function getBaseUrl(processObj: any) {
|
|
|
22
22
|
const currentKey = ENV.toLowerCase() || "dev";
|
|
23
23
|
|
|
24
24
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
API_URL: apiBaseUrlObj[currentKey],
|
|
26
|
+
FILE_URL: fileBaseUrlObj[currentKey],
|
|
27
27
|
};
|
|
28
28
|
}
|
package/src/common.ts
CHANGED
|
@@ -119,11 +119,26 @@ export function unescapeString(input: string): string {
|
|
|
119
119
|
* 将内容复制到粘贴板中
|
|
120
120
|
* @param text 需要复制的内容
|
|
121
121
|
*/
|
|
122
|
-
export function copyToClipboard(text: string) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
export function copyToClipboard(text: string, callback?: any) {
|
|
123
|
+
try {
|
|
124
|
+
if (navigator?.clipboard && window.isSecureContext) {
|
|
125
|
+
navigator.clipboard?.writeText(text)?.then(() => {
|
|
126
|
+
callback && callback(1);
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
const textarea = document.createElement("textarea");
|
|
130
|
+
textarea.value = text;
|
|
131
|
+
document.body.appendChild(textarea);
|
|
132
|
+
textarea.select();
|
|
133
|
+
if (document.execCommand) {
|
|
134
|
+
callback && callback(1);
|
|
135
|
+
document.execCommand("copy");
|
|
136
|
+
} else {
|
|
137
|
+
callback && callback(0);
|
|
138
|
+
}
|
|
139
|
+
document.body.removeChild(textarea);
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
callback && callback(0);
|
|
143
|
+
}
|
|
129
144
|
}
|
package/src/microAppCreator.ts
CHANGED
|
@@ -63,9 +63,8 @@ export function initMicroApp(render: any, microAppOptions: IMicroAppOptions) {
|
|
|
63
63
|
* 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
|
|
64
64
|
*/
|
|
65
65
|
async function unmount(props: any) {
|
|
66
|
-
console.log("微应用 unmount");
|
|
66
|
+
console.log("微应用 unmount", props);
|
|
67
67
|
microAppUnMountHandle && microAppUnMountHandle(props);
|
|
68
|
-
microAppRoot?.unmount?.();
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
return {
|
package/src/request.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class AxiosRequest {
|
|
|
79
79
|
private interceptorsResponse() {
|
|
80
80
|
axios.interceptors.response.use(
|
|
81
81
|
(response) => {
|
|
82
|
-
console.log(response);
|
|
82
|
+
// console.log(response);
|
|
83
83
|
// 对返回数据进行解密后 返回给客户端
|
|
84
84
|
if ((response.config as any)?.isCrypto) {
|
|
85
85
|
}
|
|
@@ -288,24 +288,42 @@ function transformData(data?: any): any {
|
|
|
288
288
|
|
|
289
289
|
export interface IOptions extends AxiosRequestConfig {
|
|
290
290
|
isFormData?: boolean;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
/**
|
|
292
|
+
* 是否需要携带请求头默认携带
|
|
293
|
+
*/
|
|
294
|
+
isAuth?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* 是否对传输数据开启加密模式
|
|
297
|
+
*/
|
|
298
|
+
isCrypto?: boolean | "aes" | "des";
|
|
299
|
+
/**
|
|
300
|
+
* 是否交给实例处理异常
|
|
301
|
+
*/
|
|
302
|
+
isErrorMessage?: boolean;
|
|
294
303
|
}
|
|
295
304
|
|
|
296
305
|
export interface IOtherOptions {
|
|
297
|
-
|
|
306
|
+
// token过期等 需要跳转到登录页
|
|
307
|
+
jumpCallback?: (status: number) => void;
|
|
308
|
+
// 提示方法 外部传入
|
|
298
309
|
messageWarning?: (
|
|
299
310
|
msg: string,
|
|
300
311
|
duration: number,
|
|
301
312
|
callback?: () => void
|
|
302
|
-
) => void;
|
|
313
|
+
) => void;
|
|
303
314
|
modalConfirm?: (msg: string, callback?: () => void) => void;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
// token相关值
|
|
316
|
+
TenantId?: string;
|
|
317
|
+
// auth值
|
|
318
|
+
Authorization?: string;
|
|
319
|
+
// 超时时间
|
|
320
|
+
timeout?: number;
|
|
321
|
+
// 基础url
|
|
322
|
+
baseURL?: string;
|
|
323
|
+
// 加密实例方法
|
|
324
|
+
crypto?: Crypto;
|
|
325
|
+
// 超时是否需要弹框
|
|
326
|
+
isTimeoutConfirm?: boolean;
|
|
327
|
+
// 超时弹框提示内容
|
|
328
|
+
isTimeoutConfirmStr?: string;
|
|
311
329
|
}
|