@gct-paas/render 0.1.4-dev.10

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 (59) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1 -0
  4. package/dist/index.esm.min.mjs +7825 -0
  5. package/dist/index.min.cjs +17 -0
  6. package/dist/index.system.min.js +17 -0
  7. package/es/Event/Dependency/controller.d.ts +13 -0
  8. package/es/Event/Dependency/controller.mjs +97 -0
  9. package/es/Event/Dependency/displayRule.d.ts +19 -0
  10. package/es/Event/Dependency/displayRule.mjs +76 -0
  11. package/es/Event/Dependency/useDependency.d.ts +7 -0
  12. package/es/Event/Dependency/useDependencyToShow.d.ts +10 -0
  13. package/es/Event/Dependency/useDependencyToShow.mjs +109 -0
  14. package/es/Event/baseEvent.d.ts +155 -0
  15. package/es/Event/baseEvent.mjs +430 -0
  16. package/es/Event/bizServiceRequest.d.ts +26 -0
  17. package/es/Event/bizServiceRequest.mjs +47 -0
  18. package/es/Event/eventType.d.ts +20 -0
  19. package/es/Event/index.d.ts +4 -0
  20. package/es/Event/utils/appRedis.d.ts +29 -0
  21. package/es/Event/utils/appRedis.mjs +50 -0
  22. package/es/Event/utils/globalLoading.d.ts +13 -0
  23. package/es/Event/utils/globalLoading.mjs +103 -0
  24. package/es/Event/utils/processRovedInfo.d.ts +100 -0
  25. package/es/Event/utils/processRovedInfo.mjs +297 -0
  26. package/es/Event/utils/runGlobalByPage.d.ts +333 -0
  27. package/es/Event/utils/runGlobalByPage.mjs +306 -0
  28. package/es/Event/utils/verificationVar.d.ts +2 -0
  29. package/es/Event/utils/verificationVar.mjs +42 -0
  30. package/es/enums/index.d.ts +14 -0
  31. package/es/enums/index.mjs +6 -0
  32. package/es/hooks/useStorageRef.d.ts +9 -0
  33. package/es/hooks/useStorageRef.mjs +33 -0
  34. package/es/index.d.ts +3 -0
  35. package/es/index.mjs +23 -0
  36. package/es/register/index.d.ts +1 -0
  37. package/es/register/render-register/render-register.d.ts +54 -0
  38. package/es/register/render-register/render-register.mjs +59 -0
  39. package/es/types/index.d.ts +7 -0
  40. package/es/utils/cacheAdapter.d.ts +7 -0
  41. package/es/utils/cacheAdapter.mjs +57 -0
  42. package/es/utils/expression/index.d.ts +6 -0
  43. package/es/utils/expression/index.mjs +133 -0
  44. package/es/utils/expression/regularExpression/methods.d.ts +77 -0
  45. package/es/utils/expression/regularExpression/methods.mjs +729 -0
  46. package/es/utils/field-attrs/basicAttrs.d.ts +12 -0
  47. package/es/utils/field-attrs/basicAttrs.mjs +82 -0
  48. package/es/utils/field-attrs/index.d.ts +6 -0
  49. package/es/utils/field-attrs/index.mjs +15 -0
  50. package/es/utils/get-ref-data.d.ts +1 -0
  51. package/es/utils/get-ref-data.mjs +62 -0
  52. package/es/utils/getFieldSchema.d.ts +26 -0
  53. package/es/utils/getFieldSchema.mjs +83 -0
  54. package/es/utils/index.d.ts +6 -0
  55. package/es/utils/model-transformer.d.ts +46 -0
  56. package/es/utils/model-transformer.mjs +77 -0
  57. package/es/utils/useStyle.d.ts +21 -0
  58. package/es/utils/useStyle.mjs +17 -0
  59. package/package.json +72 -0
