@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.
- package/dist/index.esm.min.js +6189 -0
- package/dist/index.min.css +2 -0
- package/es/Event/Dependency/controller.mjs +81 -94
- package/es/Event/Dependency/displayRule.mjs +65 -67
- package/es/Event/Dependency/useDependency.mjs +117 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
- package/es/Event/baseEvent.d.ts +8 -7
- package/es/Event/baseEvent.mjs +382 -423
- package/es/Event/bizServiceRequest.mjs +28 -40
- package/es/Event/eventType.d.ts +1 -1
- package/es/Event/eventType.mjs +1 -0
- package/es/Event/index.d.ts +4 -3
- package/es/Event/index.mjs +5 -0
- package/es/Event/utils/appRedis.mjs +39 -49
- package/es/Event/utils/globalLoading.mjs +95 -94
- package/es/Event/utils/processRovedInfo.mjs +228 -294
- package/es/Event/utils/runGlobalByPage.mjs +297 -301
- package/es/Event/utils/verificationVar.mjs +32 -38
- package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/components/HandwritingPad.vue.d.ts +27 -0
- package/es/components/HandwritingPad.vue.mjs +7 -0
- package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
- package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
- package/es/components/index.d.ts +2 -0
- package/es/components/index.mjs +1 -0
- package/es/enums/index.mjs +17 -5
- package/es/hooks/useStorageRef.mjs +35 -31
- package/es/index.d.ts +1 -0
- package/es/index.mjs +20 -21
- package/es/register/render-register/render-register.mjs +63 -58
- package/es/utils/cacheAdapter.mjs +62 -54
- package/es/utils/expression/index.mjs +105 -122
- package/es/utils/expression/regularExpression/methods.mjs +426 -567
- package/es/utils/field-attrs/basicAttrs.mjs +56 -80
- package/es/utils/field-attrs/index.mjs +16 -13
- package/es/utils/get-ref-data.mjs +41 -59
- package/es/utils/getFieldSchema.mjs +66 -80
- package/es/utils/index.d.ts +2 -2
- package/es/utils/index.mjs +6 -0
- package/es/utils/model-transformer.mjs +74 -64
- package/es/utils/useStyle.mjs +20 -16
- package/package.json +10 -10
- package/dist/index.esm.min.mjs +0 -7042
- package/dist/index.min.cjs +0 -17
- package/dist/index.system.min.js +0 -17
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
import { GLOBAL_VAR_TYPE } from
|
|
2
|
-
import dayjs from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 };
|
package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs
ADDED
|
@@ -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 @@
|
|
|
1
|
+
import "./HandwritingPad.vue.mjs";
|
package/es/enums/index.mjs
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import { computed } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
package/es/index.mjs
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import { RenderRegister } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 };
|