@gct-paas/render 0.1.4-dev.11 → 0.1.4-dev.13

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 (46) hide show
  1. package/dist/index.esm.min.js +6189 -0
  2. package/dist/index.min.css +2 -0
  3. package/es/Event/Dependency/controller.mjs +81 -94
  4. package/es/Event/Dependency/displayRule.mjs +65 -67
  5. package/es/Event/Dependency/useDependency.mjs +117 -0
  6. package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
  7. package/es/Event/baseEvent.d.ts +8 -7
  8. package/es/Event/baseEvent.mjs +382 -423
  9. package/es/Event/bizServiceRequest.mjs +28 -40
  10. package/es/Event/eventType.d.ts +1 -1
  11. package/es/Event/eventType.mjs +1 -0
  12. package/es/Event/index.d.ts +4 -3
  13. package/es/Event/index.mjs +5 -0
  14. package/es/Event/utils/appRedis.mjs +39 -49
  15. package/es/Event/utils/globalLoading.mjs +95 -94
  16. package/es/Event/utils/processRovedInfo.mjs +228 -294
  17. package/es/Event/utils/runGlobalByPage.mjs +297 -301
  18. package/es/Event/utils/verificationVar.mjs +32 -38
  19. package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
  20. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  21. package/es/components/HandwritingPad.vue.d.ts +27 -0
  22. package/es/components/HandwritingPad.vue.mjs +7 -0
  23. package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
  24. package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
  25. package/es/components/index.d.ts +2 -0
  26. package/es/components/index.mjs +1 -0
  27. package/es/enums/index.mjs +17 -5
  28. package/es/hooks/useStorageRef.mjs +35 -31
  29. package/es/index.d.ts +1 -0
  30. package/es/index.mjs +20 -21
  31. package/es/register/render-register/render-register.mjs +63 -58
  32. package/es/utils/cacheAdapter.mjs +62 -54
  33. package/es/utils/expression/index.mjs +105 -122
  34. package/es/utils/expression/regularExpression/methods.mjs +426 -567
  35. package/es/utils/field-attrs/basicAttrs.mjs +56 -80
  36. package/es/utils/field-attrs/index.mjs +16 -13
  37. package/es/utils/get-ref-data.mjs +41 -59
  38. package/es/utils/getFieldSchema.mjs +66 -80
  39. package/es/utils/index.d.ts +2 -2
  40. package/es/utils/index.mjs +6 -0
  41. package/es/utils/model-transformer.mjs +74 -64
  42. package/es/utils/useStyle.mjs +20 -16
  43. package/package.json +10 -10
  44. package/dist/index.esm.min.mjs +0 -7042
  45. package/dist/index.min.cjs +0 -17
  46. package/dist/index.system.min.js +0 -17