@@ -0,0 +1,430 @@
1
+ import { t, INNER_EVENT, FormComponents } from '@gct-paas/core';
2
+ import { useStyleTag } from '@vueuse/core';
3
+ import BigNumberJS from 'bignumber.js';
4
+ import dayjs from 'dayjs';
5
+ import * as _ from 'lodash-es';
6
+ import { differenceBy, cloneDeep } from 'lodash-es';
7
+ import { toRaw } from 'vue';
8
+ import '../utils/field-attrs/basicAttrs.mjs';
9
+ import '@gct-paas/schema';
10
+ import { transformData, transformSourceData } from '../utils/model-transformer.mjs';
11
+ import '../utils/expression/index.mjs';
12
+ import 'qs';
13
+ import { BizService, $httpBizService, $request } from './bizServiceRequest.mjs';
14
+ import { ProcessAppRovedData } from './utils/processRovedInfo.mjs';
15
+ import { Globals } from './utils/runGlobalByPage.mjs';
16
+ import { globalLoading } from './utils/globalLoading.mjs';
17
+
18
+ class Events {
19
+ context;
20
+ searchVNodes;
21
+ cssData;
22
+ pageKey;
23
+ exports;
24
+ #Oberver;
25
+ #VNodes;
26
+ /**流程信息 */
27
+ ProcessAppRoved;
28
+ pageLayoutMode;
29
+ constructor({
30
+ js,
31
+ css,
32
+ pageKey,
33
+ ContextPc
34
+ }) {
35
+ this.cssData = this.#createCss(css);
36
+ this.searchVNodes = {};
37
+ this.exports = {};
38
+ this.#VNodes = {};
39
+ this.#Oberver = {};
40
+ this.context = new ContextPc({
41
+ $ref: this.getComponent.bind(this),
42
+ $asyncRef: this.getSyncComponent.bind(this)
43
+ });
44
+ this.#createFunction(js);
45
+ Globals.setContextByKey(this.context, pageKey);
46
+ this.pageKey = pageKey;
47
+ }
48
+ /**初始化流程节点信息 */
49
+ async runProcessBySaskId({
50
+ taskId,
51
+ processInstanceId,
52
+ examineAndApproveState,
53
+ refFormId
54
+ }) {
55
+ this.ProcessAppRoved = new ProcessAppRovedData({
56
+ taskId,
57
+ processInstanceId,
58
+ examineAndApproveState,
59
+ refFormId
60
+ });
61
+ await this.ProcessAppRoved.readyProcess();
62
+ }
63
+ #createCss(str, attr = {}) {
64
+ if (!str) return;
65
+ const { css, load, unload } = useStyleTag(str, attr);
66
+ return { css, load, unload };
67
+ }
68
+ /**保存所有组件的props*/
69
+ runContext(key, widget) {
70
+ this.context.gctWidgets[key] = widget;
71
+ }
72
+ /**触发内置事件 */
73
+ async runEventByName(eventName, events = {}, ...arg) {
74
+ const E = events[eventName];
75
+ let data;
76
+ if (!E) return;
77
+ if (Array.isArray(E)) {
78
+ data = await builtInEvents(E, this.context, arg);
79
+ } else {
80
+ const fun = this.exports[E.name];
81
+ if (!fun) throw `函数${E.name}不存在`;
82
+ data = await fun(...arg, toRaw(E.extraParams));
83
+ }
84
+ return data;
85
+ }
86
+ /**执行公共函数事件 */
87
+ async runExportByName(eventName, ...arg) {
88
+ try {
89
+ const fun = this.exports[eventName];
90
+ if (!fun) throw `函数${eventName}不存在`;
91
+ return fun(...arg);
92
+ } catch (error) {
93
+ console.error(error);
94
+ }
95
+ }
96
+ /**异步执行公共函数事件 */
97
+ async runAsyncExportByName(eventName, ...arg) {
98
+ try {
99
+ const fun = this.exports[eventName];
100
+ if (!fun) throw `函数${eventName}不存在`;
101
+ await this.getReadyByFun(fun);
102
+ return fun(...arg);
103
+ } catch (error) {
104
+ console.error(error);
105
+ }
106
+ }
107
+ #createFunction(jsJSON) {
108
+ if (!jsJSON) return;
109
+ try {
110
+ const fun = new Function("exports", "CTX", jsJSON);
111
+ fun(this.exports, this.context);
112
+ } catch (error) {
113
+ console.error(error, "createFunction");
114
+ }
115
+ }
116
+ // 把小组件的实例按照key存起来
117
+ initNode(key, options) {
118
+ if (key) {
119
+ this.#VNodes[key] = options;
120
+ this.#publish(key, options);
121
+ }
122
+ }
123
+ /**组件销毁 */
124
+ destroyNode(key) {
125
+ delete this.#VNodes[key];
126
+ delete this.#Oberver[key];
127
+ }
128
+ // 执行查询
129
+ initSearchs(key, callback, comId) {
130
+ if (!key) return;
131
+ if (this.searchVNodes[key]) {
132
+ const item = this.searchVNodes[key].find((i) => i.comId === comId);
133
+ if (item) {
134
+ item.callback = callback;
135
+ } else {
136
+ this.searchVNodes[key].push({ callback, comId });
137
+ }
138
+ } else {
139
+ this.searchVNodes[key] = [{ callback, comId }];
140
+ }
141
+ }
142
+ // 取消注册的查询
143
+ cancelInitSearchs(key, comId) {
144
+ if (!key || !this.searchVNodes[key]) return;
145
+ this.searchVNodes[key] = this.searchVNodes[key].filter(
146
+ (i) => i.comId !== comId
147
+ );
148
+ if (this.searchVNodes[key].length === 0) {
149
+ delete this.searchVNodes[key];
150
+ }
151
+ }
152
+ runTableBySearch(key, data) {
153
+ const funArg = this.searchVNodes[key] || [];
154
+ funArg.forEach(({ callback }) => callback(data));
155
+ }
156
+ /**
157
+ * 组件初始化订阅
158
+ * @param {*} key 组件唯一key
159
+ * @param {*} eventName 事件名称
160
+ */
161
+ #subscribeready(key, callback) {
162
+ const options = this.#VNodes[key];
163
+ if (options) {
164
+ callback(key, options);
165
+ } else if (this.#Oberver[key]) {
166
+ this.#Oberver[key].push(callback);
167
+ } else {
168
+ this.#Oberver[key] = [callback];
169
+ }
170
+ }
171
+ /**
172
+ *
173
+ * @param key 执行回调
174
+ */
175
+ #publish(key, options) {
176
+ if (this.#Oberver[key]) {
177
+ this.#Oberver[key].forEach((fun) => {
178
+ fun(options);
179
+ });
180
+ }
181
+ }
182
+ /**
183
+ * 获取组件公用方法 getComponent(identity),根据组件唯一标识获取组件。
184
+ * @param {*} key
185
+ * @returns
186
+ */
187
+ getComponent(key) {
188
+ const options = this.#VNodes[key];
189
+ if (options) {
190
+ return new GctComponent(key, options);
191
+ }
192
+ console.error(key + "组件不存在或者未初始化");
193
+ }
194
+ /**
195
+ * 获取组件公用方法 getComponent(identity),根据组件唯一标识获取组件。
196
+ * @param {*} key
197
+ * @returns
198
+ */
199
+ getSyncComponent(key) {
200
+ if (!key) return Promise.reject("标识不能为空");
201
+ const options = this.#VNodes[key];
202
+ if (options) {
203
+ return Promise.resolve(new GctComponent(key, options));
204
+ }
205
+ return new Promise((resolve, reject) => {
206
+ const timer = setTimeout(() => {
207
+ reject(key + "不存在或者被隐藏");
208
+ }, 3e4);
209
+ this.#subscribeready(key, (options2) => {
210
+ clearTimeout(timer);
211
+ resolve(new GctComponent(key, options2));
212
+ });
213
+ });
214
+ }
215
+ /**
216
+ * 指定函数中使用到的组件初始化后才执行
217
+ * @param fun
218
+ * @returns
219
+ */
220
+ async getReadyByFun(fun) {
221
+ if (typeof fun !== "function") return Promise.reject("参数必须是函数");
222
+ const funstr = String(fun);
223
+ const P = funstr.match(/\$ref\((["'A-Za-z0-9_-]+)\)/g)?.map((i) => {
224
+ const key = i.match(/\$ref\(['|"]([A-Za-z0-9_-]+)['|"]\)/)?.[1];
225
+ return this.getSyncComponent(key);
226
+ }) || [];
227
+ await Promise.all(P);
228
+ }
229
+ /**
230
+ * 流程处理
231
+ * @param processDateValue
232
+ * @param data
233
+ */
234
+ async processHandle(data, {
235
+ opinion,
236
+ reassignId,
237
+ signature,
238
+ countersignUserIds,
239
+ button
240
+ }) {
241
+ const { taskId, processInstanceId } = this.ProcessAppRoved;
242
+ const processData = {
243
+ procInstId: processInstanceId,
244
+ data,
245
+ opinion,
246
+ button,
247
+ countersignUserIds,
248
+ taskId,
249
+ signature,
250
+ reassignId
251
+ };
252
+ await _gct.api.apaas.pmProcessEngine.postProcExecute(processData);
253
+ }
254
+ /**流程审批校验 */
255
+ async checkedProcess(formProcessId) {
256
+ const { processId } = this.ProcessAppRoved || {};
257
+ if (!processId)
258
+ return Promise.reject(t("sys.process.pleaseInitiateTheProcessFirst"));
259
+ if (formProcessId !== processId)
260
+ return Promise.reject(t("sys.process.processInstanceMismatch"));
261
+ }
262
+ }
263
+ class Context {
264
+ /**根据key获取当前组件 */
265
+ $ref;
266
+ /**根据key异步获取获取组件 */
267
+ $asyncRef;
268
+ /**根据id获取模态框 */
269
+ $getModal;
270
+ /**关闭当前上下文模态框 */
271
+ $closeModal;
272
+ /**调用第三方服务 */
273
+ $customBizService = BizService;
274
+ /**组件id和widget 的map */
275
+ gctWidgets = {};
276
+ constructor({ $ref, $asyncRef }) {
277
+ this.$asyncRef = $asyncRef;
278
+ this.$ref = $ref;
279
+ }
280
+ /**ctx 下的工具函数 */
281
+ $utility = {
282
+ _,
283
+ cloneDeep,
284
+ differenceBy,
285
+ dayjs,
286
+ BigNumber: BigNumberJS,
287
+ plus(a, b) {
288
+ return new BigNumberJS(a).plus(new BigNumberJS(b)).toNumber();
289
+ },
290
+ minus(a, b) {
291
+ return new BigNumberJS(a).minus(new BigNumberJS(b)).toNumber();
292
+ },
293
+ multipliedBy(a, b) {
294
+ return new BigNumberJS(a).multipliedBy(new BigNumberJS(b)).toNumber();
295
+ },
296
+ div(a, b) {
297
+ return new BigNumberJS(a).div(new BigNumberJS(b)).toNumber();
298
+ },
299
+ /**表格数据data,dict翻译 */
300
+ transformSourceData,
301
+ /**表单数据data,dict翻译*/
302
+ transformData
303
+ };
304
+ $httpBizService = $httpBizService;
305
+ $request = $request;
306
+ /**全局loading */
307
+ $loading = globalLoading;
308
+ $getPremission(id) {
309
+ return Globals.getPremission(id);
310
+ }
311
+ /**
312
+ *
313
+ * @param key 组件权限标识
314
+ * @param id 组件id
315
+ */
316
+ $setPremission(key, id) {
317
+ Globals.setPremission(key, id);
318
+ }
319
+ /**获取应用全局变量 */
320
+ $getAppGlobalVar(id) {
321
+ return Globals.getGlobalVar(id);
322
+ }
323
+ /**设置应用全局变量 */
324
+ $setAppGlobalVar(id, value) {
325
+ Globals.setGlobalVar(id, value);
326
+ }
327
+ /**获取页面全局变量老版本兼容问题暂时不删除 后续不维护*/
328
+ $getPageGlobalVar(id) {
329
+ return Globals.getPageGlobalVar(id);
330
+ }
331
+ /**设置页面变量老版本 兼容问题暂时不删除 后续不维护 */
332
+ $setPageGlobalVar(id, value) {
333
+ Globals.setPageGlobalVar(id, value);
334
+ }
335
+ /**获取页面全局变量 */
336
+ $getPageVar(id) {
337
+ return Globals.getPageVar(id);
338
+ }
339
+ /**设置页面全局变量 */
340
+ $setPageVar(id, value) {
341
+ Globals.setPageVar(id, value);
342
+ }
343
+ /**根据模态框id 获取上下文 id不传默认页面上下文*/
344
+ $getCtxById(modalKey) {
345
+ return Globals.getContextByKey(modalKey);
346
+ }
347
+ /**设置组件的属性 */
348
+ $setPropsByKey(key, fromProp) {
349
+ const toProps = this.gctWidgets[key]?.props;
350
+ if (!toProps) return;
351
+ for (const k in fromProp) {
352
+ toProps[k] = fromProp[k];
353
+ }
354
+ }
355
+ /**获取组件的属性 */
356
+ $getPropsByKey(key, PropsKey = [], root) {
357
+ const widget = this.gctWidgets[key];
358
+ if (!widget) return {};
359
+ const props = root || !widget.props ? widget : widget.props;
360
+ if (typeof PropsKey === "string") {
361
+ PropsKey = [PropsKey];
362
+ }
363
+ return PropsKey.reduce((pre, curr) => {
364
+ pre[curr] = props[curr];
365
+ return pre;
366
+ }, {});
367
+ }
368
+ }
369
+ class GctComponent {
370
+ modelKey;
371
+ getValue;
372
+ setValue;
373
+ /**提交 */
374
+ submit;
375
+ /**刷新 */
376
+ reload;
377
+ key;
378
+ constructor(key, options) {
379
+ this.key = key;
380
+ const elRef = options.elRef;
381
+ Object.keys(elRef).forEach((k) => {
382
+ this[k] = elRef[k];
383
+ });
384
+ }
385
+ }
386
+ async function builtInEvents(eventList, context, args) {
387
+ const allEvent = eventList.map(transformEventFun.bind(context, args));
388
+ await Promise.all(allEvent);
389
+ }
390
+ async function transformEventFun(args, item) {
391
+ const { name, refId, scopeId, modalTitle } = item;
392
+ const ids = modalTitle?.split(".") || [];
393
+ let widget;
394
+ if (ids.length > 1) {
395
+ const orgWidget = this.gctWidgets?.[ids[0]] || {};
396
+ const opes = [];
397
+ getAllOpe(opes, orgWidget);
398
+ widget = opes.find((i) => i.id === ids[1]) || {};
399
+ } else if (ids.length) {
400
+ widget = this.gctWidgets?.[ids[0]];
401
+ }
402
+ if (name === INNER_EVENT.OPEN_MODAL) {
403
+ await this.$getModal(refId).open({ title: widget?.props?.title });
404
+ }
405
+ if (name === INNER_EVENT.CLOSE_MODAL) {
406
+ if (refId) {
407
+ await this.$getModal(refId).close();
408
+ } else {
409
+ await this.$closeModal();
410
+ }
411
+ }
412
+ if (name === INNER_EVENT.REFRESH_TABLE) {
413
+ const com = await this.$getCtxById(scopeId).$asyncRef(refId);
414
+ await com.reload(args ? args[0] : null);
415
+ }
416
+ }
417
+ function getAllOpe(arr, widget) {
418
+ const children = widget.children || [];
419
+ for (const i of children) {
420
+ if (i.type && i.type == FormComponents.CustomButton) {
421
+ arr.push(i);
422
+ } else {
423
+ if (i.children?.length) {
424
+ getAllOpe(arr, i);
425
+ }
426
+ }
427
+ }
428
+ }
429
+
430
+ export { Context, Events, GctComponent };
@@ -0,0 +1,26 @@
1
+ import { BizServiceEnum, EntityModelCategoryEnum } from '@gct-paas/core';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ export declare const BizService: {
4
+ post: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
5
+ get: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
6
+ put: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
7
+ delete: (path: PathType, query?: IObject, data?: IObject, config?: AxiosRequestConfig) => Promise<unknown>;
8
+ };
9
+ /**
10
+ * 系统内置业务服务请求
11
+ * @param path
12
+ * @param params
13
+ * @param config
14
+ * @returns
15
+ */
16
+ export declare function $httpBizService(path: PathType, params: Record<string, unknown>, config?: AxiosRequestConfig): Promise<unknown>;
17
+ /**post 业务服务请求 */
18
+ export declare function $request(modelKey: string, action: PathType['action'], { body, query }?: IObject, config?: AxiosRequestConfig): Promise<unknown>;
19
+ type BizServiceParams = Record<string, unknown>;
20
+ export interface PathType {
21
+ key: string;
22
+ action: keyof typeof BizServiceEnum;
23
+ modelCategory?: EntityModelCategoryEnum;
24
+ }
25
+ export type BizServiceMethod = (path: PathType, params: BizServiceParams, ...args: unknown[]) => Promise<unknown>;
26
+ export {};
@@ -0,0 +1,47 @@
1
+ import { EntityModelCategoryEnum, BizServiceEnum } from '@gct-paas/core';
2
+
3
+ const bizServiceRequestHook = (api) => (path, query = {}, data = {}, config = {}) => {
4
+ return api(
5
+ {
6
+ modelKey: path.key,
7
+ bsKey: path.action,
8
+ modelCategory: path.modelCategory ?? EntityModelCategoryEnum.ENTITY
9
+ },
10
+ query,
11
+ data,
12
+ config
13
+ );
14
+ };
15
+ const BizService = {
16
+ post: bizServiceRequestHook(
17
+ _gct.api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey
18
+ ),
19
+ get: bizServiceRequestHook(
20
+ _gct.api.apaas.modelComprehensive.getBizServiceModelCategoryModelKeyBsKey
21
+ ),
22
+ put: bizServiceRequestHook(
23
+ _gct.api.apaas.modelComprehensive.putBizServiceModelCategoryModelKeyBsKey
24
+ ),
25
+ delete: bizServiceRequestHook(
26
+ _gct.api.apaas.modelComprehensive.deleteBizServiceModelCategoryModelKeyBsKey
27
+ )
28
+ };
29
+ async function $httpBizService(path, params, config = {}) {
30
+ const method = BizServiceEnum[path.action];
31
+ return BizService[method](path, params, config);
32
+ }
33
+ async function $request(modelKey, action, { body = {}, query = {} } = {}, config = {}) {
34
+ const res = await _gct.api.apaas.modelComprehensive.postBizServiceGeneralModelCategoryModelKeyBsKey(
35
+ {
36
+ bsKey: action,
37
+ modelKey,
38
+ modelCategory: EntityModelCategoryEnum.ENTITY
39
+ },
40
+ query,
41
+ body,
42
+ config
43
+ );
44
+ return res;
45
+ }
46
+
47
+ export { $httpBizService, $request, BizService };
@@ -0,0 +1,20 @@
1
+ import { FormComponents, ButtonTypeEnum } from '@gct-paas/core';
2
+ export interface InitNodeOptions {
3
+ /**组件方法 */
4
+ elRef: Record<string, FunctionType> | null;
5
+ /**组件类型 */
6
+ type: FormComponents;
7
+ }
8
+ export interface EventsConstructor {
9
+ js: string;
10
+ css: string;
11
+ pageKey?: string;
12
+ }
13
+ export interface processDateValue {
14
+ bizServiceKey: string;
15
+ button: ButtonTypeEnum;
16
+ message?: string;
17
+ processInstanceId?: string;
18
+ processKey: string;
19
+ }
20
+ export type FunctionType = (...arg: unknown[]) => unknown;
@@ -0,0 +1,4 @@
1
+ export { Globals, pageGlobaVariables, globalVarCaches, formMap, setFormData, pageDataforJson, getPageTitle, getPremission, } from './utils/runGlobalByPage';
2
+ export { Events, Context, GctComponent } from './baseEvent';
3
+ export { type EventsConstructor } from './eventType';
4
+ export * from './Dependency/useDependencyToShow';
@@ -0,0 +1,29 @@
1
+ import { UserLoginResp } from '@gct-paas/api/platform';
2
+ export declare class GlobaAppInfo {
3
+ /**环境变量 */
4
+ static ENV: string;
5
+ /**应用标识 */
6
+ static AID: string;
7
+ /**用户信息 */
8
+ static userInfo: UserLoginResp;
9
+ /**app初始化变量 */
10
+ static runApp({ userInfo, env, aid }: RunAppParams): void;
11
+ }
12
+ /**获取缓存变量 */
13
+ export declare const useCreateAppredis: <T = unknown>({ value: defaultValue, appredis, key: varKey, type, }: UseCreateAppredisOptions<T>) => GlobalVar<T>;
14
+ interface RunAppParams {
15
+ env: string;
16
+ aid: string;
17
+ userInfo: UserLoginResp;
18
+ }
19
+ interface GlobalVar<T = unknown> {
20
+ value: T;
21
+ type: unknown;
22
+ }
23
+ export interface UseCreateAppredisOptions<T = unknown> {
24
+ value: T;
25
+ appredis: boolean;
26
+ key: string;
27
+ type: unknown;
28
+ }
29
+ export {};
@@ -0,0 +1,50 @@
1
+ import { useGctSelect } from '../../hooks/useStorageRef.mjs';
2
+
3
+ class GlobaAppInfo {
4
+ /**环境变量 */
5
+ static ENV;
6
+ /**应用标识 */
7
+ static AID;
8
+ /**用户信息 */
9
+ static userInfo;
10
+ /**app初始化变量 */
11
+ static runApp({ userInfo, env, aid }) {
12
+ this.ENV = env;
13
+ this.AID = aid;
14
+ this.userInfo = userInfo;
15
+ }
16
+ }
17
+ const useCreateAppredis = ({
18
+ value: defaultValue,
19
+ appredis,
20
+ key: varKey,
21
+ type
22
+ }) => {
23
+ const isredis = GlobaAppInfo.ENV !== "dev" ? appredis : false;
24
+ const key = `${GlobaAppInfo.AID}_${GlobaAppInfo.userInfo?.userId}`;
25
+ const { cacheMap } = useGctSelect(key);
26
+ const globalVar = new Proxy(
27
+ { value: defaultValue, type },
28
+ {
29
+ get(target, name) {
30
+ if (isredis && name === "value") {
31
+ return cacheMap.value[varKey];
32
+ }
33
+ return Reflect.get(target, name);
34
+ },
35
+ set(target, name, value, receiver) {
36
+ if (isredis && name === "value") {
37
+ if (cacheMap.value[varKey]) {
38
+ cacheMap.value[varKey] = value;
39
+ } else {
40
+ cacheMap.value = { ...cacheMap.value, [varKey]: value };
41
+ }
42
+ }
43
+ return Reflect.set(target, name, value, receiver);
44
+ }
45
+ }
46
+ );
47
+ return globalVar;
48
+ };
49
+
50
+ export { GlobaAppInfo, useCreateAppredis };
@@ -0,0 +1,13 @@
1
+ declare class GlobalLoading {
2
+ static instance: GlobalLoading;
3
+ mask: HTMLDivElement;
4
+ container: HTMLDivElement;
5
+ spinner: HTMLDivElement;
6
+ constructor();
7
+ createLoadingElement(): void;
8
+ initStyle(): void;
9
+ show(): void;
10
+ hide(): void;
11
+ }
12
+ export declare const globalLoading: GlobalLoading;
13
+ export {};