zmdms-utils 0.0.73 → 0.0.75

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.
Files changed (67) hide show
  1. package/package.json +4 -2
  2. package/publish.py +12 -0
  3. package/src/index.ts +3 -0
  4. package/src/locales/i18n.ts +18 -0
  5. package/src/locales/index.ts +8 -0
  6. package/src/locales/t-in-non-react.ts +65 -0
  7. package/src/locales/t-options.ts +24 -0
  8. package/src/locales/use-translation.ts +76 -0
  9. package/src/locales//345/244/232/350/257/255/350/250/200.md +1 -0
  10. package/src/math.ts +6 -1
  11. package/src/microAppCreator.ts +47 -8
  12. package/dist/es/_virtual/_commonjsHelpers.js +0 -3
  13. package/dist/es/_virtual/_tslib.js +0 -87
  14. package/dist/es/_virtual/decimal.js +0 -7
  15. package/dist/es/_virtual/parseTimeTest.js +0 -3
  16. package/dist/es/_virtual/test.js +0 -3
  17. package/dist/es/auth.d.ts +0 -9
  18. package/dist/es/auth.js +0 -49
  19. package/dist/es/baseUrl.d.ts +0 -23
  20. package/dist/es/baseUrl.js +0 -50
  21. package/dist/es/canvas.d.ts +0 -6
  22. package/dist/es/canvas.js +0 -14
  23. package/dist/es/common.d.ts +0 -81
  24. package/dist/es/common.js +0 -304
  25. package/dist/es/constants.d.ts +0 -20
  26. package/dist/es/constants.js +0 -33
  27. package/dist/es/crypto.d.ts +0 -51
  28. package/dist/es/crypto.js +0 -97
  29. package/dist/es/file.d.ts +0 -127
  30. package/dist/es/file.js +0 -373
  31. package/dist/es/htmlToPdf.d.ts +0 -44
  32. package/dist/es/htmlToPdf.js +0 -84
  33. package/dist/es/mainApp.d.ts +0 -36
  34. package/dist/es/mainApp.js +0 -44
  35. package/dist/es/math.d.ts +0 -29
  36. package/dist/es/math.js +0 -142
  37. package/dist/es/microAppCreator.d.ts +0 -23
  38. package/dist/es/microAppCreator.js +0 -67
  39. package/dist/es/node_modules/decimal.js/decimal.js +0 -4896
  40. package/dist/es/node_modules/decimal.js/decimal2.js +0 -4930
  41. package/dist/es/node_modules/js-base64/base64.js +0 -273
  42. package/dist/es/node_modules/jwt-decode/build/jwt-decode.esm.js +0 -3
  43. package/dist/es/node_modules/mitt/dist/mitt.js +0 -3
  44. package/dist/es/node_modules/pinyin-pro/dist/index.js +0 -12627
  45. package/dist/es/parseTime.d.ts +0 -29
  46. package/dist/es/parseTime.js +0 -189
  47. package/dist/es/parseTimeTest.js +0 -2
  48. package/dist/es/passwordValidate.d.ts +0 -9
  49. package/dist/es/passwordValidate.js +0 -169
  50. package/dist/es/pdf.d.ts +0 -49
  51. package/dist/es/pdf.js +0 -176
  52. package/dist/es/pinyin.js +0 -1
  53. package/dist/es/print.d.ts +0 -23
  54. package/dist/es/print.js +0 -43
  55. package/dist/es/qiankunUtils.d.ts +0 -13
  56. package/dist/es/qiankunUtils.js +0 -32
  57. package/dist/es/request.d.ts +0 -87
  58. package/dist/es/request.js +0 -308
  59. package/dist/es/src/parseTimeTest.js +0 -288
  60. package/dist/es/src/test.js +0 -245
  61. package/dist/es/test.js +0 -2
  62. package/dist/es/validate.d.ts +0 -26
  63. package/dist/es/validate.js +0 -47
  64. package/dist/es/water.d.ts +0 -53
  65. package/dist/es/water.js +0 -88
  66. package/dist/index.d.ts +0 -21
  67. package/dist/index.js +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -34,12 +34,14 @@
34
34
  "@types/crypto-js": "^4.1.1",
35
35
  "axios": "^1.4.0",