@@ -1,42 +1,36 @@
1
- import { GLOBAL_VAR_TYPE } from '@gct-paas/core';
2
- import dayjs from 'dayjs';
3
-
4
- const verificationMap = {
5
- [GLOBAL_VAR_TYPE.DATE]: {
6
- callback(value) {
7
- return dayjs(value, ["YYYY-MM-DD", "YYYY/MM/DD"], true).isValid();
8
- },
9
- message: "日期变量格式为YYYY-MM-DD,YYYY/MM/DD"
10
- },
11
- [GLOBAL_VAR_TYPE.TIME]: {
12
- callback(value) {
13
- return dayjs(value, "HH:mm:ss", true).isValid();
14
- },
15
- message: "时间变量格式HH:mm:ss"
16
- },
17
- [GLOBAL_VAR_TYPE.DATETIME]: {
18
- callback(value) {
19
- return dayjs(value, [
20
- "YYYY-MM-DD HH:mm:ss",
21
- "YYYY/MM/DD HH:mm:ss"
22
- ]).isValid();
23
- },
24
- message: "日期时间变量格式为YYYY-MM-DD HH:mm:ss,YYYY/MM/DD HH:mm:ss"
25
- }
1
+ import { GLOBAL_VAR_TYPE } from "@gct-paas/core";
2
+ import dayjs from "dayjs";
3
+ //#region src/Event/utils/verificationVar.ts
4
+ var verificationMap = {
5
+ [GLOBAL_VAR_TYPE.DATE]: {
6
+ callback(value) {
7
+ return dayjs(value, ["YYYY-MM-DD", "YYYY/MM/DD"], true).isValid();
8
+ },
9
+ message: "日期变量格式为YYYY-MM-DD,YYYY/MM/DD"
10
+ },
11
+ [GLOBAL_VAR_TYPE.TIME]: {
12
+ callback(value) {
13
+ return dayjs(value, "HH:mm:ss", true).isValid();
14
+ },
15
+ message: "时间变量格式HH:mm:ss"
16
+ },
17
+ [GLOBAL_VAR_TYPE.DATETIME]: {
18
+ callback(value) {
19
+ return dayjs(value, ["YYYY-MM-DD HH:mm:ss", "YYYY/MM/DD HH:mm:ss"]).isValid();
20
+ },
21
+ message: "日期时间变量格式为YYYY-MM-DD HH:mm:ss,YYYY/MM/DD HH:mm:ss"
22
+ }
26
23
  };
27
24
  function verificationData(value, type) {
28
- if (type === GLOBAL_VAR_TYPE.NULL) {
29
- return true;
30
- }
31
- const { callback, message } = verificationMap[type] || {
32
- callback(v) {
33
- return Object.prototype.toString.call(v).slice(8, -1).toLowerCase() === type;
34
- }};
35
- if (callback(value)) {
36
- return Promise.resolve();
37
- } else {
38
- return Promise.reject(message);
39
- }
25
+ if (type === GLOBAL_VAR_TYPE.NULL) return true;
26
+ const { callback, message } = verificationMap[type] || {
27
+ callback(v) {
28
+ return Object.prototype.toString.call(v).slice(8, -1).toLowerCase() === type;
29
+ },
30
+ value: "变量值必须为" + type
31
+ };
32
+ if (callback(value)) return Promise.resolve();
33
+ else return Promise.reject(message);
40
34
  }
41
-
35
+ //#endregion
42
36
  export { verificationData };
@@ -0,0 +1,8 @@
1
+ //#region \0plugin-vue:export-helper
2
+ var _plugin_vue_export_helper_default = (sfc, props) => {
3
+ const target = sfc.__vccOpts || sfc;
4
+ for (const [key, val] of props) target[key] = val;
5
+ return target;
6
+ };
7
+ //#endregion
8
+ export { _plugin_vue_export_helper_default as default };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -0,0 +1,27 @@
1
+ type __VLS_Props = {
2
+ width?: number;
3
+ height?: number;
4
+ backgroundColor?: string;
5
+ lineWidth?: number;
6
+ strokeStyle?: string;
7
+ };
8
+ /** 清空 */
9
+ declare function clear(): void;
10
+ /** 获取签名 */
11
+ declare function getValue(): string | undefined;
12
+ /** 回显 */
13
+ declare function setValue(base64: string): void;
14
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {
15
+ getValue: typeof getValue;
16
+ setValue: typeof setValue;
17
+ clear: typeof clear;
18
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
19
+ width: number;
20
+ height: number;
21
+ backgroundColor: string;
22
+ lineWidth: number;
23
+ strokeStyle: string;
24
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
25
+ canvasRef: HTMLCanvasElement;
26
+ }, HTMLDivElement>;
27
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default from "./HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs";
2
+ import './HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css';/* empty css */
3
+ import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-helper.mjs";
4
+ //#region src/components/HandwritingPad.vue
5
+ var HandwritingPad_default = /* @__PURE__ */ _plugin_vue_export_helper_default(HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default, [["__scopeId", "data-v-d5b980b7"]]);
6
+ //#endregion
7
+ export { HandwritingPad_default as default };
@@ -0,0 +1,109 @@
1
+ import { createElementBlock, createElementVNode, defineComponent, onMounted, openBlock, ref } from "vue";
2
+ //#region src/components/HandwritingPad.vue?vue&type=script&setup=true&name=HandwritingPad&lang.ts
3
+ var _hoisted_1 = { class: "handwriting-pad" };
4
+ var _hoisted_2 = ["width", "height"];
5
+ var HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default = /* @__PURE__ */ defineComponent({
6
+ __name: "HandwritingPad",
7
+ props: {
8
+ width: { default: 300 },
9
+ height: { default: 150 },
10
+ backgroundColor: { default: "transparent" },
11
+ lineWidth: { default: 2 },
12
+ strokeStyle: { default: "#000" }
13
+ },
14
+ setup(__props, { expose: __expose }) {
15
+ const props = __props;
16
+ const canvasRef = ref(null);
17
+ let ctx = null;
18
+ let isDrawing = false;
19
+ let startX = 0;
20
+ let startY = 0;
21
+ onMounted(() => {
22
+ ctx = canvasRef.value.getContext("2d");
23
+ if (props.backgroundColor !== "transparent") {
24
+ ctx.fillStyle = props.backgroundColor;
25
+ ctx.fillRect(0, 0, props.width, props.height);
26
+ }
27
+ ctx.lineWidth = props.lineWidth;
28
+ ctx.strokeStyle = props.strokeStyle;
29
+ });
30
+ /** 统一坐标获取 */
31
+ function getPoint(e) {
32
+ const rect = canvasRef.value.getBoundingClientRect();
33
+ if ("touches" in e) return {
34
+ x: e.touches[0].clientX - rect.left,
35
+ y: e.touches[0].clientY - rect.top
36
+ };
37
+ return {
38
+ x: e.offsetX,
39
+ y: e.offsetY
40
+ };
41
+ }
42
+ function start(e) {
43
+ e.preventDefault();
44
+ isDrawing = true;
45
+ const { x, y } = getPoint(e);
46
+ startX = x;
47
+ startY = y;
48
+ }
49
+ function move(e) {
50
+ if (!isDrawing || !ctx) return;
51
+ e.preventDefault();
52
+ const { x, y } = getPoint(e);
53
+ ctx.beginPath();
54
+ ctx.moveTo(startX, startY);
55
+ ctx.lineTo(x, y);
56
+ ctx.stroke();
57
+ ctx.closePath();
58
+ startX = x;
59
+ startY = y;
60
+ }
61
+ function end(e) {
62
+ e.preventDefault();
63
+ isDrawing = false;
64
+ }
65
+ /** 清空 */
66
+ function clear() {
67
+ ctx?.clearRect(0, 0, props.width, props.height);
68
+ if (props.backgroundColor !== "transparent") {
69
+ ctx.fillStyle = props.backgroundColor;
70
+ ctx.fillRect(0, 0, props.width, props.height);
71
+ }
72
+ }
73
+ /** 获取签名 */
74
+ function getValue() {
75
+ return canvasRef.value?.toDataURL();
76
+ }
77
+ /** 回显 */
78
+ function setValue(base64) {
79
+ const img = new Image();
80
+ img.src = base64;
81
+ img.onload = () => {
82
+ ctx?.drawImage(img, 0, 0);
83
+ };
84
+ }
85
+ __expose({
86
+ getValue,
87
+ setValue,
88
+ clear
89
+ });
90
+ return (_ctx, _cache) => {
91
+ return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("canvas", {
92
+ ref_key: "canvasRef",
93
+ ref: canvasRef,
94
+ width: __props.width,
95
+ height: __props.height,
96
+ class: "canvas",
97
+ onMousedown: start,
98
+ onMousemove: move,
99
+ onMouseup: end,
100
+ onMouseleave: end,
101
+ onTouchstart: start,
102
+ onTouchmove: move,
103
+ onTouchend: end
104
+ }, null, 40, _hoisted_2)]);
105
+ };
106
+ }
107
+ });
108
+ //#endregion
109
+ export { HandwritingPad_vue_vue_type_script_setup_true_name_HandwritingPad_lang_default as default };
@@ -0,0 +1,9 @@
1
+
2
+ .handwriting-pad[data-v-d5b980b7] {
3
+ display: inline-block;
4
+ }
5
+ .canvas[data-v-d5b980b7] {
6
+ display: block;
7
+ background: transparent;
8
+ touch-action: none;
9
+ }
@@ -0,0 +1,2 @@
1
+ import { default as HandwritingPad } from './HandwritingPad.vue';
2
+ export { HandwritingPad };
@@ -0,0 +1 @@
1
+ import "./HandwritingPad.vue.mjs";
@@ -1,6 +1,18 @@
1
- var GlobalParamEnum = /* @__PURE__ */ ((GlobalParamEnum2) => {
2
- GlobalParamEnum2["SELECT_ID"] = "$VAR_GCT_SELECT_ID";
3
- return GlobalParamEnum2;
4
- })(GlobalParamEnum || {});
5
-
1
+ //#region src/enums/index.ts
2
+ /**
3
+ * 全局参数
4
+ *
5
+ * @author zhanghanrui
6
+ * @date 2024-07-21 17:07:00
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ var GlobalParamEnum = /* @__PURE__ */ function(GlobalParamEnum) {
11
+ /**
12
+ * 选择组件标识
13
+ */
14
+ GlobalParamEnum["SELECT_ID"] = "$VAR_GCT_SELECT_ID";
15
+ return GlobalParamEnum;
16
+ }({});
17
+ //#endregion
6
18
  export { GlobalParamEnum };
