@gct-paas/render 0.1.4-dev.9 → 0.1.5-dev.0
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.min.css +2 -0
- package/dist/loader.esm.min.js +1 -0
- package/es/Event/Dependency/controller.d.ts +1 -1
- package/es/Event/Dependency/controller.mjs +81 -94
- package/es/Event/Dependency/displayRule.mjs +130 -68
- package/es/Event/Dependency/useDependency.mjs +117 -0
- package/es/Event/Dependency/useDependencyToShow.d.ts +1 -1
- package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
- package/es/Event/baseEvent.d.ts +28 -32
- package/es/Event/baseEvent.mjs +383 -439
- package/es/Event/bizServiceRequest.d.ts +1 -1
- package/es/Event/bizServiceRequest.mjs +29 -41
- package/es/Event/eventType.d.ts +1 -1
- package/es/Event/eventType.mjs +1 -0
- package/es/Event/index.d.ts +6 -3
- package/es/Event/index.mjs +7 -0
- package/es/Event/utils/appRedis.mjs +39 -49
- package/es/Event/utils/globalLoading.d.ts +13 -0
- package/es/Event/utils/globalLoading.mjs +104 -0
- package/es/Event/utils/processRovedInfo.mjs +228 -294
- package/es/Event/utils/runGlobalByPage.d.ts +4 -1
- 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/constant/data-format.d.ts +52 -0
- package/es/constant/data-format.mjs +66 -0
- package/es/constant/date-time.d.ts +99 -0
- package/es/constant/date-time.mjs +187 -0
- package/es/constant/index.d.ts +94 -0
- package/es/constant/index.mjs +100 -0
- package/es/controller/design-render/design-render.controller.d.ts +18 -0
- package/es/controller/design-render/design-render.controller.mjs +78 -0
- package/es/controller/design-render-base/design-render-base.controller.d.ts +9 -0
- package/es/controller/design-render-base/design-render-base.controller.mjs +12 -0
- package/es/controller/design-render-container/design-render-container.controller.d.ts +4 -0
- package/es/controller/design-render-container/design-render-container.controller.mjs +5 -0
- package/es/controller/design-render-item/design-render-item.controller.d.ts +4 -0
- package/es/controller/design-render-item/design-render-item.controller.mjs +5 -0
- package/es/controller/index.d.ts +4 -0
- package/es/controller/index.mjs +4 -0
- package/es/enums/index.mjs +17 -5
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.mjs +2 -0
- package/es/hooks/use-design-render-controller/use-design-render-controller.d.ts +11 -0
- package/es/hooks/use-design-render-controller/use-design-render-controller.mjs +32 -0
- package/es/hooks/useStorageRef.mjs +35 -31
- package/es/index.d.ts +4 -0
- package/es/index.mjs +34 -21
- package/es/interface/controller/i-design-render-base.controller.d.ts +43 -0
- package/es/interface/controller/i-design-render-container.controller.d.ts +7 -0
- package/es/interface/controller/i-design-render-item.controller.d.ts +7 -0
- package/es/interface/controller/i-design-render.controller.d.ts +93 -0
- package/es/interface/index.d.ts +12 -0
- package/es/interface/provider/i-render-base-node.provider.d.ts +45 -0
- package/es/interface/provider/i-render-container-node.provider.d.ts +30 -0
- package/es/interface/provider/i-render-editor-node.provider.d.ts +29 -0
- package/es/interface/provider/i-render-item-node.provider.d.ts +30 -0
- package/es/interface/state/i-design-render-base.state.d.ts +19 -0
- package/es/interface/state/i-design-render-container.state.d.ts +11 -0
- package/es/interface/state/i-design-render-item.state.d.ts +11 -0
- package/es/interface/state/i-design-render.state.d.ts +18 -0
- package/es/loader.d.ts +1 -0
- package/es/register/index.d.ts +1 -0
- package/es/register/index.mjs +2 -0
- package/es/register/node/node.register.d.ts +92 -0
- package/es/register/node/node.register.mjs +116 -0
- package/es/register/render-register/render-register.mjs +63 -58
- package/es/state/design-render/design-render.state.d.ts +13 -0
- package/es/state/design-render/design-render.state.mjs +15 -0
- package/es/state/design-render-base/design-render-base.state.d.ts +4 -0
- package/es/state/design-render-base/design-render-base.state.mjs +6 -0
- package/es/state/design-render-container/design-render-container.state.d.ts +4 -0
- package/es/state/design-render-item/design-render-item.state.d.ts +4 -0
- package/es/state/index.d.ts +4 -0
- package/es/utils/cacheAdapter.mjs +62 -54
- package/es/utils/expression/index.d.ts +1 -1
- 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 +6 -3
- package/es/utils/index.mjs +11 -0
- package/es/utils/model-transformer.mjs +74 -64
- package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.d.ts +43 -0
- package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.mjs +65 -0
- package/es/utils/search/index.d.ts +2 -0
- package/es/utils/search/index.mjs +2 -0
- package/es/utils/search/search-default-value.d.ts +7 -0
- package/es/utils/search/search-default-value.mjs +244 -0
- package/es/utils/search/search-hooks.d.ts +6 -0
- package/es/utils/search/search-hooks.mjs +67 -0
- package/es/utils/useStyle.d.ts +2 -2
- package/es/utils/useStyle.mjs +20 -15
- package/package.json +20 -17
- package/dist/index.esm.min.mjs +0 -7758
- package/dist/index.min.cjs +0 -9
- package/dist/index.system.min.js +0 -9
|
@@ -1,306 +1,302 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { verificationData } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
var pageGlobaVariables = ref({});
|
|
22
|
+
/**app全局变量 */
|
|
23
|
+
var globalVarCaches = ref({});
|
|
24
|
+
var formMap = ref({});
|
|
21
25
|
function setFormData(key, formData) {
|
|
22
|
-
|
|
26
|
+
formMap.value[key] = formData;
|
|
23
27
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
/**页面信息 */
|
|
29
|
+
var pageDataforJson = ref({
|
|
30
|
+
pageStyle: {},
|
|
31
|
+
pageConfig: {},
|
|
32
|
+
pageName: ""
|
|
28
33
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
/**页面信息 */
|
|
35
|
+
var getPageTitle = toRef(() => {
|
|
36
|
+
const { title } = pageDataforJson.value.pageConfig || {};
|
|
37
|
+
return title;
|
|
32
38
|
});
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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 };
|