@gct-paas/render 0.1.4-dev.9 → 0.1.5-dev.1

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 (110) hide show
  1. package/dist/index.min.css +2 -0
  2. package/dist/loader.esm.min.js +1 -0
  3. package/es/Event/Dependency/controller.d.ts +1 -1
  4. package/es/Event/Dependency/controller.mjs +81 -94
  5. package/es/Event/Dependency/displayRule.mjs +130 -68
  6. package/es/Event/Dependency/useDependency.mjs +117 -0
  7. package/es/Event/Dependency/useDependencyToShow.d.ts +1 -1
  8. package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
  9. package/es/Event/baseEvent.d.ts +28 -32
  10. package/es/Event/baseEvent.mjs +383 -439
  11. package/es/Event/bizServiceRequest.d.ts +1 -1
  12. package/es/Event/bizServiceRequest.mjs +29 -41
  13. package/es/Event/eventType.d.ts +1 -1
  14. package/es/Event/eventType.mjs +1 -0
  15. package/es/Event/index.d.ts +6 -3
  16. package/es/Event/index.mjs +7 -0
  17. package/es/Event/utils/appRedis.mjs +39 -49
  18. package/es/Event/utils/globalLoading.d.ts +13 -0
  19. package/es/Event/utils/globalLoading.mjs +104 -0
  20. package/es/Event/utils/processRovedInfo.mjs +228 -294
  21. package/es/Event/utils/runGlobalByPage.d.ts +4 -1
  22. package/es/Event/utils/runGlobalByPage.mjs +297 -301
  23. package/es/Event/utils/verificationVar.mjs +32 -38
  24. package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
  25. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  26. package/es/components/HandwritingPad.vue.d.ts +27 -0
  27. package/es/components/HandwritingPad.vue.mjs +7 -0
  28. package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
  29. package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
  30. package/es/components/index.d.ts +2 -0
  31. package/es/components/index.mjs +1 -0
  32. package/es/constant/data-format.d.ts +52 -0
  33. package/es/constant/data-format.mjs +66 -0
  34. package/es/constant/date-time.d.ts +99 -0
  35. package/es/constant/date-time.mjs +187 -0
  36. package/es/constant/index.d.ts +94 -0
  37. package/es/constant/index.mjs +100 -0
  38. package/es/controller/design-render/design-render.controller.d.ts +18 -0
  39. package/es/controller/design-render/design-render.controller.mjs +78 -0
  40. package/es/controller/design-render-base/design-render-base.controller.d.ts +9 -0
  41. package/es/controller/design-render-base/design-render-base.controller.mjs +12 -0
  42. package/es/controller/design-render-container/design-render-container.controller.d.ts +4 -0
  43. package/es/controller/design-render-container/design-render-container.controller.mjs +5 -0
  44. package/es/controller/design-render-item/design-render-item.controller.d.ts +4 -0
  45. package/es/controller/design-render-item/design-render-item.controller.mjs +5 -0
  46. package/es/controller/index.d.ts +4 -0
  47. package/es/controller/index.mjs +4 -0
  48. package/es/enums/index.mjs +17 -5
  49. package/es/hooks/index.d.ts +3 -0
  50. package/es/hooks/index.mjs +3 -0
  51. package/es/hooks/use-design-render-controller/use-design-render-controller.d.ts +11 -0
  52. package/es/hooks/use-design-render-controller/use-design-render-controller.mjs +32 -0
  53. package/es/hooks/useStorageRef.mjs +35 -31
  54. package/es/hooks/widgets/useFileAttrsHooks.d.ts +28 -0
  55. package/es/hooks/widgets/useFileAttrsHooks.mjs +37 -0
  56. package/es/index.d.ts +5 -0
  57. package/es/index.mjs +44 -21
  58. package/es/interface/controller/i-design-render-base.controller.d.ts +43 -0
  59. package/es/interface/controller/i-design-render-container.controller.d.ts +7 -0
  60. package/es/interface/controller/i-design-render-item.controller.d.ts +7 -0
  61. package/es/interface/controller/i-design-render.controller.d.ts +93 -0
  62. package/es/interface/index.d.ts +12 -0
  63. package/es/interface/provider/i-render-base-node.provider.d.ts +45 -0
  64. package/es/interface/provider/i-render-container-node.provider.d.ts +30 -0
  65. package/es/interface/provider/i-render-editor-node.provider.d.ts +29 -0
  66. package/es/interface/provider/i-render-item-node.provider.d.ts +30 -0
  67. package/es/interface/state/i-design-render-base.state.d.ts +19 -0
  68. package/es/interface/state/i-design-render-container.state.d.ts +11 -0
  69. package/es/interface/state/i-design-render-item.state.d.ts +11 -0
  70. package/es/interface/state/i-design-render.state.d.ts +18 -0
  71. package/es/loader.d.ts +1 -0
  72. package/es/register/index.d.ts +1 -0
  73. package/es/register/index.mjs +2 -0
  74. package/es/register/node/node.register.d.ts +92 -0
  75. package/es/register/node/node.register.mjs +116 -0
  76. package/es/register/render-register/render-register.mjs +63 -58
  77. package/es/state/design-render/design-render.state.d.ts +13 -0
  78. package/es/state/design-render/design-render.state.mjs +15 -0
  79. package/es/state/design-render-base/design-render-base.state.d.ts +4 -0
  80. package/es/state/design-render-base/design-render-base.state.mjs +6 -0
  81. package/es/state/design-render-container/design-render-container.state.d.ts +4 -0
  82. package/es/state/design-render-item/design-render-item.state.d.ts +4 -0
  83. package/es/state/index.d.ts +4 -0
  84. package/es/utils/cacheAdapter.mjs +62 -54
  85. package/es/utils/expression/index.d.ts +1 -1
  86. package/es/utils/expression/index.mjs +105 -122
  87. package/es/utils/expression/regularExpression/methods.mjs +426 -567
  88. package/es/utils/field-attrs/basicAttrs.mjs +56 -80
  89. package/es/utils/field-attrs/index.mjs +16 -13
  90. package/es/utils/get-ref-data.mjs +41 -59
  91. package/es/utils/getFieldSchema.mjs +66 -80
  92. package/es/utils/index.d.ts +6 -3
  93. package/es/utils/index.mjs +12 -0
  94. package/es/utils/model-transformer.mjs +74 -64
  95. package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.d.ts +43 -0
  96. package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.mjs +65 -0
  97. package/es/utils/search/index.d.ts +3 -0
  98. package/es/utils/search/index.mjs +3 -0
  99. package/es/utils/search/listhook.d.ts +17 -0
  100. package/es/utils/search/listhook.mjs +70 -0
  101. package/es/utils/search/search-default-value.d.ts +7 -0
  102. package/es/utils/search/search-default-value.mjs +244 -0
  103. package/es/utils/search/search-hooks.d.ts +6 -0
  104. package/es/utils/search/search-hooks.mjs +67 -0
  105. package/es/utils/useStyle.d.ts +2 -2
  106. package/es/utils/useStyle.mjs +20 -15
  107. package/package.json +21 -17
  108. package/dist/index.esm.min.mjs +0 -7758
  109. package/dist/index.min.cjs +0 -9
  110. package/dist/index.system.min.js +0 -9