@@ -1,33 +1,37 @@
1
- import { useLocalStorage } from '@vueuse/core';
2
- import { GlobalParamEnum } from '../enums/index.mjs';
3
- import { computed } from 'vue';
4
-
5
- const GCT_SELECT_ID = useLocalStorage("GCT_APP_GlobalCache", {});
6
- const useGctSelect = (key) => {
7
- const cacheMap = computed({
8
- get() {
9
- return GCT_SELECT_ID.value[key] || {};
10
- },
11
- set(value) {
12
- GCT_SELECT_ID.value[key] = value;
13
- }
14
- });
15
- const selectID = computed({
16
- get() {
17
- return cacheMap.value[GlobalParamEnum.SELECT_ID];
18
- },
19
- set(value) {
20
- if (cacheMap.value[GlobalParamEnum.SELECT_ID]) {
21
- cacheMap.value[GlobalParamEnum.SELECT_ID] = value;
22
- } else {
23
- cacheMap.value = {
24
- ...cacheMap.value,
25
- [GlobalParamEnum.SELECT_ID]: value
26
- };
27
- }
28
- }
29
- });
30
- return { selectID, cacheMap };
1
+ import { GlobalParamEnum } from "../enums/index.mjs";
2
+ import { useLocalStorage } from "@vueuse/core";
3
+ import { computed } from "vue";
4
+ //#region src/hooks/useStorageRef.ts
5
+ var GCT_SELECT_ID = useLocalStorage("GCT_APP_GlobalCache", {});
6
+ /**
7
+ * app全局缓存
8
+ * @param key aid_userId
9
+ * @returns
10
+ */
11
+ var useGctSelect = (key) => {
12
+ const cacheMap = computed({
13
+ get() {
14
+ return GCT_SELECT_ID.value[key] || {};
15
+ },
16
+ set(value) {
17
+ GCT_SELECT_ID.value[key] = value;
18
+ }
19
+ });
20
+ return {
21
+ selectID: computed({
22
+ get() {
23
+ return cacheMap.value[GlobalParamEnum.SELECT_ID];
24
+ },
25
+ set(value) {
26
+ if (cacheMap.value[GlobalParamEnum.SELECT_ID]) cacheMap.value[GlobalParamEnum.SELECT_ID] = value;
27
+ else cacheMap.value = {
28
+ ...cacheMap.value,
29
+ [GlobalParamEnum.SELECT_ID]: value
30
+ };
31
+ }
32
+ }),
33
+ cacheMap
34
+ };
31
35
  };
32
-
36
+ //#endregion
33
37
  export { useGctSelect };
package/es/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './utils';
2
+ export * from './components';
2
3
  export * from './Event';
3
4
  export declare function onInit(): void;
package/es/index.mjs CHANGED
@@ -1,23 +1,22 @@
1
- import { RenderRegister } from './register/render-register/render-register.mjs';
2
- export { transformPropsField } from './utils/field-attrs/index.mjs';
3
- export { useStyle } from './utils/useStyle.mjs';
4
- export { FieldSchema, initFieldWidgetRuntime } from './utils/getFieldSchema.mjs';
5
- export { addDataByForm, setDataByForm, transSelectData, transformData, transformDataToDict, transformSourceData } from './utils/model-transformer.mjs';
6
- export { calculate, identify } from './utils/expression/index.mjs';
7
- export { getRefInfoId } from './utils/get-ref-data.mjs';
8
- export { Globals, formMap, getPageTitle, getPremission, globalVarCaches, pageDataforJson, pageGlobaVariables, setFormData } from './Event/utils/runGlobalByPage.mjs';
9
- export { Context, Events, GctComponent } from './Event/baseEvent.mjs';
10
- import '@gct-paas/core';
11
- export { dependencyToShow, dependencyToShowSync, tableWidgetByDept, tableWidgetToShow, useDependencyToShow, useDependencyToShowList } from './Event/Dependency/useDependencyToShow.mjs';
12
-
1
+ import { RenderRegister } from "./register/render-register/render-register.mjs";
2
+ import { transformPropsField } from "./utils/field-attrs/index.mjs";
3
+ import { schemaToStyle, useStyle } from "./utils/useStyle.mjs";
4
+ import { FieldSchema, initFieldWidgetRuntime } from "./utils/getFieldSchema.mjs";
5
+ import { addDataByForm, setDataByForm, transSelectData, transformData, transformDataToDict, transformSourceData } from "./utils/model-transformer.mjs";
6
+ import { calculate, identify } from "./utils/expression/index.mjs";
7
+ import { getRefInfoId } from "./utils/get-ref-data.mjs";
8
+ import "./utils/index.mjs";
9
+ import HandwritingPad_default from "./components/HandwritingPad.vue.mjs";
10
+ import "./components/index.mjs";
11
+ import { Globals, PageTypeEnum, formMap, getPageTitle, getPremission, globalVarCaches, pageDataforJson, pageGlobaVariables, setFormData } from "./Event/utils/runGlobalByPage.mjs";
12
+ import { Context, Events, GctComponent } from "./Event/baseEvent.mjs";
13
+ import { dependencyToShow, dependencyToShowSync, tableWidgetByDept, tableWidgetToShow, useDependencyToShow, useDependencyToShowList } from "./Event/Dependency/useDependencyToShow.mjs";
14
+ import { useDependency, useDependencyByRequired } from "./Event/Dependency/useDependency.mjs";
15
+ import "./Event/index.mjs";
16
+ //#region src/index.ts
13
17
  function onInit() {
14
- if (!_gct.register.render) {
15
- _gct.register.render = new RenderRegister();
16
- } else {
17
- console.warn(
18
- "渲染注册已存在,可能存在重复注册问题,请检查是否有重复引入渲染包的情况"
19
- );
20
- }
18
+ if (!_gct.register.render) _gct.register.render = new RenderRegister();
19
+ else console.warn("渲染注册已存在,可能存在重复注册问题,请检查是否有重复引入渲染包的情况");
21
20
  }
22
-
23
- export { onInit };
21
+ //#endregion
22
+ export { Context, Events, FieldSchema, GctComponent, Globals, HandwritingPad_default as HandwritingPad, PageTypeEnum, addDataByForm, calculate, dependencyToShow, dependencyToShowSync, formMap, getPageTitle, getPremission, getRefInfoId, globalVarCaches, identify, initFieldWidgetRuntime, onInit, pageDataforJson, pageGlobaVariables, schemaToStyle, setDataByForm, setFormData, tableWidgetByDept, tableWidgetToShow, transSelectData, transformData, transformDataToDict, transformPropsField, transformSourceData, useDependency, useDependencyByRequired, useDependencyToShow, useDependencyToShowList, useStyle };
@@ -1,59 +1,64 @@
1
- class RenderRegister {
2
- /**
3
- * 组件清单
4
- *
5
- * @author zhanghanrui
6
- * @date 2024-05-25 08:05:03
7
- * @protected
8
- * @type {Map<string, Component>}
9
- */
10
- map = /* @__PURE__ */ new Map();
11
- // readonly hooks = {
12
- // register: new SyncSeriesHook<[string, Component]>(),
13
- // unregister: new SyncSeriesHook<string>(),
14
- // };
15
- /**
16
- * 注册界面绘制组件
17
- *
18
- * @author zhanghanrui
19
- * @date 2024-05-25 08:05:05
20
- * @param {string} tag
21
- * @param {Component} com
22
- */
23
- register(tag, com) {
24
- this.map.set(tag, com);
25
- }
26
- /**
27
- * 取消组件注册
28
- *
29
- * @author zhanghanrui
30
- * @date 2024-05-25 08:05:34
31
- * @param {string} tag
32
- */
33
- unregister(tag) {
34
- this.map.delete(tag);
35
- }
36
- /**
37
- * 获取注册的组件
38
- *
39
- * @author zhanghanrui
40
- * @date 2024-05-25 08:05:59
41
- * @param {string} tag
42
- * @return {*} {(Component | undefined)}
43
- */
44
- get(tag) {
45
- return this.map.get(tag);
46
- }
47
- /**
48
- * 组件标识清单
49
- *
50
- * @author zhanghanrui
51
- * @date 2024-05-25 08:05:19
52
- * @return {*} {string[]}
53
- */
54
- keys() {
55
- return Array.from(this.map.keys());
56
- }
57
- }
58
-
1
+ //#region src/register/render-register/render-register.ts
2
+ /**
3
+ * 绘制组件注册
4
+ *
5
+ * @author zhanghanrui
6
+ * @date 2024-05-25 08:05:52
7
+ * @export
8
+ * @class RenderRegister
9
+ */
10
+ var RenderRegister = class {
11
+ /**
12
+ * 组件清单
13
+ *
14
+ * @author zhanghanrui
15
+ * @date 2024-05-25 08:05:03
16
+ * @protected
17
+ * @type {Map<string, Component>}
18
+ */
19
+ map = /* @__PURE__ */ new Map();
20
+ /**
21
+ * 注册界面绘制组件
22
+ *
23
+ * @author zhanghanrui
24
+ * @date 2024-05-25 08:05:05
25
+ * @param {string} tag
26
+ * @param {Component} com
27
+ */
28
+ register(tag, com) {
29
+ this.map.set(tag, com);
30
+ }
31
+ /**
32
+ * 取消组件注册
33
+ *
34
+ * @author zhanghanrui
35
+ * @date 2024-05-25 08:05:34
36
+ * @param {string} tag
37
+ */
38
+ unregister(tag) {
39
+ this.map.delete(tag);
40
+ }
41
+ /**
42
+ * 获取注册的组件
43
+ *
44
+ * @author zhanghanrui
45
+ * @date 2024-05-25 08:05:59
46
+ * @param {string} tag
47
+ * @return {*} {(Component | undefined)}
48
+ */
49
+ get(tag) {
50
+ return this.map.get(tag);
51
+ }
52
+ /**
53
+ * 组件标识清单
54
+ *
55
+ * @author zhanghanrui
56
+ * @date 2024-05-25 08:05:19
57
+ * @return {*} {string[]}
58
+ */
59
+ keys() {
60
+ return Array.from(this.map.keys());
61
+ }
62
+ };
63
+ //#endregion
59
64
  export { RenderRegister };
@@ -1,57 +1,65 @@
1
- import qs from 'qs';
2
-
1
+ import qs from "qs";
2
+ //#region src/utils/cacheAdapter.ts
3
+ /**
4
+ * 请求缓存
5
+ * @param args
6
+ * @param adapter
7
+ * @returns
8
+ */
3
9
  function cacheAdapter(args, adapter, noneCache = false) {
4
- if (noneCache || args?.customApi?.value) return adapter(args);
5
- const maxAge = 5e3;
6
- const requestKey = typeof args === "object" ? qs.stringify({ ...args, customApi: null }) : args;
7
- let responsePromise = MemoryCache.get(requestKey);
8
- if (!responsePromise) {
9
- responsePromise = (async () => {
10
- try {
11
- return await adapter(args);
12
- } catch (reason) {
13
- MemoryCache.delete(requestKey);
14
- throw reason;
15
- }
16
- })();
17
- MemoryCache.set(requestKey, responsePromise, maxAge);
18
- return responsePromise;
19
- }
20
- return responsePromise;
10
+ if (noneCache || args?.customApi?.value) return adapter(args);
11
+ const maxAge = 5e3;
12
+ const requestKey = typeof args === "object" ? qs.stringify({
13
+ ...args,
14
+ customApi: null
15
+ }) : args;
16
+ let responsePromise = MemoryCache.get(requestKey);
17
+ if (!responsePromise) {
18
+ responsePromise = (async () => {
19
+ try {
20
+ return await adapter(args);
21
+ } catch (reason) {
22
+ MemoryCache.delete(requestKey);
23
+ throw reason;
24
+ }
25
+ })();
26
+ MemoryCache.set(requestKey, responsePromise, maxAge);
27
+ return responsePromise;
28
+ }
29
+ return responsePromise;
21
30
  }
22
- class MemoryCache {
23
- static cachedata = {};
24
- static set(key, value, maxAge) {
25
- this.cachedata[key] = {
26
- maxAge: maxAge || 0,
27
- value,
28
- now: Date.now()
29
- };
30
- }
31
- static get(key) {
32
- this.reset();
33
- const cachedItem = this.cachedata[key];
34
- if (!cachedItem) return null;
35
- return cachedItem.value;
36
- }
37
- static delete(key) {
38
- return delete this.cachedata[key];
39
- }
40
- static clear() {
41
- this.cachedata = {};
42
- }
43
- /**
44
- *清空过期的数据
45
- */
46
- static reset() {
47
- for (const key in this.cachedata) {
48
- const cachedItem = this.cachedata[key];
49
- if (cachedItem) {
50
- const isExpired = Date.now() - cachedItem.now > cachedItem.maxAge;
51
- if (isExpired) this.delete(key);
52
- }
53
- }
54
- }
55
- }
56
-
31
+ var MemoryCache = class {
32
+ static cachedata = {};
33
+ static set(key, value, maxAge) {
34
+ this.cachedata[key] = {
35
+ maxAge: maxAge || 0,
36
+ value,
37
+ now: Date.now()
38
+ };
39
+ }
40
+ static get(key) {
41
+ this.reset();
42
+ const cachedItem = this.cachedata[key];
43
+ if (!cachedItem) return null;
44
+ return cachedItem.value;
45
+ }
46
+ static delete(key) {
47
+ return delete this.cachedata[key];
48
+ }
49
+ static clear() {
50
+ this.cachedata = {};
51
+ }
52
+ /**
53
+ *清空过期的数据
54
+ */
55
+ static reset() {
56
+ for (const key in this.cachedata) {
57
+ const cachedItem = this.cachedata[key];
58
+ if (cachedItem) {
59
+ if (Date.now() - cachedItem.now > cachedItem.maxAge) this.delete(key);
60
+ }
61
+ }
62
+ }
63
+ };
64
+ //#endregion
57
65
  export { cacheAdapter };