@gct-paas/render 0.1.4-dev.7 → 0.1.4-dev.9
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.mjs +7684 -15
- package/dist/index.min.cjs +9 -1
- package/dist/index.system.min.js +9 -1
- package/es/Event/Dependency/controller.d.ts +13 -0
- package/es/Event/Dependency/controller.mjs +97 -0
- package/es/Event/Dependency/displayRule.d.ts +19 -0
- package/es/Event/Dependency/displayRule.mjs +76 -0
- package/es/Event/Dependency/useDependency.d.ts +7 -0
- package/es/Event/Dependency/useDependencyToShow.d.ts +10 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +109 -0
- package/es/Event/baseEvent.d.ts +160 -0
- package/es/Event/baseEvent.mjs +445 -0
- package/es/Event/bizServiceRequest.d.ts +26 -0
- package/es/Event/bizServiceRequest.mjs +47 -0
- package/es/Event/eventType.d.ts +20 -0
- package/es/Event/index.d.ts +4 -0
- package/es/Event/utils/appRedis.d.ts +29 -0
- package/es/Event/utils/appRedis.mjs +50 -0
- package/es/Event/utils/processRovedInfo.d.ts +100 -0
- package/es/Event/utils/processRovedInfo.mjs +297 -0
- package/es/Event/utils/runGlobalByPage.d.ts +332 -0
- package/es/Event/utils/runGlobalByPage.mjs +306 -0
- package/es/Event/utils/verificationVar.d.ts +2 -0
- package/es/Event/utils/verificationVar.mjs +42 -0
- package/es/enums/index.d.ts +14 -0
- package/es/enums/index.mjs +6 -0
- package/es/hooks/useStorageRef.d.ts +9 -0
- package/es/hooks/useStorageRef.mjs +33 -0
- package/es/index.d.ts +2 -0
- package/es/index.mjs +22 -0
- package/es/register/index.d.ts +1 -0
- package/es/register/render-register/render-register.d.ts +54 -0
- package/es/register/render-register/render-register.mjs +59 -0
- package/es/types/index.d.ts +6 -0
- package/es/utils/cacheAdapter.d.ts +7 -0
- package/es/utils/cacheAdapter.mjs +57 -0
- package/es/utils/expression/index.d.ts +6 -0
- package/es/utils/expression/index.mjs +133 -0
- package/es/utils/expression/regularExpression/methods.d.ts +77 -0
- package/es/utils/expression/regularExpression/methods.mjs +729 -0
- package/es/utils/field-attrs/index.d.ts +1 -1
- package/es/utils/get-ref-data.d.ts +1 -0
- package/es/utils/get-ref-data.mjs +62 -0
- package/es/utils/getFieldSchema.d.ts +1 -3
- package/es/utils/getFieldSchema.mjs +83 -0
- package/es/utils/index.d.ts +5 -0
- package/es/utils/model-transformer.d.ts +46 -0
- package/es/utils/model-transformer.mjs +77 -0
- package/es/utils/useStyle.d.ts +21 -0
- package/es/utils/useStyle.mjs +17 -0
- package/package.json +26 -6
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { RuntimePageJson } from '@gct-paas/schema';
|
|
2
|
+
export declare enum PageTypeEnum {
|
|
3
|
+
/** WEB */
|
|
4
|
+
WEB = "web_module",
|
|
5
|
+
/** MOBILE */
|
|
6
|
+
MOBILE = "mobile_module",
|
|
7
|
+
/** PAD */
|
|
8
|
+
PAD = "pad_module"
|
|
9
|
+
}
|
|
10
|
+
export declare const pageGlobaVariables: import('vue').Ref<Record<string, IObject>, Record<string, IObject>>;
|
|
11
|
+
/**app全局变量 */
|
|
12
|
+
export declare const globalVarCaches: import('vue').Ref<Record<string, IObject>, Record<string, IObject>>;
|
|
13
|
+
export declare const formMap: import('vue').Ref<Record<string, IObject>, Record<string, IObject>>;
|
|
14
|
+
export declare function setFormData(key: string, formData: IObject): void;
|
|
15
|
+
/**页面信息 */
|
|
16
|
+
export declare const pageDataforJson: import('vue').Ref<{
|
|
17
|
+
pageStyle?: {
|
|
18
|
+
position?: string | undefined;
|
|
19
|
+
top?: string | undefined;
|
|
20
|
+
left?: string | undefined;
|
|
21
|
+
right?: string | undefined;
|
|
22
|
+
bottom?: string | undefined;
|
|
23
|
+
width?: string | undefined;
|
|
24
|
+
height?: string | undefined;
|
|
25
|
+
maxHeight?: string | undefined;
|
|
26
|
+
backgroundColor?: string | undefined;
|
|
27
|
+
marginAll?: string | undefined;
|
|
28
|
+
marginTop?: string | undefined;
|
|
29
|
+
marginRight?: string | undefined;
|
|
30
|
+
marginBottom?: string | undefined;
|
|
31
|
+
marginLeft?: string | undefined;
|
|
32
|
+
paddingAll?: string | undefined;
|
|
33
|
+
paddingTop?: string | undefined;
|
|
34
|
+
paddingRight?: string | undefined;
|
|
35
|
+
paddingBottom?: string | undefined;
|
|
36
|
+
paddingLeft?: string | undefined;
|
|
37
|
+
labelFont?: {
|
|
38
|
+
fontSize: string;
|
|
39
|
+
bold: boolean;
|
|
40
|
+
italic: boolean;
|
|
41
|
+
textDecoration: import('@gct-paas/core').TextDecoration;
|
|
42
|
+
color: string;
|
|
43
|
+
align: "left" | "right" | "justify";
|
|
44
|
+
} | undefined;
|
|
45
|
+
contentFont?: {
|
|
46
|
+
fontSize: string;
|
|
47
|
+
bold: boolean;
|
|
48
|
+
italic: boolean;
|
|
49
|
+
textDecoration: import('@gct-paas/core').TextDecoration;
|
|
50
|
+
color: string;
|
|
51
|
+
align: "left" | "right" | "justify";
|
|
52
|
+
} | undefined;
|
|
53
|
+
tagStyle?: {
|
|
54
|
+
color?: string | undefined;
|
|
55
|
+
tagType?: import('@gct-paas/core').TagTypeEnum | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
tagStyleOpen?: boolean | undefined;
|
|
58
|
+
borderAll?: {
|
|
59
|
+
borderWidth?: string | undefined;
|
|
60
|
+
borderStyle?: string | undefined;
|
|
61
|
+
borderColor?: string | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
borderLeft?: {
|
|
64
|
+
borderWidth?: string | undefined;
|
|
65
|
+
borderStyle?: string | undefined;
|
|
66
|
+
borderColor?: string | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
borderRight?: {
|
|
69
|
+
borderWidth?: string | undefined;
|
|
70
|
+
borderStyle?: string | undefined;
|
|
71
|
+
borderColor?: string | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
borderBottom?: {
|
|
74
|
+
borderWidth?: string | undefined;
|
|
75
|
+
borderStyle?: string | undefined;
|
|
76
|
+
borderColor?: string | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
borderTop?: {
|
|
79
|
+
borderWidth?: string | undefined;
|
|
80
|
+
borderStyle?: string | undefined;
|
|
81
|
+
borderColor?: string | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
borderTopRightRadius?: string | undefined;
|
|
84
|
+
borderTopLeftRadius?: string | undefined;
|
|
85
|
+
borderBottomRightRadius?: string | undefined;
|
|
86
|
+
borderBottomLeftRadius?: string | undefined;
|
|
87
|
+
borderAllRadius?: string | undefined;
|
|
88
|
+
columnwidthConfigure?: import('@gct-paas/core').tableColumnWidthEnum | undefined;
|
|
89
|
+
columnwidth?: number | undefined;
|
|
90
|
+
columnFontStyleByRule?: {
|
|
91
|
+
displayRule: string;
|
|
92
|
+
contentFont: {
|
|
93
|
+
fontSize: string;
|
|
94
|
+
bold: boolean;
|
|
95
|
+
italic: boolean;
|
|
96
|
+
textDecoration: import('@gct-paas/core').TextDecoration;
|
|
97
|
+
color: string;
|
|
98
|
+
align: "left" | "right" | "justify";
|
|
99
|
+
};
|
|
100
|
+
tagStyle: {
|
|
101
|
+
color?: string | undefined;
|
|
102
|
+
tagType?: import('@gct-paas/core').TagTypeEnum | undefined;
|
|
103
|
+
};
|
|
104
|
+
progressStyle: {
|
|
105
|
+
color: string;
|
|
106
|
+
tagType: import('@gct-paas/core').ProgressTypeEnum;
|
|
107
|
+
};
|
|
108
|
+
tagType: import('@gct-paas/core').tagEnum;
|
|
109
|
+
tagStyleOpen: boolean;
|
|
110
|
+
}[] | undefined;
|
|
111
|
+
columnBackgroundByRule?: {
|
|
112
|
+
displayRule: string;
|
|
113
|
+
backgroundColor?: string | undefined;
|
|
114
|
+
}[] | undefined;
|
|
115
|
+
tableheight?: number | undefined;
|
|
116
|
+
tableheightConfigure?: import('@gct-paas/core').tableColumnWidthEnum | undefined;
|
|
117
|
+
enableHeaderBGColor?: boolean | undefined;
|
|
118
|
+
} | undefined;
|
|
119
|
+
pageConfig?: {
|
|
120
|
+
title?: string | undefined;
|
|
121
|
+
i18n?: {
|
|
122
|
+
key?: string | undefined;
|
|
123
|
+
title?: string | undefined;
|
|
124
|
+
} | undefined;
|
|
125
|
+
hasFooter?: boolean | undefined;
|
|
126
|
+
} | undefined;
|
|
127
|
+
pageName?: string | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
pageStyle?: RuntimePageJson["pageStyle"];
|
|
130
|
+
pageConfig?: RuntimePageJson["pageConfig"];
|
|
131
|
+
pageName?: string;
|
|
132
|
+
} | {
|
|
133
|
+
pageStyle?: {
|
|
134
|
+
position?: string | undefined;
|
|
135
|
+
top?: string | undefined;
|
|
136
|
+
left?: string | undefined;
|
|
137
|
+
right?: string | undefined;
|
|
138
|
+
bottom?: string | undefined;
|
|
139
|
+
width?: string | undefined;
|
|
140
|
+
height?: string | undefined;
|
|
141
|
+
maxHeight?: string | undefined;
|
|
142
|
+
backgroundColor?: string | undefined;
|
|
143
|
+
marginAll?: string | undefined;
|
|
144
|
+
marginTop?: string | undefined;
|
|
145
|
+
marginRight?: string | undefined;
|
|
146
|
+
marginBottom?: string | undefined;
|
|
147
|
+
marginLeft?: string | undefined;
|
|
148
|
+
paddingAll?: string | undefined;
|
|
149
|
+
paddingTop?: string | undefined;
|
|
150
|
+
paddingRight?: string | undefined;
|
|
151
|
+
paddingBottom?: string | undefined;
|
|
152
|
+
paddingLeft?: string | undefined;
|
|
153
|
+
labelFont?: {
|
|
154
|
+
fontSize: string;
|
|
155
|
+
bold: boolean;
|
|
156
|
+
italic: boolean;
|
|
157
|
+
textDecoration: import('@gct-paas/core').TextDecoration;
|
|
158
|
+
color: string;
|
|
159
|
+
align: "left" | "right" | "justify";
|
|
160
|
+
} | undefined;
|
|
161
|
+
contentFont?: {
|
|
162
|
+
fontSize: string;
|
|
163
|
+
bold: boolean;
|
|
164
|
+
italic: boolean;
|
|
165
|
+
textDecoration: import('@gct-paas/core').TextDecoration;
|
|
166
|
+
color: string;
|
|
167
|
+
align: "left" | "right" | "justify";
|
|
168
|
+
} | undefined;
|
|
169
|
+
tagStyle?: {
|
|
170
|
+
color?: string | undefined;
|
|
171
|
+
tagType?: import('@gct-paas/core').TagTypeEnum | undefined;
|
|
172
|
+
} | undefined;
|
|
173
|
+
tagStyleOpen?: boolean | undefined;
|
|
174
|
+
borderAll?: {
|
|
175
|
+
borderWidth?: string | undefined;
|
|
176
|
+
borderStyle?: string | undefined;
|
|
177
|
+
borderColor?: string | undefined;
|
|
178
|
+
} | undefined;
|
|
179
|
+
borderLeft?: {
|
|
180
|
+
borderWidth?: string | undefined;
|
|
181
|
+
borderStyle?: string | undefined;
|
|
182
|
+
borderColor?: string | undefined;
|
|
183
|
+
} | undefined;
|
|
184
|
+
borderRight?: {
|
|
185
|
+
borderWidth?: string | undefined;
|
|
186
|
+
borderStyle?: string | undefined;
|
|
187
|
+
borderColor?: string | undefined;
|
|
188
|
+
} | undefined;
|
|
189
|
+
borderBottom?: {
|
|
190
|
+
borderWidth?: string | undefined;
|
|
191
|
+
borderStyle?: string | undefined;
|
|
192
|
+
borderColor?: string | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
borderTop?: {
|
|
195
|
+
borderWidth?: string | undefined;
|
|
196
|
+
borderStyle?: string | undefined;
|
|
197
|
+
borderColor?: string | undefined;
|
|
198
|
+
} | undefined;
|
|
199
|
+
borderTopRightRadius?: string | undefined;
|
|
200
|
+
borderTopLeftRadius?: string | undefined;
|
|
201
|
+
borderBottomRightRadius?: string | undefined;
|
|
202
|
+
borderBottomLeftRadius?: string | undefined;
|
|
203
|
+
borderAllRadius?: string | undefined;
|
|
204
|
+
columnwidthConfigure?: import('@gct-paas/core').tableColumnWidthEnum | undefined;
|
|
205
|
+
columnwidth?: number | undefined;
|
|
206
|
+
columnFontStyleByRule?: {
|
|
207
|
+
displayRule: string;
|
|
208
|
+
contentFont: {
|
|
209
|
+
fontSize: string;
|
|
210
|
+
bold: boolean;
|
|
211
|
+
italic: boolean;
|
|
212
|
+
textDecoration: import('@gct-paas/core').TextDecoration;
|
|
213
|
+
color: string;
|
|
214
|
+
align: "left" | "right" | "justify";
|
|
215
|
+
};
|
|
216
|
+
tagStyle: {
|
|
217
|
+
color?: string | undefined;
|
|
218
|
+
tagType?: import('@gct-paas/core').TagTypeEnum | undefined;
|
|
219
|
+
};
|
|
220
|
+
progressStyle: {
|
|
221
|
+
color: string;
|
|
222
|
+
tagType: import('@gct-paas/core').ProgressTypeEnum;
|
|
223
|
+
};
|
|
224
|
+
tagType: import('@gct-paas/core').tagEnum;
|
|
225
|
+
tagStyleOpen: boolean;
|
|
226
|
+
}[] | undefined;
|
|
227
|
+
columnBackgroundByRule?: {
|
|
228
|
+
displayRule: string;
|
|
229
|
+
backgroundColor?: string | undefined;
|
|
230
|
+
}[] | undefined;
|
|
231
|
+
tableheight?: number | undefined;
|
|
232
|
+
tableheightConfigure?: import('@gct-paas/core').tableColumnWidthEnum | undefined;
|
|
233
|
+
enableHeaderBGColor?: boolean | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
pageConfig?: {
|
|
236
|
+
title?: string | undefined;
|
|
237
|
+
i18n?: {
|
|
238
|
+
key?: string | undefined;
|
|
239
|
+
title?: string | undefined;
|
|
240
|
+
} | undefined;
|
|
241
|
+
hasFooter?: boolean | undefined;
|
|
242
|
+
} | undefined;
|
|
243
|
+
pageName?: string | undefined;
|
|
244
|
+
}>;
|
|
245
|
+
/**页面信息 */
|
|
246
|
+
export declare const getPageTitle: Readonly<import('vue').Ref<string | undefined, string | undefined>>;
|
|
247
|
+
/**页面全局事件 */
|
|
248
|
+
export declare class Globals {
|
|
249
|
+
/**模态框缓存 */
|
|
250
|
+
static modalsCache: Record<string, RuntimePageJson['modals'][number]>;
|
|
251
|
+
/**
|
|
252
|
+
* 上下文缓存
|
|
253
|
+
*/
|
|
254
|
+
static pageID: string;
|
|
255
|
+
static permissions: Record<string, string>;
|
|
256
|
+
static ContextCache: IObject;
|
|
257
|
+
/**常量刷新锁 */
|
|
258
|
+
static startRuning: boolean;
|
|
259
|
+
/**全局钩子 */
|
|
260
|
+
static globalHookCaches: {
|
|
261
|
+
pageMounted: (() => void)[];
|
|
262
|
+
pageActivated: (() => void)[];
|
|
263
|
+
pageDestroyed: (() => void)[];
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* 设置模态框
|
|
267
|
+
* @param list
|
|
268
|
+
*/
|
|
269
|
+
static setModals(list?: RuntimePageJson['modals']): void;
|
|
270
|
+
/**获取模态框信息 */
|
|
271
|
+
static getModalById(key?: string): Promise<import('@gct-paas/schema').RuntimeModal>;
|
|
272
|
+
/**
|
|
273
|
+
* 角色权限
|
|
274
|
+
* @param id 组件标识
|
|
275
|
+
*/
|
|
276
|
+
static getPremission(id?: string): boolean;
|
|
277
|
+
/**
|
|
278
|
+
*设置组件权限
|
|
279
|
+
* @param key 权限标识
|
|
280
|
+
* @param id 组件标识
|
|
281
|
+
*/
|
|
282
|
+
static setPremission(key: string, id: string): void;
|
|
283
|
+
static setContextByKey(context: IObject, key?: string): void;
|
|
284
|
+
static getContextByKey(key?: string): any;
|
|
285
|
+
/**
|
|
286
|
+
*获取页面变量
|
|
287
|
+
*/
|
|
288
|
+
static initvars(): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* 获取APP全局钩子
|
|
291
|
+
*/
|
|
292
|
+
static inithooks(): Promise<void>;
|
|
293
|
+
static initPermission(permissions: IObject): Promise<void>;
|
|
294
|
+
static initGlobalS(data: IObject): Promise<void>;
|
|
295
|
+
static getGlobalVar(id: string): any;
|
|
296
|
+
static setGlobalVar(id: string, value: string): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* 获取页面变量
|
|
299
|
+
* @param key
|
|
300
|
+
* @returns
|
|
301
|
+
*/
|
|
302
|
+
static getPageVar(key: string): any;
|
|
303
|
+
/**
|
|
304
|
+
*设置页面变量
|
|
305
|
+
* @param key
|
|
306
|
+
* @param value
|
|
307
|
+
*/
|
|
308
|
+
static setPageVar(key: string, value: string): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* 获取页面全局变量老版本兼容问题暂时不删除 后续不维护
|
|
311
|
+
* @param key
|
|
312
|
+
* @returns
|
|
313
|
+
*/
|
|
314
|
+
static getPageGlobalVar(key: string): any;
|
|
315
|
+
/**设置页面变量老版本 兼容问题暂时不删除 后续不维护*/
|
|
316
|
+
static setPageGlobalVar(key: string, value: string): void;
|
|
317
|
+
static initPageByid(id: string, pageType?: PageTypeEnum): Promise<{
|
|
318
|
+
res: import('@gct-paas/api/apaas').PadPageResponse;
|
|
319
|
+
data: RuntimePageJson;
|
|
320
|
+
name: string | undefined;
|
|
321
|
+
}>;
|
|
322
|
+
static initHistoryByid(id: string): Promise<{
|
|
323
|
+
res: import('@gct-paas/api/apaas').PageDesignerLogResponse;
|
|
324
|
+
data: any;
|
|
325
|
+
name: string | undefined;
|
|
326
|
+
}>;
|
|
327
|
+
/**注册钩子 */
|
|
328
|
+
static usePageHooks(Event: IObject, pageEvents: RuntimePageJson['pageEvents'], globalEvents: RuntimePageJson['globalEvents'], pageCallback: ((Event: IObject) => Promise<void>) | undefined): {
|
|
329
|
+
pageload: import('vue').Ref<boolean, boolean>;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
export declare const getPremission: typeof Globals.getPremission;
|
|
@@ -0,0 +1,306 @@
|
|
|
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
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const pageGlobaVariables = ref({});
|
|
19
|
+
const globalVarCaches = ref({});
|
|
20
|
+
const formMap = ref({});
|
|
21
|
+
function setFormData(key, formData) {
|
|
22
|
+
formMap.value[key] = formData;
|
|
23
|
+
}
|
|
24
|
+
const pageDataforJson = ref({
|
|
25
|
+
pageStyle: {},
|
|
26
|
+
pageConfig: {},
|
|
27
|
+
pageName: ""
|
|
28
|
+
});
|
|
29
|
+
const getPageTitle = toRef(() => {
|
|
30
|
+
const { title } = pageDataforJson.value.pageConfig || {};
|
|
31
|
+
return title;
|
|
32
|
+
});
|
|
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 };
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
26
|
+
};
|
|
27
|
+
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
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { verificationData };
|