@@ -1,306 +1,302 @@
1
- import { ref, toRef, onMounted, nextTick, onBeforeUnmount, onActivated } from 'vue';
2
- import { verificationData } from './verificationVar.mjs';
3
- import { useCreateAppredis } from './appRedis.mjs';
4
- import '@gct-paas/schema';
5
- import { usePermissionStore } from '@gct-paas/core';
6
-
7
- const getPageApiByMap = {
8
- ["web_module" /* WEB */]: {
9
- getPageInfo: _gct.api.apaas.webpage.getInfo
10
- },
11
- ["mobile_module" /* MOBILE */]: {
12
- getPageInfo: _gct.api.apaas.mobilePage.getInfo
13
- },
14
- ["pad_module" /* PAD */]: {
15
- getPageInfo: _gct.api.apaas.padPage.getInfo
16
- }
1
+ import { useCreateAppredis } from "./appRedis.mjs";
2
+ import { verificationData } from "./verificationVar.mjs";
3
+ import { usePermissionStore } from "@gct-paas/core";
4
+ import "@gct-paas/schema";
5
+ import { nextTick, onActivated, onBeforeUnmount, onMounted, ref, toRef } from "vue";
6
+ //#region src/Event/utils/runGlobalByPage.ts
7
+ var PageTypeEnum = /* @__PURE__ */ function(PageTypeEnum) {
8
+ /** WEB */
9
+ PageTypeEnum["WEB"] = "web_module";
10
+ /** MOBILE */
11
+ PageTypeEnum["MOBILE"] = "mobile_module";
12
+ /** PAD */
13
+ PageTypeEnum["PAD"] = "pad_module";
14
+ return PageTypeEnum;
15
+ }({});
16
+ var getPageApiByMap = {
17
+ [PageTypeEnum.WEB]: { getPageInfo: _gct.api.apaas.webpage.getInfo },
18
+ [PageTypeEnum.MOBILE]: { getPageInfo: _gct.api.apaas.mobilePage.getInfo },
19
+ [PageTypeEnum.PAD]: { getPageInfo: _gct.api.apaas.padPage.getInfo }
17
20
  };
18
- const pageGlobaVariables = ref({});
19
- const globalVarCaches = ref({});
20
- const formMap = ref({});
21
+ var pageGlobaVariables = ref({});
22
+ /**app全局变量 */
23
+ var globalVarCaches = ref({});
24
+ var formMap = ref({});
21
25
  function setFormData(key, formData) {
22
- formMap.value[key] = formData;
26
+ formMap.value[key] = formData;
23
27
  }
24
- const pageDataforJson = ref({
25
- pageStyle: {},
26
- pageConfig: {},
27
- pageName: ""
28
+ /**页面信息 */
29
+ var pageDataforJson = ref({
30
+ pageStyle: {},
31
+ pageConfig: {},
32
+ pageName: ""
28
33
  });
29
- const getPageTitle = toRef(() => {
30
- const { title } = pageDataforJson.value.pageConfig || {};
31
- return title;
34
+ /**页面信息 */
35
+ var getPageTitle = toRef(() => {
36
+ const { title } = pageDataforJson.value.pageConfig || {};
37
+ return title;
32
38
  });
33
- class Globals {
34
- /**模态框缓存 */
35
- static modalsCache = {};
36
- /**
37
- * 上下文缓存
38
- */
39
- static pageID = "";
40
- static permissions = {};
41
- // static
42
- static ContextCache = {};
43
- /**常量刷新锁 */
44
- static startRuning = false;
45
- /**全局钩子 */
46
- static globalHookCaches = {
47
- pageMounted: [],
48
- pageActivated: [],
49
- pageDestroyed: []
50
- };
51
- /**
52
- * 设置模态框
53
- * @param list
54
- */
55
- static setModals(list) {
56
- this.modalsCache = {};
57
- list?.forEach((i) => {
58
- this.modalsCache[i.id] = i;
59
- });
60
- }
61
- /**获取模态框信息 */
62
- static async getModalById(key) {
63
- if (!key) return Promise.reject();
64
- if (/^i?g_modal_/.test(key) && !this.modalsCache[key]) {
65
- const [res] = await _api.apaas.appGlobalSettings.getInfo({
66
- keys: key,
67
- fullInfo: true
68
- }) || [];
69
- if (res?.configJson) {
70
- const modal = JSON.parse(res.configJson);
71
- this.modalsCache[key] = modal;
72
- }
73
- }
74
- const data = this.modalsCache[key];
75
- if (!data) {
76
- console.error(`模态框${key}不存在`);
77
- return Promise.reject();
78
- }
79
- return data;
80
- }
81
- /**
82
- * 角色权限
83
- * @param id 组件标识
84
- */
85
- static getPremission(id) {
86
- if (!id) return true;
87
- const key = this.permissions[id];
88
- if (!key) return true;
89
- const PermissionStore = usePermissionStore();
90
- return PermissionStore.getPermissionByKey(this.pageID, key);
91
- }
92
- /**
93
- *设置组件权限
94
- * @param key 权限标识
95
- * @param id 组件标识
96
- */
97
- static setPremission(key, id) {
98
- this.permissions[id] = key;
99
- }
100
- static setContextByKey(context, key) {
101
- if (key) {
102
- this.ContextCache[key] = context;
103
- } else {
104
- this.ContextCache = {
105
- page: context
106
- };
107
- }
108
- }
109
- static getContextByKey(key) {
110
- return this.ContextCache[key || "page"];
111
- }
112
- /**
113
- *获取页面变量
114
- */
115
- static async initvars() {
116
- const data = await _gct.api.apaas.appGlobalSettings.getList({
117
- type: "var",
118
- fullInfo: true
119
- }) || [];
120
- data.forEach((i) => {
121
- if (!i.configJson) return;
122
- try {
123
- const datavalue = JSON.parse(i.configJson);
124
- globalVarCaches.value[datavalue.key] = useCreateAppredis({
125
- value: datavalue.defaultValue,
126
- appredis: datavalue.appredis,
127
- key: datavalue.key,
128
- type: datavalue.type
129
- });
130
- } catch (error) {
131
- console.error("initvars", error);
132
- }
133
- });
134
- }
135
- /**
136
- * 获取APP全局钩子
137
- */
138
- static async inithooks() {
139
- const data = await _gct.api.apaas.appGlobalSettings.getList({
140
- type: "event",
141
- fullInfo: true
142
- }) || [];
143
- data.forEach((i) => {
144
- if (!i.configJson) return;
145
- try {
146
- const fun = new Function(JSON.parse(i.configJson).runJs);
147
- const catchFun = this.globalHookCaches[i.key];
148
- if (catchFun) catchFun.push(fun);
149
- } catch (error) {
150
- console.error("inithooks", error);
151
- }
152
- });
153
- }
154
- static async initPermission(permissions) {
155
- this.permissions = permissions || {};
156
- }
157
- static async initGlobalS(data) {
158
- this.setModals(data.modals);
159
- data.pageVars?.forEach((i) => {
160
- pageGlobaVariables.value[i.key] = {
161
- value: i.varInfo?.defaultValue,
162
- type: i.varInfo.type
163
- };
164
- });
165
- if (this.startRuning) return;
166
- this.startRuning = true;
167
- try {
168
- await Promise.all([this.initvars(), this.inithooks()]);
169
- } catch (error) {
170
- console.log(error);
171
- }
172
- }
173
- static getGlobalVar(id) {
174
- const data = globalVarCaches.value[id];
175
- if (!data) return console.warn("变量key不存在");
176
- return data.value;
177
- }
178
- static async setGlobalVar(id, value) {
179
- const data = globalVarCaches.value[id];
180
- if (!data) return console.warn("变量key不存在");
181
- data.value = value;
182
- }
183
- /**
184
- * 获取页面变量
185
- * @param key
186
- * @returns
187
- */
188
- static getPageVar(key) {
189
- const data = pageGlobaVariables.value[key];
190
- if (!data) return console.warn("变量key不存在");
191
- return data.value;
192
- }
193
- /**
194
- *设置页面变量
195
- * @param key
196
- * @param value
197
- */
198
- static async setPageVar(key, value) {
199
- const data = pageGlobaVariables.value[key];
200
- if (!data) return console.warn("变量key不存在");
201
- await verificationData(value, data.type);
202
- if (!pageGlobaVariables.value[key]) return;
203
- pageGlobaVariables.value[key].value = value;
204
- }
205
- /**
206
- * 获取页面全局变量老版本兼容问题暂时不删除 后续不维护
207
- * @param key
208
- * @returns
209
- */
210
- static getPageGlobalVar(key) {
211
- return pageGlobaVariables.value[key]?.value;
212
- }
213
- /**设置页面变量老版本 兼容问题暂时不删除 后续不维护*/
214
- static setPageGlobalVar(key, value) {
215
- if (pageGlobaVariables.value[key]) {
216
- pageGlobaVariables.value[key].value = value;
217
- } else {
218
- pageGlobaVariables.value[key] = { value, type: "string" };
219
- }
220
- }
221
- static async initPageByid(id, pageType = "web_module" /* WEB */) {
222
- this.pageID = id;
223
- const getJSon = getPageApiByMap[pageType].getPageInfo;
224
- const res = await getJSon(
225
- { id }
226
- // location.href.includes('PagePreview')
227
- // ? { transferToConfig: { headers: { Env: 'dev' } } }
228
- // : {},
229
- );
230
- const { runtimeJson, name } = res || {};
231
- pageDataforJson.value.pageName = name;
232
- if (!runtimeJson) return Promise.reject();
233
- const data = JSON.parse(runtimeJson);
234
- if (!data.widgets.filter((item) => item.type !== "bottom-button-container").length)
235
- return Promise.reject();
236
- await this.initGlobalS(data);
237
- pageDataforJson.value.pageConfig = data.pageConfig || {};
238
- pageDataforJson.value.pageStyle = data.pageStyle || {};
239
- return { res, data, name };
240
- }
241
- static async initHistoryByid(id) {
242
- this.pageID = id;
243
- const res = await _gct.api.apaas.pageDesignerLog.getInfo({ id });
244
- const { runtimeJson, name } = res || {};
245
- if (!runtimeJson) return Promise.reject();
246
- pageDataforJson.value.pageName = name;
247
- const data = JSON.parse(runtimeJson);
248
- await this.initGlobalS(data);
249
- pageDataforJson.value.pageConfig = data.pageConfig || {};
250
- pageDataforJson.value.pageStyle = data.pageStyle || {};
251
- return { res, data, name };
252
- }
253
- /**注册钩子 */
254
- static usePageHooks(Event, pageEvents, globalEvents, pageCallback) {
255
- const pageload = ref(false);
256
- onMounted(async () => {
257
- await nextTick();
258
- const pageBeforeMountData = pageEvents?.pageBeforeMount;
259
- if (pageBeforeMountData?.name) {
260
- await Event.runExportByName(
261
- pageBeforeMountData.name,
262
- pageBeforeMountData.extraParams
263
- );
264
- }
265
- if (pageCallback) await pageCallback(Event);
266
- pageload.value = true;
267
- if (globalEvents.pageMounted) {
268
- for (const fun of this.globalHookCaches.pageMounted) {
269
- await fun();
270
- }
271
- }
272
- const { extraParams, name } = pageEvents?.pageMounted || {};
273
- if (name) {
274
- Event.runAsyncExportByName(name, extraParams);
275
- }
276
- });
277
- onBeforeUnmount(async () => {
278
- pageDataforJson.value = {};
279
- const { extraParams, name } = pageEvents?.pageDestroyed || {};
280
- if (name) {
281
- Event.runExportByName(name, extraParams);
282
- }
283
- if (globalEvents.pageDestroyed) {
284
- for (const fun of this.globalHookCaches.pageDestroyed) {
285
- await fun();
286
- }
287
- }
288
- });
289
- onActivated(async () => {
290
- Globals.setContextByKey(Event.context);
291
- if (globalEvents.pageActivated) {
292
- for (const fun of this.globalHookCaches.pageActivated) {
293
- await fun();
294
- }
295
- }
296
- const { extraParams, name } = pageEvents?.pageActivated || {};
297
- if (name) {
298
- Event.runAsyncExportByName(name, extraParams);
299
- }
300
- });
301
- return { pageload };
302
- }
303
- }
304
- const getPremission = Globals.getPremission.bind(Globals);
305
-
306
- export { Globals, formMap, getPageTitle, getPremission, globalVarCaches, pageDataforJson, pageGlobaVariables, setFormData };
39
+ /**页面全局事件 */
40
+ var Globals = class Globals {
41
+ /**模态框缓存 */
42
+ static modalsCache = {};
43
+ /**
44
+ * 上下文缓存
45
+ */
46
+ static pageID = "";
47
+ static permissions = {};
48
+ static ContextCache = {};
49
+ /**常量刷新锁 */
50
+ static startRuning = false;
51
+ /**全局钩子 */
52
+ static globalHookCaches = {
53
+ pageMounted: [],
54
+ pageActivated: [],
55
+ pageDestroyed: []
56
+ };
57
+ /**
58
+ * 设置模态框
59
+ * @param list
60
+ */
61
+ static setModals(list) {
62
+ this.modalsCache = {};
63
+ list?.forEach((i) => {
64
+ this.modalsCache[i.id] = i;
65
+ });
66
+ }
67
+ /**获取模态框信息 */
68
+ static async getModalById(key) {
69
+ if (!key) return Promise.reject();
70
+ if (/^i?g_modal_/.test(key) && !this.modalsCache[key]) {
71
+ const [res] = await _api.apaas.appGlobalSettings.getInfo({
72
+ keys: key,
73
+ fullInfo: true
74
+ }) || [];
75
+ if (res?.configJson) {
76
+ const modal = JSON.parse(res.configJson);
77
+ this.modalsCache[key] = modal;
78
+ }
79
+ }
80
+ const data = this.modalsCache[key];
81
+ if (!data) {
82
+ console.error(`模态框${key}不存在`);
83
+ return Promise.reject();
84
+ }
85
+ return data;
86
+ }
87
+ /**
88
+ * 角色权限
89
+ * @param id 组件标识
90
+ */
91
+ static getPremission(id) {
92
+ if (!id) return true;
93
+ const key = this.permissions[id];
94
+ if (!key) return true;
95
+ return usePermissionStore().getPermissionByKey(this.pageID, key);
96
+ }
97
+ /**
98
+ *设置组件权限
99
+ * @param key 权限标识
100
+ * @param id 组件标识
101
+ */
102
+ static setPremission(key, id) {
103
+ this.permissions[id] = key;
104
+ }
105
+ static setContextByKey(context, key) {
106
+ if (key) this.ContextCache[key] = context;
107
+ else this.ContextCache = { page: context };
108
+ }
109
+ static getContextByKey(key) {
110
+ return this.ContextCache[key || "page"];
111
+ }
112
+ /**
113
+ *获取页面变量
114
+ */
115
+ static async initvars() {
116
+ (await _gct.api.apaas.appGlobalSettings.getList({
117
+ type: "var",
118
+ fullInfo: true
119
+ }) || []).forEach((i) => {
120
+ if (!i.configJson) return;
121
+ try {
122
+ const datavalue = JSON.parse(i.configJson);
123
+ globalVarCaches.value[datavalue.key] = useCreateAppredis({
124
+ value: datavalue.defaultValue,
125
+ appredis: datavalue.appredis,
126
+ key: datavalue.key,
127
+ type: datavalue.type
128
+ });
129
+ } catch (error) {
130
+ console.error("initvars", error);
131
+ }
132
+ });
133
+ }
134
+ /**
135
+ * 获取APP全局钩子
136
+ */
137
+ static async inithooks() {
138
+ (await _gct.api.apaas.appGlobalSettings.getList({
139
+ type: "event",
140
+ fullInfo: true
141
+ }) || []).forEach((i) => {
142
+ if (!i.configJson) return;
143
+ try {
144
+ const fun = new Function(JSON.parse(i.configJson).runJs);
145
+ const catchFun = this.globalHookCaches[i.key];
146
+ if (catchFun) catchFun.push(fun);
147
+ } catch (error) {
148
+ console.error("inithooks", error);
149
+ }
150
+ });
151
+ }
152
+ static async initPermission(permissions) {
153
+ this.permissions = permissions || {};
154
+ }
155
+ static async initGlobalS(data) {
156
+ this.setModals(data.modals);
157
+ /**初始化页面变量 */
158
+ data.pageVars?.forEach((i) => {
159
+ pageGlobaVariables.value[i.key] = {
160
+ value: i.varInfo?.defaultValue,
161
+ type: i.varInfo.type
162
+ };
163
+ });
164
+ if (this.startRuning) return;
165
+ this.startRuning = true;
166
+ try {
167
+ await Promise.all([this.initvars(), this.inithooks()]);
168
+ } catch (error) {
169
+ console.log(error);
170
+ }
171
+ }
172
+ static getGlobalVar(id) {
173
+ const data = globalVarCaches.value[id];
174
+ if (!data) return console.warn("变量key不存在");
175
+ return data.value;
176
+ }
177
+ static async setGlobalVar(id, value) {
178
+ const data = globalVarCaches.value[id];
179
+ if (!data) return console.warn("变量key不存在");
180
+ data.value = value;
181
+ }
182
+ /**
183
+ * 获取页面变量
184
+ * @param key
185
+ * @returns
186
+ */
187
+ static getPageVar(key) {
188
+ const data = pageGlobaVariables.value[key];
189
+ if (!data) return console.warn("变量key不存在");
190
+ return data.value;
191
+ }
192
+ /**
193
+ *设置页面变量
194
+ * @param key
195
+ * @param value
196
+ */
197
+ static async setPageVar(key, value) {
198
+ const data = pageGlobaVariables.value[key];
199
+ if (!data) return console.warn("变量key不存在");
200
+ await verificationData(value, data.type);
201
+ if (!pageGlobaVariables.value[key]) return;
202
+ pageGlobaVariables.value[key].value = value;
203
+ }
204
+ /**
205
+ * 获取页面全局变量老版本兼容问题暂时不删除 后续不维护
206
+ * @param key
207
+ * @returns
208
+ */
209
+ static getPageGlobalVar(key) {
210
+ return pageGlobaVariables.value[key]?.value;
211
+ }
212
+ /**设置页面变量老版本 兼容问题暂时不删除 后续不维护*/
213
+ static setPageGlobalVar(key, value) {
214
+ if (pageGlobaVariables.value[key]) pageGlobaVariables.value[key].value = value;
215
+ else pageGlobaVariables.value[key] = {
216
+ value,
217
+ type: "string"
218
+ };
219
+ }
220
+ static async initPageByid(id, pageType = PageTypeEnum.WEB) {
221
+ this.pageID = id;
222
+ const getJSon = getPageApiByMap[pageType].getPageInfo;
223
+ const res = await getJSon({ id });
224
+ const { runtimeJson, name } = res || {};
225
+ pageDataforJson.value.pageName = name;
226
+ if (!runtimeJson) return Promise.reject();
227
+ const data = JSON.parse(runtimeJson);
228
+ if (!data.widgets.filter((item) => item.type !== "bottom-button-container").length) return Promise.reject();
229
+ await this.initGlobalS(data);
230
+ pageDataforJson.value.pageConfig = data.pageConfig || {};
231
+ pageDataforJson.value.pageStyle = data.pageStyle || {};
232
+ return {
233
+ res,
234
+ data,
235
+ name
236
+ };
237
+ }
238
+ static async initHistoryByid(id) {
239
+ this.pageID = id;
240
+ const res = await _gct.api.apaas.pageDesignerLog.getInfo({ id });
241
+ const { runtimeJson, name } = res || {};
242
+ if (!runtimeJson) return Promise.reject();
243
+ pageDataforJson.value.pageName = name;
244
+ const data = JSON.parse(runtimeJson);
245
+ await this.initGlobalS(data);
246
+ pageDataforJson.value.pageConfig = data.pageConfig || {};
247
+ pageDataforJson.value.pageStyle = data.pageStyle || {};
248
+ return {
249
+ res,
250
+ data,
251
+ name
252
+ };
253
+ }
254
+ /**注册钩子 */
255
+ static usePageHooks(Event, pageEvents, globalEvents, pageCallback) {
256
+ /**页面加载 */
257
+ const pageload = ref(false);
258
+ onMounted(async () => {
259
+ await nextTick();
260
+ const pageBeforeMountData = pageEvents?.pageBeforeMount;
261
+ if (pageBeforeMountData?.name)
262
+ /**页面钩子 */
263
+ /**异步执行保存内部组件初始化 */
264
+ await Event.runExportByName(pageBeforeMountData.name, pageBeforeMountData.extraParams);
265
+ /**自定义初始化回调 */
266
+ if (pageCallback) await pageCallback(Event);
267
+ pageload.value = true;
268
+ /**全局钩子 */
269
+ if (globalEvents?.pageMounted) for (const fun of this.globalHookCaches.pageMounted) await fun();
270
+ const { extraParams, name } = pageEvents?.pageMounted || {};
271
+ if (name)
272
+ /**页面钩子 */
273
+ /**异步执行保存内部组件初始化 */
274
+ Event.runAsyncExportByName(name, extraParams);
275
+ });
276
+ onBeforeUnmount(async () => {
277
+ /**清空页面data */
278
+ pageDataforJson.value = {};
279
+ const { extraParams, name } = pageEvents?.pageDestroyed || {};
280
+ if (name)
281
+ /**页面钩子 */
282
+ /**页面销毁时候的钩子函数 */
283
+ Event.runExportByName(name, extraParams);
284
+ /**全局钩子 */
285
+ if (globalEvents?.pageDestroyed) for (const fun of this.globalHookCaches.pageDestroyed) await fun();
286
+ });
287
+ onActivated(async () => {
288
+ Globals.setContextByKey(Event.context);
289
+ /**全局钩子 */
290
+ if (globalEvents?.pageActivated) for (const fun of this.globalHookCaches.pageActivated) await fun();
291
+ const { extraParams, name } = pageEvents?.pageActivated || {};
292
+ if (name)
293
+ /**页面钩子 */
294
+ /**异步执行保存内部组件初始化 */
295
+ Event.runAsyncExportByName(name, extraParams);
296
+ });
297
+ return { pageload };
298
+ }
299
+ };
300
+ var getPremission = Globals.getPremission.bind(Globals);
301
+ //#endregion
302
+ export { Globals, PageTypeEnum, formMap, getPageTitle, getPremission, globalVarCaches, pageDataforJson, pageGlobaVariables, setFormData };