36
36
  "crypto-js": "^4.1.1",
37
- "js-base64": "^3.7.7",
38
37
  "dayjs": "^1.11.10",
39
38
  "html2canvas": "^1.4.1",
39
+ "i18next": "^25.1.2",
40
+ "js-base64": "^3.7.7",
40
41
  "jspdf": "^2.5.1",
41
42
  "print-js": "^1.6.0",
42
43
  "qiankun": "^2.10.8",
44
+ "react-i18next": "^15.5.1",
43
45
  "rimraf": "^4.4.1",
44
46
  "rollup": "^3.20.2",
45
47
  "rollup-plugin-dts": "^5.3.0",
package/publish.py ADDED
@@ -0,0 +1,12 @@
1
+ import os
2
+
3
+ os.system('yarn')
4
+ os.system('npm config set registry https://registry.npmjs.org')
5
+ os.system('yarn config set registry https://registry.yarnpkg.com')
6
+ os.system('npm config set proxy http://127.0.0.1:7890')
7
+ os.system('yarn build')
8
+ os.system('npm publish')
9
+ os.system('npm config set registry https://registry.npmmirror.com')
10
+ os.system('yarn config set registry https://registry.npmmirror.com')
11
+ os.system('npm config rm proxy')
12
+
package/src/index.ts CHANGED
@@ -78,3 +78,6 @@ export { windowPrint, htmlPrint, imgPrint, pdfPrint } from "./print";
78
78
 
79
79
  // 水印相关
80
80
  export { createWater, mergeWaterConfig, getDefaultContent } from "./water";
