zmdms-utils 0.0.6 → 0.0.7

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 CHANGED
@@ -1 +1,11 @@
1
1
  ## 公用方法,用于存放一些与框架、平台无关的方法
2
+
3
+ ```
4
+ /**
5
+ * 这种注释不会被删除
6
+ */
7
+
8
+ // 这种注释会被删除
9
+
10
+ /* 这种也会被删除 */
11
+ ```
@@ -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
- var textarea = document.createElement("textarea");
118
- textarea.value = text;
119
- document.body.appendChild(textarea);
120
- textarea.select();
121
- (_a = document === null || document === void 0 ? void 0 : document.execCommand) === null || _a === void 0 ? void 0 : _a.call(document, "copy");
122
- document.body.removeChild(textarea);
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, microAppRoot = microAppOptions.microAppRoot, microAppMountHandle = microAppOptions.microAppMountHandle, microAppUnMountHandle = microAppOptions.microAppUnMountHandle;
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 (_b) {
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
  });
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
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
- const textarea = document.createElement("textarea");
124
- textarea.value = text;
125
- document.body.appendChild(textarea);
126
- textarea.select();
127
- document?.execCommand?.("copy");
128
- document.body.removeChild(textarea);
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
  }
@@ -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
@@ -288,24 +288,42 @@ function transformData(data?: any): any {
288
288
 
289
289
  export interface IOptions extends AxiosRequestConfig {
290
290
  isFormData?: boolean;
291
- isAuth?: boolean; // 是否需要携带请求头 默认携带
292
- isCrypto?: boolean | "aes" | "des"; // 是否对传输数据开启加密模式
293
- isErrorMessage?: boolean; // 是否交给实例处理异常
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
- jumpCallback?: (status: number) => void; // token过期等 需要跳转到登录页
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
- TenantId?: string; // token相关值
305
- Authorization?: string; // auth值
306
- timeout?: number; // 超时时间
307
- baseURL?: string; // 基础url
308
- crypto?: Crypto; // 加密实例方法
309
- isTimeoutConfirm?: boolean; // 超时是否需要弹框
310
- isTimeoutConfirmStr?: string; // 超时弹框提示内容
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
  }