81
+
82
+ // 多语言相关
83
+ export { initLocale, i18n, useTranslation, Trans, safeT } from "./locales";
@@ -0,0 +1,18 @@
1
+ import i18next from "i18next";
2
+ import { initReactI18next } from "react-i18next";
3
+
4
+ type InitOptions = Parameters<typeof i18next.init>;
5
+
6
+ /**
7
+ * 初始化逻辑
8
+ * - 本函数主要用于初始化 i18next 实例,同时使用 react-i18next 插件进行 react 组件的支持
9
+ * - 本函数的调用时机,一般是在项目的入口文件中进行调用,如 src/main.tsx 中
10
+ * @param options 参数 同i18next.init 第一个参数
11
+ * @param callback 参数 同i18next.init 第二个参数
12
+ * @returns
13
+ */
14
+ function initLocale(options: InitOptions[0], callback?: InitOptions[1]) {
15
+ return i18next.use(initReactI18next).init(options, callback);
16
+ }
17
+
18
+ export { initLocale, i18next as i18n };
@@ -0,0 +1,8 @@
1
+ // i18n实例 及 初始化方法
2
+ export { i18n, initLocale } from "./i18n";
3
+
4
+ // 代理的 useTranslation 函数
5
+ export { useTranslation, Trans } from "./use-translation";
6
+
7
+ // 导出 t 函数(应对在非 react 组件环境下进行使用的场景)
8
+ export { safeT } from "./t-in-non-react";
@@ -0,0 +1,65 @@
1
+ /**
2
+ * t 函数封装:
3
+ * - 本文件的几个 t 函数,主要用于弥补一些在 React 组件之外使用的场景
4
+ * - 常规情况下,在 react 组件中,更加推荐的是使用 react-i18next 包中的 t 函数,即 const { t } = useTranslate(); 形式
5
+ */
6
+ import { i18n } from "./i18n";
7
+ import type { TOpionsEx } from "./t-options";
8
+ import { getTFuncArgs } from "./t-options";
9
+
10
+ /** 包裹一层 try-catch 的 t 函数 */
11
+ const tryT = (
12
+ key: string,
13
+ defaultValueOrOptions: string | TOpionsEx
14
+ ): string => {
15
+ const { defaultValue, options } = getTFuncArgs(defaultValueOrOptions);
16
+ if (!key) {
17
+ // 情况1:键名为空,返回默认值或键名
18
+ console.error(
19
+ `tryT: 请不要传入空 key 值进行 i18n.t 函数执行,这将会导致直接返回空字符串!`
20
+ );
21
+ return defaultValue || key;
22
+ }
23
+ if (!i18n.exists(key)) {
24
+ // 情况2:键名不存在,返回默认值或键名
25
+ console.error(
26
+ `tryT: i18n-key '${key}' 不存在,请检查对应的 @/locales/resources/locales/xx.json 中是否存在对应值`
27
+ );
28
+ return defaultValue || key;
29
+ }
30
+ try {
31
+ // 情况3:尝试执行 i18n.t 函数
32
+ return i18n.t(key, options);
33
+ } catch (err) {
34
+ // 情况4:执行 i18n.t 函数异常,返回默认值或键名
35
+ console.error(`tryT: i18n.t key=${key} 函数执行异常:err=`, err);
36
+ return defaultValue || key;
37
+ }
38
+ };
39
+
40
+ /**
41
+ * 同步版本的 i18n.t 函数(应对在 react 组件外使用的翻译函数)
42
+ * - 如果 i18n 未初始化,则返回默认值或键名
43
+ * - 如果 i18n 初始化后,键名不存在,则返回默认值或键名
44
+ * - 其他正常情况(已经初始化+键名存在),则返回翻译值
45
+ * @description 本函数为在非 react 组件中使用的翻译函数;(在react中请求使用 useTranslate() 返回的 t 函数)
46
+ * @param {string} key
47
+ * @param {TOpionsEx|string} defaultValue 必填值
48
+ * @returns {string}
49
+ * @example
50
+ * const txt = t('someLocaleKey', '兜底默认值');
51
+ */
52
+ export function safeT(
53
+ key: string,
54
+ defaultValueOrOptions: string | TOpionsEx
55
+ ): string {
56
+ if (i18n.isInitialized) {
57
+ return tryT(key, defaultValueOrOptions);
58
+ }
59
+ // 异常情况:没有初始化完成时,返回默认值
60
+ const { defaultValue } = getTFuncArgs(defaultValueOrOptions);
61
+ console.warn(
62
+ `safeT: i18n is not initialized. Returning defaultValue(${defaultValue}) or origin key (${key}).`
63
+ );
64
+ return defaultValue || key;
65
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ import type { TOptions } from "i18next";
3
+
4
+ export interface TOpionsEx extends TOptions {
5
+ defaultValue: string; // 必须填值
6
+ }
7
+
8
+ /**
9
+ * 获取 t 函数的参数
10
+ * @param {string | TOpionsEx} defaultValueOrOptions 默认值或者选项
11
+ * @returns { {defaultValue: string, options: TOpionsEx} } 默认值和选项
12
+ */
13
+ export function getTFuncArgs(defaultValueOrOptions: string | TOpionsEx) {
14
+ let options: TOpionsEx | null = null;
15
+ let defaultValue = "";
16
+ if (typeof defaultValueOrOptions === "string") {
17
+ defaultValue = defaultValueOrOptions;
18
+ options = { defaultValue };
19
+ } else {
20
+ options = defaultValueOrOptions;
21
+ defaultValue = options.defaultValue;
22
+ }
23
+ return { defaultValue, options };
24
+ }
@@ -0,0 +1,76 @@
1
+ import { useTranslation, Trans } from "react-i18next";
2
+ import type { TOpionsEx } from "./t-options";
3
+ import { getTFuncArgs } from "./t-options";
4
+
5
+ type Prams = Parameters<typeof useTranslation>;
6
+ type NS = Prams[0];
7
+ type Options = Prams[1];
8
+
9
+ type EnhanceTFunc = (
10
+ key: string,
11
+ defaultValueOrOptions: string | TOpionsEx
12
+ ) => string;
13
+
14
+ /**
15
+ * 这里只是简单代理一下useTranslation,方便后续扩展或添加其他逻辑
16
+ * @param ns 命名空间 大多数情况下都不需要传入这个参数,除非你用到了命名空间。
17
+ * @param options 其他参数 大多数情况下,都不需要关注这个参数。
18
+ * options.keyPrefix 为所有翻译键添加前缀
19
+ * // JSON 文件:{ "greeting": { "welcome": "Welcome" } }
20
+ * const { t } = useTranslation('common', { keyPrefix: 'greeting' });
21
+ * // 使用时省略前缀
22
+ * t('welcome'); // 等价于 t('greeting:welcome')
23
+ * @returns { t, i18n, ready }
24
+ * t: 翻译方法
25
+ * i18n: i18next实例 访问 i18next 的完整 API(如切换语言、加载命名空间)
26
+ * i18n.changeLanguage('zh-CN'); 使用它切换语言,可以触发组件渲染。但是当前项目中是使用全局刷新的模式,来更新语言的。
27
+ * ready: 是否加载完成
28
+ */
29
+ function useZtTranslation(ns?: NS, options?: Options) {
30
+ const { t: _tOld, i18n, ready } = useTranslation(ns, options);
31
+
32
+ // 扩展t方法,用于处理嵌套的翻译键
33
+ const tEnhance: EnhanceTFunc = (key, defaultValueOrOptions) => {
34
+ const { defaultValue, options } = getTFuncArgs(defaultValueOrOptions);
35
+
36
+ if (!key) {
37
+ // 情况1:键名为空,返回默认值或键名
38
+ console.error(
39
+ `tEnhance: 请不要传入空 key 值进行 t 函数执行,这将会导致直接返回空字符串!`
40
+ );
41
+ return defaultValue || key;
42
+ }
43
+ if (!i18n.exists(key)) {
44
+ // 情况2:键名不存在,返回默认值或键名
45
+ console.error(
46
+ `tEnhance: i18n-key '${key}' 不存在,请检查对应的 @/locales/resources/locales/xx.json 中是否存在对应值`
47
+ );
48
+ return defaultValue || key;
49
+ }
50
+ try {
51
+ return _tOld(key, options);
52
+ } catch (error) {
53
+ console.warn(`tEnhance: t 函数执行异常,请检查! key=${key}, err=`, error);
54
+ return defaultValue || key || "unknown";
55
+ }
56
+ };
57
+
58
+ return {
59
+ /**
60
+ * t函数的使用方式:基本上使用1、2两种方式就可以了。
61
+ * 1、t('key') // 基础用法
62
+ * 2、t('greeting', { name: 'John' }); // 对应 JSON: "greeting": "Hello {{name}}"
63
+ * 3、t('auth:login'); // 显式指定命名空间
64
+ *
65
+ * 关于t函数的第二个参数的说明。
66
+ * 为了防止一些异常情况,翻译失败。可以传入一个默认值。这个默认值就是原本的中文就行。
67
+ * 1、t('key', '默认值');
68
+ * 2、t('key', { defaultValue: '默认值', ...otherOptions });
69
+ */
70
+ t: tEnhance,
71
+ i18n,
72
+ ready,
73
+ };
74
+ }
75
+
76
+ export { useZtTranslation as useTranslation, Trans };
@@ -0,0 +1 @@
1
+ # React 项目多语言
package/src/math.ts CHANGED
@@ -113,7 +113,12 @@ export function exactRound(num: numType, ratio: number) {
113
113
  return 0;
114
114
  // return (0).toFixed(ratio);
115
115
  }
116
- return new Decimal(num).toFixed(ratio);
116
+ let value = new Decimal(num).toFixed(ratio);
117
+ // 设置exactRound去掉小数位后面的0
118
+ if ((window as any).__EXACT_ROUND_TYPE__ === "TRIM_ZEROS") {
119
+ value = Number(value);
120
+ }
121
+ return value;
117
122
  // return Number(num).toFixed(ratio);
118
123
  } catch (err) {
119
124
  return num;
@@ -16,11 +16,32 @@ export function update(props: any) {
16
16
  * @param microAppOptions 微应用的一些配置
17
17
  */
18
18
  export interface IMicroAppOptions {
19
+ /**
20
+ * @deprecated 该属性已废弃,无意义
21
+ */
19
22
  microAppContainerId: string; // 微应用加载的dom容器 id
20
23
  microAppKey: string; // 微应用的唯一key值 用途:1. qiankun下的路由前缀;2. 主、子通信时的标识
24
+ /**
25
+ * @deprecated 该属性已废弃,无意义
26
+ */
21
27
  microAppRoot: any; // 微应用根节点实例
22
- microAppMountHandle?: (props: any) => void; // 微应用每次进入都会调用的方法
23
- microAppUnMountHandle?: (props: any) => void; // 微应用每次切出/卸载 都会调用的方法
28
+ /**
29
+ * 只会在微应用初始化的时候调用一次,下次微应用重新进入时会直接调用 mount 钩子,不会再重复触发 bootstrap
30
+ * 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
31
+ **/
32
+ microAppBootstrapHandle?: () => void;
33
+ /**
34
+ * 应用每次进入都会调用 mount 方法,通常我们在这里触发应用的渲染方法
35
+ */
36
+ microAppMountHandle: (props: any) => void;
37
+ /**
38
+ * 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
39
+ */
40
+ microAppUnMountHandle: (props: any) => void;
41
+ /**
42
+ * 可选生命周期钩子,仅使用 loadMicroApp 方式加载微应用时生效
43
+ */
44
+ microAppUpdateHandle?: (props: any) => void;
24
45
  }
25
46
  export function initMicroApp(render: any, microAppOptions: IMicroAppOptions) {
26
47
  // 初始加载应用
@@ -32,9 +53,10 @@ export function initMicroApp(render: any, microAppOptions: IMicroAppOptions) {
32
53
  // 2. 进入微前端环境的运行逻辑
33
54
  const {
34
55
  microAppKey,
35
- microAppRoot,
56
+ microAppBootstrapHandle,
36
57
  microAppMountHandle,
37
58
  microAppUnMountHandle,
59
+ microAppUpdateHandle,
38
60
  } = microAppOptions;
39
61
 
40
62
  // 唯一key没传 给出开发提示
@@ -47,15 +69,20 @@ export function initMicroApp(render: any, microAppOptions: IMicroAppOptions) {
47
69
  * 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
48
70
  */
49
71
  async function bootstrap() {
50
- console.log("微应用 bootstraped");
72
+ console.log(`微应用==${microAppKey}==bootstraped`);
73
+ if (microAppBootstrapHandle) {
74
+ microAppBootstrapHandle();
75
+ }
51
76
  }
52
77
 
53
78
  /**
54
79
  * 应用每次进入都会调用 mount 方法,通常我们在这里触发应用的渲染方法
55
80
  */
56
81
  async function mount(props: any) {
57
- console.log("微应用 mount");
58
- microAppMountHandle && microAppMountHandle(props);
82
+ console.log(`微应用==${microAppKey}==mount`);
83
+ if (microAppMountHandle) {
84
+ microAppMountHandle(props);
85
+ }
59
86
  render(props);
60
87
  }
61
88
 
@@ -63,13 +90,25 @@ export function initMicroApp(render: any, microAppOptions: IMicroAppOptions) {
63
90
  * 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
64
91
  */
65
92
  async function unmount(props: any) {
66
- console.log("微应用 unmount", props);
67
- microAppUnMountHandle && microAppUnMountHandle(props);
93
+ console.log(`微应用==${microAppKey}==unmount`);
94
+ if (microAppUnMountHandle) {
95
+ microAppUnMountHandle(props);
96
+ }
97
+ }
98
+ /**
99
+ * 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
100
+ */
101
+ async function update(props: any) {
102
+ console.log(`微应用==${microAppKey}==update`);
103
+ if (microAppUpdateHandle) {
104
+ microAppUpdateHandle(props);
105
+ }
68
106
  }
69
107
 
70
108
  return {
71
109
  bootstrap,
72
110
  mount,
73
111
  unmount,
112
+ update,
74
113
  };
75
114
  }
@@ -1,3 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
-
3
- export { commonjsGlobal };
@@ -1,87 +0,0 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- var __assign = function() {
17
- __assign = Object.assign || function __assign(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
-
27
- function __rest(s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- }
38
-
39
- function __awaiter(thisArg, _arguments, P, generator) {
40
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
41
- return new (P || (P = Promise))(function (resolve, reject) {
42
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
43
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
44
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
45
- step((generator = generator.apply(thisArg, _arguments || [])).next());
46
- });
47
- }
48
-
49
- function __generator(thisArg, body) {
50
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
51
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
52
- function verb(n) { return function (v) { return step([n, v]); }; }
53
- function step(op) {
54
- if (f) throw new TypeError("Generator is already executing.");
55
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
56
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
57
- if (y = 0, t) op = [op[0] & 2, t.value];
58
- switch (op[0]) {
59
- case 0: case 1: t = op; break;
60
- case 4: _.label++; return { value: op[1], done: false };
61
- case 5: _.label++; y = op[1]; op = [0]; continue;
62
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
63
- default:
64
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
65
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
66
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
67
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
68
- if (t[2]) _.ops.pop();
69
- _.trys.pop(); continue;
70
- }
71
- op = body.call(thisArg, _);
72
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
73
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
74
- }
75
- }
76
-
77
- function __spreadArray(to, from, pack) {
78
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
79
- if (ar || !(i in from)) {
80
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
81
- ar[i] = from[i];
82
- }
83
- }
84
- return to.concat(ar || Array.prototype.slice.call(from));
85
- }
86
-
87
- export { __assign, __awaiter, __generator, __rest, __spreadArray };
@@ -1,7 +0,0 @@
1
- var decimalExports = {};
2
- var decimal = {
3
- get exports(){ return decimalExports; },
4
- set exports(v){ decimalExports = v; },
5
- };
6
-
7
- export { decimal as __module, decimalExports as exports };
@@ -1,3 +0,0 @@
1
- var parseTimeTest = {};
2
-
3
- export { parseTimeTest as __exports };
@@ -1,3 +0,0 @@
1
- var test = {};
2
-
3
- export { test as __exports };
package/dist/es/auth.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * 权限相关
3
- */
4
- declare function getToken(): string | null;
5
- declare function setToken(token: string): void;
6
- declare function removeToken(): void;
7
- declare function parseToken(token?: string): unknown;
8
-
9
- export { getToken, parseToken, removeToken, setToken };
package/dist/es/auth.js DELETED
@@ -1,49 +0,0 @@
1
- import o from './node_modules/jwt-decode/build/jwt-decode.esm.js';
2
-
3
- /**
4
- * 权限相关
5
- */
6
- function getToken() {
7
- try {
8
- return window.localStorage.getItem("system-token");
9
- }
10
- catch (err) {
11
- console.error("获取token失败", err);
12
- return "";
13
- }
14
- }
15
- function setToken(token) {
16
- try {
17
- window.localStorage.setItem("system-token", token);
18
- }
19
- catch (err) {
20
- console.error("设置token失败", err);
21
- }
22
- }
23
- function removeToken() {
24
- try {
25
- window.localStorage.removeItem("system-token");
26
- }
27
- catch (err) {
28
- console.error("设置token失败", err);
29
- }
30
- }
31
- function parseToken(token) {
32
- var t = token;
33
- if (!t) {
34
- t = getToken();
35
- }
36
- if (t) {
37
- try {
38
- return o(t);
39
- }
40
- catch (err) {
41
- console.log("解析失败", err);
42
- return null;
43
- }
44
- }
45
- // 没有token
46
- return null;
47
- }
48
-
49
- export { getToken, parseToken, removeToken, setToken };
@@ -1,23 +0,0 @@
1
- interface IOptions {
2
- /** 环境变量key值 */
3
- envKey: string;
4
- /** api地址的前缀key */
5
- apiKey: string;
6
- /** 附件服务器前缀key */
7
- fileKey: string;
8
- /** 退出登录默认的key */
9
- logoutKey: string;
10
- /** 数字中心各个环境key值 */
11
- cicomsKey?: string;
12
- /** 外网服务器前缀key值 */
13
- outKey?: string;
14
- }
15
- declare function getBaseUrl(processObj: any, options?: IOptions): {
16
- API_URL: any;
17
- CICOMS_API_URL: any;
18
- FILE_URL: any;
19
- OUTHR_DOMAIN: any;
20
- LOGOUT_URL: any;
21
- };
22
-
23
- export { getBaseUrl };
@@ -1,50 +0,0 @@
1
- // 根据当前环境变量获取基础的URL
2
- function getBaseUrl(processObj, options) {
3
- var _a = options || {}, _b = _a.envKey, envKey = _b === void 0 ? "REACT_APP_ENV" : _b, _c = _a.apiKey, apiKey = _c === void 0 ? "REACT_APP_API" : _c, _d = _a.fileKey, fileKey = _d === void 0 ? "REACT_APP_FILE" : _d, _e = _a.logoutKey, logoutKey = _e === void 0 ? "REACT_APP_LOGOUT" : _e, _f = _a.cicomsKey, cicomsKey = _f === void 0 ? "REACT_APP_CICOMS_API" : _f, _g = _a.outKey, outKey = _g === void 0 ? "REACT_APP_OUTHR_API" : _g;
4
- var ENV = processObj[envKey]; // 获取当前环境变量
5
- // api各个环境地址
6
- var apiBaseUrlObj = {
7
- dev: processObj["".concat(apiKey, "_DEV")] || window.location.origin,
8
- test: processObj["".concat(apiKey, "_TEST")] || window.location.origin,
9
- stage: processObj["".concat(apiKey, "_STAGE")] || window.location.origin,
10
- prod: processObj["".concat(apiKey, "_PROD")] || window.location.origin,
11
- };
12
- // 数字中心各个环境地址
13
- var cicomsApiBaseUrlObj = {
14
- dev: processObj["".concat(cicomsKey, "_DEV")] || window.location.origin,
15
- test: processObj["".concat(cicomsKey, "_TEST")] || window.location.origin,
16
- stage: processObj["".concat(cicomsKey, "_STAGE")] || window.location.origin,
17
- prod: processObj["".concat(cicomsKey, "_PROD")] || window.location.origin,
18
- };
19
- // file 服务器
20
- var fileBaseUrlObj = {
21
- dev: processObj["".concat(fileKey, "_DEV")] || window.location.origin,
22
- test: processObj["".concat(fileKey, "_TEST")] || window.location.origin,
23
- stage: processObj["".concat(fileKey, "_STAGE")] || window.location.origin,
24
- prod: processObj["".concat(fileKey, "_PROD")] || window.location.origin,
25
- };
26
- // 外网项目各个环境地址
27
- var outHrDomain = {
28
- dev: processObj["".concat(outKey, "_DEV")] || "http://192.168.0.134:18886",
29
- test: processObj["".concat(outKey, "_TEST")] || "http://hr-out.cico.com.cn:30601",
30
- stage: processObj["".concat(outKey, "_STAGE")] || "http://10.100.234.36:18886",
31
- prod: processObj["".concat(outKey, "_PROD")] || "https://dhr.cncico.com:18443",
32
- };
33
- // 退出登录地址
34
- var logoutUrl = {
35
- dev: processObj["".concat(logoutKey, "_DEV")] || "/login",
36
- test: processObj["".concat(logoutKey, "_TEST")] || "/login",
37
- stage: processObj["".concat(logoutKey, "_STAGE")] || "http://testportal.cncico.com:8099/",
38
- prod: processObj["".concat(logoutKey, "_PROD")] || "http://newportal.cncico.com/",
39
- };
40
- var currentKey = ENV.toLowerCase() || "prod";
41
- return {
42
- API_URL: apiBaseUrlObj[currentKey] || apiBaseUrlObj["prod"],
43
- CICOMS_API_URL: cicomsApiBaseUrlObj[currentKey] || cicomsApiBaseUrlObj["prod"],
44
- FILE_URL: fileBaseUrlObj[currentKey] || fileBaseUrlObj["prod"],
45
- OUTHR_DOMAIN: outHrDomain[currentKey] || outHrDomain["prod"],
46
- LOGOUT_URL: logoutUrl[currentKey] || logoutUrl["prod"],
47
- };
48
- }
49
-
50
- export { getBaseUrl };
@@ -1,6 +0,0 @@
1
- /**
2
- * dom 转 canvas
3
- */
4
- declare function domToCanvas(dom: HTMLElement): Promise<HTMLCanvasElement>;
5
-
6
- export { domToCanvas };
package/dist/es/canvas.js DELETED
@@ -1,14 +0,0 @@
1
- import html2canvas from 'html2canvas';
2
-
3
- /**
4
- * dom 转 canvas
5
- */
6
- function domToCanvas(dom) {
7
- return html2canvas(dom, {
8
- useCORS: true,
9
- allowTaint: true,
10
- scale: 2, // 用于渲染的比例。默认为浏览器设备像素比 如果dom区域较大,下载会出现部分灰色区域,需要加scale解决
11
- });
12
- }
13
-
14
- export { domToCanvas };