@gct-paas/design 0.1.4-dev.14 → 0.1.4-dev.16

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.
@@ -9,6 +9,7 @@ export declare const MobileContainer: import('vue').DefineComponent<import('vue'
9
9
  };
10
10
  title: {
11
11
  type: StringConstructor;
12
+ default: () => any;
12
13
  };
13
14
  }>, {
14
15
  ns: import('@gct-paas/core').Namespace;
@@ -24,8 +25,10 @@ export declare const MobileContainer: import('vue').DefineComponent<import('vue'
24
25
  };
25
26
  title: {
26
27
  type: StringConstructor;
28
+ default: () => any;
27
29
  };
28
30
  }>> & Readonly<{}>, {
31
+ title: string;
29
32
  headerBgColor: boolean;
30
33
  showTitleBar: boolean;
31
34
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -15,7 +15,10 @@ var MobileContainer = /* @__PURE__ */ defineComponent({
15
15
  type: Boolean,
16
16
  default: true
17
17
  },
18
- title: { type: String }
18
+ title: {
19
+ type: String,
20
+ default: () => _gct.store.appInfo.name
21
+ }
19
22
  },
20
23
  setup() {
21
24
  return {
@@ -39,7 +39,7 @@ export declare const currentPanel: Ref<PanelEnum>;
39
39
  * 加载页面信息
40
40
  * @returns
41
41
  */
42
- export declare function loadPageInfo(_app: App): Promise<void>;
42
+ export declare function loadPageInfo(app: App): Promise<void>;
43
43
  /**
44
44
  * 初始化界面占用信息
45
45
  */
@@ -1,6 +1,7 @@
1
1
  import { PageTypeEnum } from "../../../constant/page-designer.mjs";
2
2
  import "../../../constant/index.mjs";
3
3
  import { platform } from "../../../utils/design-view/index.mjs";
4
+ import { DesignPluginPgkUtil } from "../../../utils/design-plugin-pkg-util/design-plugin-pkg-util.mjs";
4
5
  import { createWidgetByType } from "../../../utils/schema/index.mjs";
5
6
  import "../../../utils/index.mjs";
6
7
  import "../design-state.mjs";
@@ -28,9 +29,9 @@ var currentPanel = ref(PanelEnum.PAGE);
28
29
  * 加载页面信息
29
30
  * @returns
30
31
  */
31
- async function loadPageInfo(_app) {
32
+ async function loadPageInfo(app) {
32
33
  const { initToolkitWidgets } = useToolkit();
33
- const { setPageJson, loadPageDesignHistoryList, emitCache, pageJson, savePageJsonSnapshot } = useDesigner();
34
+ const { setPageJson, loadPageDesignHistoryList, emitCache, pageJson, setPluginConfigs, savePageJsonSnapshot } = useDesigner();
34
35
  const { historyUtils } = useCacheHistory();
35
36
  platform.value = _gct.store.context.platform || Platform.WEB;
36
37
  const pid = _gct.store.context.pid || "";
@@ -41,10 +42,17 @@ async function loadPageInfo(_app) {
41
42
  designerJson: ""
42
43
  };
43
44
  else pageInfo.value = platform.value === Platform.WEB ? await _api.apaas.webpage.getInfo({ id: _gct.store.context.pid }) : platform.value === Platform.PAD ? await _api.apaas.padPage.getInfo({ id: _gct.store.context.pid }) : await _api.apaas.mobilePage.getInfo({ id: _gct.store.context.pid });
45
+ const [configs] = await DesignPluginPgkUtil.loadDesignPlugin(app, platform.value, _gct.store.appInfo.suiteKey ? [_gct.store.appInfo.suiteKey] : void 0);
46
+ setPluginConfigs([configs]);
44
47
  if (!historyUtils.isHistoryInfoExist(_gct.store.context.pid)) historyUtils.init({ historyId: _gct.store.context.pid ?? "" });
45
48
  if (pageInfo.value.designerJson && !isNil(pageInfo.value.designerJson) && !isEmpty(pageInfo.value.designerJson)) {
46
49
  const _json = JSON.parse(pageInfo.value.designerJson);
47
- if (_json && _json.plugins) {}
50
+ if (_json && _json.plugins) {
51
+ const items = _json.plugins.filter((item) => {
52
+ return configs.findIndex((config) => config.key === item.key) === -1;
53
+ });
54
+ await DesignPluginPgkUtil.loadDesignDeletedPlugins(platform.value, items);
55
+ }
48
56
  if (!_json.pageConfig) _json.pageConfig = {
49
57
  title: "",
50
58
  i18n: {},
package/es/index.mjs CHANGED
@@ -18,7 +18,7 @@ import { deptFilter, formulaFilter } from "./utils/field-filter/index.mjs";
18
18
  import { openFormulaEditorByDesign } from "./utils/formula-editor-design/formula-editor-design.mjs";
19
19
  import { findAllChildrenTypes } from "./utils/find-deep-types/find-deep-types.mjs";
20
20
  import { createWidgetProvider, onWidgetInfoInit } from "./utils/init-widget-info/init-widget-info.mjs";
21
- import { PluginPgkUtil } from "./utils/plugin-pkg-util/plugin-pkg-util.mjs";
21
+ import { DesignPluginPgkUtil } from "./utils/design-plugin-pkg-util/design-plugin-pkg-util.mjs";
22
22
  import { createWidgetByType } from "./utils/schema/index.mjs";
23
23
  import { buildRunJs, initMethodMap } from "./utils/transform-js/transform-js.mjs";
24
24
  import { flatten } from "./utils/flatten.mjs";
@@ -90,4 +90,4 @@ function onInit() {
90
90
  }
91
91
  onInit();
92
92
  //#endregion
93
- export { BaseDate, BaseSearch, CategoryEnum, ControllerType, DesignContainerNode, DesignEditorNode, DesignEditorType, DesignItemActionTag, DesignItemAttribute, DesignNode, DesignNodePrefix, DesignNodeType, DesignSaveTip, DesignStepCheck, DesignViewHooks, DesignViewLayout, DesignViewPrefix, DesignerRegister, FieldCascader_default as FieldCascader, FieldSchema, InsertNodeMode, MaterialGroup, MaterialRegister, MenuClickEvent, ModalNameEditor, ModelTypeEnum, NotMask, PageTypeEnum, PluginPgkUtil, ProcessTypeEnum, SCREditorUtils, ScriptTypeEnum, user_lock_default as UserLock, user_occupy_default as UserOccupy, baseBtnEditor, baseBtnProp, basicAttrsUtils, basicFieldEditor, beginDrag, BTN_TYPE_COLOR as btnTypeColor, buildRunJs, buildRuntimeJson, buttonEditor, buttonProps, buttonStyleEditor, commonStyle, createWidgetByType, createWidgetProvider, currentPanel, customMenu, deptFilter, designCreateAppVue, designInterceptors, designRegister, designSetupApp, destroyOccupyTimer, deviceEvent, displayEditor, displayProps, explainEditor, findAllChildrenTypes, fixedAlignEditor, flatten, formItemProps, formulaFilter, getAutofillEditor, getBindCmpTypeEditor, getInputAttrEditor, getSearchOptions, hiddenButtonProps, initFieldWidgetRuntime, initMethodMap, isModified, loadPageInfo, loadPageOccupyInfo, loading, lockPage, methodMap, modal_exports as modalCfg, modalDesignId, modalDesignState, modalInfo, multiFieldEditor, newKeyTag, noMore, nodeContainerProps, nodeEditorProps, nodeProps, notNeedPxStyle, occupyPage, onWidgetInfoInit, openFormulaEditorByDesign, pageDesignHistoryList, pageInfo, pageJson, pageJsonSnapshot, pageNo, pageOccupyInfo, pagePermissions, permissionEditor, placeholderEditor, platform, pluginConfigs, PRESET_COLOR as presetColor, propEditorProps, propsToStyle, regRoot, regexEditor, rgba2hex, schemaToStyle, shadeColor, styleEditorProps, subTableModalId, subTableModalState, submitInHideEditor, togglePanel, transformField2Component, transformPageJson, unlockAvailable, uploadDraggerEditor, useAsyncFieldConfig, useAsyncFileAttrs, useAsyncOperateField, useCacheHistory, useCacheHistoryInner, useDesignCache, useDesignHistory, useDesignModal, useDesignPreview, useDesignSave, useDesigner, useDesignerController, useFieldTransfer, useGlobal, useKeyParser, useModelField, usePage, usePageOccupy, usePropEditor, useScope, useSelectedWidget, useStyle, useStyleEditor, useToolkit, useUserOccupy, useWidget, useWidgetQuery, useWidgetRegistry, validatorEditor, wfNodesModalId, wfNodesModalState, widgetInfo, widgetProps, widgetWrapperProps, workflowModalId, workflowModalState };
93
+ export { BaseDate, BaseSearch, CategoryEnum, ControllerType, DesignContainerNode, DesignEditorNode, DesignEditorType, DesignItemActionTag, DesignItemAttribute, DesignNode, DesignNodePrefix, DesignNodeType, DesignPluginPgkUtil, DesignSaveTip, DesignStepCheck, DesignViewHooks, DesignViewLayout, DesignViewPrefix, DesignerRegister, FieldCascader_default as FieldCascader, FieldSchema, InsertNodeMode, MaterialGroup, MaterialRegister, MenuClickEvent, ModalNameEditor, ModelTypeEnum, NotMask, PageTypeEnum, ProcessTypeEnum, SCREditorUtils, ScriptTypeEnum, user_lock_default as UserLock, user_occupy_default as UserOccupy, baseBtnEditor, baseBtnProp, basicAttrsUtils, basicFieldEditor, beginDrag, BTN_TYPE_COLOR as btnTypeColor, buildRunJs, buildRuntimeJson, buttonEditor, buttonProps, buttonStyleEditor, commonStyle, createWidgetByType, createWidgetProvider, currentPanel, customMenu, deptFilter, designCreateAppVue, designInterceptors, designRegister, designSetupApp, destroyOccupyTimer, deviceEvent, displayEditor, displayProps, explainEditor, findAllChildrenTypes, fixedAlignEditor, flatten, formItemProps, formulaFilter, getAutofillEditor, getBindCmpTypeEditor, getInputAttrEditor, getSearchOptions, hiddenButtonProps, initFieldWidgetRuntime, initMethodMap, isModified, loadPageInfo, loadPageOccupyInfo, loading, lockPage, methodMap, modal_exports as modalCfg, modalDesignId, modalDesignState, modalInfo, multiFieldEditor, newKeyTag, noMore, nodeContainerProps, nodeEditorProps, nodeProps, notNeedPxStyle, occupyPage, onWidgetInfoInit, openFormulaEditorByDesign, pageDesignHistoryList, pageInfo, pageJson, pageJsonSnapshot, pageNo, pageOccupyInfo, pagePermissions, permissionEditor, placeholderEditor, platform, pluginConfigs, PRESET_COLOR as presetColor, propEditorProps, propsToStyle, regRoot, regexEditor, rgba2hex, schemaToStyle, shadeColor, styleEditorProps, subTableModalId, subTableModalState, submitInHideEditor, togglePanel, transformField2Component, transformPageJson, unlockAvailable, uploadDraggerEditor, useAsyncFieldConfig, useAsyncFileAttrs, useAsyncOperateField, useCacheHistory, useCacheHistoryInner, useDesignCache, useDesignHistory, useDesignModal, useDesignPreview, useDesignSave, useDesigner, useDesignerController, useFieldTransfer, useGlobal, useKeyParser, useModelField, usePage, usePageOccupy, usePropEditor, useScope, useSelectedWidget, useStyle, useStyleEditor, useToolkit, useUserOccupy, useWidget, useWidgetQuery, useWidgetRegistry, validatorEditor, wfNodesModalId, wfNodesModalState, widgetInfo, widgetProps, widgetWrapperProps, workflowModalId, workflowModalState };
@@ -0,0 +1,28 @@
1
+ import { App } from 'vue';
2
+ import { Platform, PluginPgkUtil, LoadPluginResult } from '@gct-paas/core';
3
+ /**
4
+ * 插件包处理工具类
5
+ *
6
+ * @export
7
+ * @class DesignPluginPgkUtil
8
+ */
9
+ export declare class DesignPluginPgkUtil extends PluginPgkUtil {
10
+ /**
11
+ * 加载设计态插件包
12
+ *
13
+ * @static
14
+ * @param {App} app
15
+ * @param {Platform} platform
16
+ * @returns {*} {Promise<LoadPluginResult>}
17
+ */
18
+ static loadDesignPlugin(_app: App, platform: Platform, kit?: string[]): Promise<LoadPluginResult>;
19
+ /**
20
+ * 加载设计态中,已经被从配置中移除的插件
21
+ *
22
+ * @static
23
+ * @param {Platform} platform
24
+ * @param {IObject[]} configs
25
+ * @returns {*} {Promise<void>}
26
+ */
27
+ static loadDesignDeletedPlugins(platform: Platform, configs?: IObject[]): Promise<void>;
28
+ }
@@ -0,0 +1,85 @@
1
+ import { Platform, PluginModeEnum, PluginPgkUtil } from "@gct-paas/core";
2
+ //#region src/utils/design-plugin-pkg-util/design-plugin-pkg-util.ts
3
+ /**
4
+ * 插件包处理工具类
5
+ *
6
+ * @export
7
+ * @class DesignPluginPgkUtil
8
+ */
9
+ var DesignPluginPgkUtil = class extends PluginPgkUtil {
10
+ /**
11
+ * 加载设计态插件包
12
+ *
13
+ * @static
14
+ * @param {App} app
15
+ * @param {Platform} platform
16
+ * @returns {*} {Promise<LoadPluginResult>}
17
+ */
18
+ static async loadDesignPlugin(_app, platform, kit = []) {
19
+ try {
20
+ const result = await this.loadPlugin(PluginModeEnum.DESIGN, platform, kit);
21
+ const [configs, moduleMap] = result;
22
+ configs.forEach((config) => {
23
+ config.plugins.forEach((plugin) => {
24
+ const module = moduleMap[plugin.key];
25
+ if (!module) {
26
+ console.error(`${plugin.key} 插件加载失败,请检查插件配置是否正确`);
27
+ return;
28
+ }
29
+ switch (platform) {
30
+ case Platform.MOBILE:
31
+ if (module.mobile) _gct.register.designer.mobile.register(plugin.key, () => new module.mobile());
32
+ break;
33
+ case Platform.PAD:
34
+ if (module.mobile) _gct.register.designer.pad.register(plugin.key, () => new module.mobile());
35
+ break;
36
+ case Platform.WEB:
37
+ if (module.web) _gct.register.designer.web.register(plugin.key, () => new module.web());
38
+ break;
39
+ default: console.warn(`未知平台 ${platform},无法注册插件 ${plugin.key}`);
40
+ }
41
+ });
42
+ });
43
+ return result;
44
+ } catch (error) {
45
+ console.error(error);
46
+ }
47
+ return [[], {}];
48
+ }
49
+ /**
50
+ * 加载设计态中,已经被从配置中移除的插件
51
+ *
52
+ * @static
53
+ * @param {Platform} platform
54
+ * @param {IObject[]} configs
55
+ * @returns {*} {Promise<void>}
56
+ */
57
+ static async loadDesignDeletedPlugins(platform, configs = []) {
58
+ try {
59
+ const moduleMap = await this.loadPlugins(PluginModeEnum.DESIGN, configs);
60
+ configs.forEach((plugin) => {
61
+ const module = moduleMap[plugin.key];
62
+ if (!module) {
63
+ console.error(`${plugin.key} 插件加载失败,请检查插件配置是否正确`);
64
+ return;
65
+ }
66
+ switch (platform) {
67
+ case Platform.MOBILE:
68
+ if (module.mobile) _gct.register.designer.mobile.register(plugin.key, () => new module.mobile());
69
+ break;
70
+ case Platform.PAD:
71
+ if (module.mobile) _gct.register.designer.pad.register(plugin.key, () => new module.mobile());
72
+ break;
73
+ case Platform.WEB:
74
+ if (module.web) _gct.register.designer.web.register(plugin.key, () => new module.web());
75
+ break;
76
+ default: console.warn(`未知平台 ${platform},无法注册插件 ${plugin.key}`);
77
+ }
78
+ });
79
+ } catch (error) {
80
+ console.error(error);
81
+ }
82
+ }
83
+ };
84
+ //#endregion
85
+ export { DesignPluginPgkUtil };
@@ -6,7 +6,7 @@ export { deptFilter, formulaFilter } from './field-filter';
6
6
  export { openFormulaEditorByDesign } from './formula-editor-design/formula-editor-design';
7
7
  export { findAllChildrenTypes } from './find-deep-types/find-deep-types';
8
8
  export { onWidgetInfoInit, createWidgetProvider, } from './init-widget-info/init-widget-info';
9
- export * from './plugin-pkg-util/plugin-pkg-util';
9
+ export * from './design-plugin-pkg-util/design-plugin-pkg-util';
10
10
  export { createWidgetByType } from './schema';
11
11
  export { buildRunJs, initMethodMap } from './transform-js';
12
12
  export { flatten } from './flatten';
@@ -7,7 +7,7 @@ import "./field-filter/index.mjs";
7
7
  import "./formula-editor-design/formula-editor-design.mjs";
8
8
  import "./find-deep-types/find-deep-types.mjs";
9
9
  import "./init-widget-info/init-widget-info.mjs";
10
- import "./plugin-pkg-util/plugin-pkg-util.mjs";
10
+ import "./design-plugin-pkg-util/design-plugin-pkg-util.mjs";
11
11
  import "./schema/index.mjs";
12
12
  import "./transform-js/transform-js.mjs";
13
13
  import "./flatten.mjs";
package/package.json CHANGED
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "name": "@gct-paas/design",
3
- "version": "0.1.4-dev.14",
3
+ "version": "0.1.4-dev.16",
4
4
  "type": "module",
5
5
  "description": "paas 平台设计界面底包",
6
- "main": "dist/index.min.cjs",
7
- "module": "es/index.mjs",
6
+ "loader": "dist/loader.esm.min.js",
8
7
  "types": "es/index.d.ts",
9
- "system": "dist/index.system.min.js",
10
8
  "exports": {
11
9
  ".": {
12
10
  "types": "./es/index.d.ts",
13
- "import": "./es/index.mjs",
14
- "require": "./dist/index.min.cjs"
11
+ "import": "./es/index.mjs"
15
12
  },
16
13
  "./types": {
17
14
  "types": "./es/types/index.d.ts"
@@ -47,11 +44,11 @@
47
44
  "dependencies": {
48
45
  "@ant-design/icons-vue": "^7.0.1",
49
46
  "@babel/core": "^7.29.0",
50
- "@gct-paas/api": "^0.1.1",
51
- "@gct-paas/core": "0.1.4-dev.14",
52
- "@gct-paas/core-web": "0.1.4-dev.14",
53
- "@gct-paas/schema": "0.1.4-dev.14",
54
- "@gct-paas/scss": "0.1.4-dev.14",
47
+ "@gct-paas/api": "^0.1.2-dev.1",
48
+ "@gct-paas/core": "0.1.4-dev.16",
49
+ "@gct-paas/core-web": "0.1.4-dev.16",
50
+ "@gct-paas/schema": "0.1.4-dev.16",
51
+ "@gct-paas/scss": "0.1.4-dev.16",
55
52
  "@jsplumb/browser-ui": "^6.2.10",
56
53
  "@vueuse/core": "^14.1.0",
57
54
  "ant-design-vue": "~3.2.20",
@@ -72,5 +69,13 @@
72
69
  "@types/babel__core": "^7.20.5",
73
70
  "@types/estraverse": "^5.1.7"
74
71
  },
75
- "gitHead": "d03e6d5c7bd1c3edf73777ce40e0c0ed4982622f"
72
+ "peerDependencies": {
73
+ "@gct-paas/api": "*",
74
+ "@gct-paas/core": "*",
75
+ "@gct-paas/core-web": "*",
76
+ "@gct-paas/schema": "*",
77
+ "@gct-paas/scss": "*",
78
+ "vue": ">=3"
79
+ },
80
+ "gitHead": "cee8da739039182f4df08a2c0126cdd578fbc33b"
76
81
  }
@@ -1,97 +0,0 @@
1
- import { App } from 'vue';
2
- import { Platform } from '@gct-paas/core';
3
- export type IModuleMap = Record<string, System.Module>;
4
- export type LoadPluginResult = [IObject, IModuleMap];
5
- /**
6
- * 插件包处理工具类
7
- *
8
- * @export
9
- * @class PluginPgkUtil
10
- */
11
- export declare class PluginPgkUtil {
12
- /**
13
- * 插件配置缓存
14
- *
15
- * @private
16
- * @type {Map<string, IObject[]>}
17
- */
18
- private static cache;
19
- /**
20
- * 模块缓存
21
- *
22
- * @private
23
- * @static
24
- */
25
- private static cacheModules;
26
- /**
27
- * 已经加载的插件与模块的映射
28
- *
29
- * @static
30
- */
31
- static readonly module: Map<string, System.Module>;
32
- private static joinPaths;
33
- /**
34
- * 加载插件包配置
35
- *
36
- * @static
37
- * @param {PluginModeEnum} mode 插件模式
38
- * @param {Platform} platform
39
- * @param {string[]} [kit]
40
- * @returns {*} {Promise<IStyleIMportMap[]>}
41
- */
42
- private static loadPluginConfig;
43
- /**
44
- * 批量加载平台界面 system js 插件包
45
- *
46
- * @static
47
- * @param {IStyleIMportMap[]} plugins
48
- * @returns {*} {Promise<System.Module[]>}
49
- */
50
- private static loadPlugins;
51
- /**
52
- * 加载插件包
53
- *
54
- * @private
55
- * @static
56
- * @param {PluginModeEnum} mode
57
- * @param {Platform} platform
58
- * @returns {*}
59
- */
60
- private static loadPlugin;
61
- /**
62
- * 加载设计态插件包
63
- *
64
- * @static
65
- * @param {App} app
66
- * @param {Platform} platform
67
- * @returns {*} {Promise<LoadPluginResult>}
68
- */
69
- static loadDesignPlugin(_app: App, platform: Platform, kit?: string[]): Promise<LoadPluginResult>;
70
- /**
71
- * 加载设计态中,已经被从配置中移除的插件
72
- *
73
- * @static
74
- * @param {Platform} platform
75
- * @param {IObject[]} configs
76
- * @returns {*} {Promise<void>}
77
- */
78
- static loadDesignDeletedPlugins(platform: Platform, configs?: IObject[]): Promise<void>;
79
- /**
80
- * 加载设计态移动端插件包
81
- *
82
- * @static
83
- * @param {App} app
84
- * @param {IObject[]} configs 界面用到的插件集合
85
- * @returns {*} {Promise<void>}
86
- */
87
- static loadMobilePlugin(configs?: IObject[]): Promise<void>;
88
- /**
89
- * 加载设计态网页端插件包
90
- *
91
- * @static
92
- * @param {App} app
93
- * @param {IObject[]} configs 界面用到的插件集合
94
- * @returns {*} {Promise<void>}
95
- */
96
- static loadWebPlugin(configs?: IObject[]): Promise<void>;
97
- }
@@ -1,228 +0,0 @@
1
- import { PLUGIN_BASE_URL, Platform, PluginModeEnum } from "@gct-paas/core";
2
- //#region src/utils/plugin-pkg-util/plugin-pkg-util.ts
3
- /**
4
- * 插件包处理工具类
5
- *
6
- * @export
7
- * @class PluginPgkUtil
8
- */
9
- var PluginPgkUtil = class {
10
- /**
11
- * 插件配置缓存
12
- *
13
- * @private
14
- * @type {Map<string, IObject[]>}
15
- */
16
- static cache = /* @__PURE__ */ new Map();
17
- /**
18
- * 模块缓存
19
- *
20
- * @private
21
- * @static
22
- */
23
- static cacheModules = /* @__PURE__ */ new Map();
24
- /**
25
- * 已经加载的插件与模块的映射
26
- *
27
- * @static
28
- */
29
- static module = /* @__PURE__ */ new Map();
30
- static joinPaths(...paths) {
31
- return paths.filter((p) => p && p.length > 0).map((p, index) => {
32
- let normalized = p;
33
- if (normalized.startsWith("./")) normalized = normalized.slice(2);
34
- if (normalized.endsWith("/") && index < paths.length - 1) normalized = normalized.slice(0, -1);
35
- return normalized;
36
- }).join("/");
37
- }
38
- /**
39
- * 加载插件包配置
40
- *
41
- * @static
42
- * @param {PluginModeEnum} mode 插件模式
43
- * @param {Platform} platform
44
- * @param {string[]} [kit]
45
- * @returns {*} {Promise<IStyleIMportMap[]>}
46
- */
47
- static async loadPluginConfig(mode, platform, kit = []) {
48
- const tag = `${mode}-${platform}-${kit.join("_")}`;
49
- if (this.cache.has(tag)) return this.cache.get(tag);
50
- const cfg = { client: platform === Platform.WEB ? "WEB" : "MOBILE" };
51
- if (kit.length > 0) cfg.tag = kit.join(",");
52
- const data = await _api.platform.plugin.postGetTenantCompList(cfg);
53
- if (data.length > 0) this.cache.set(tag, data);
54
- return data;
55
- }
56
- /**
57
- * 批量加载平台界面 system js 插件包
58
- *
59
- * @static
60
- * @param {IStyleIMportMap[]} plugins
61
- * @returns {*} {Promise<System.Module[]>}
62
- */
63
- static async loadPlugins(mode, configs = []) {
64
- const moduleMap = {};
65
- if (configs.length > 0) {
66
- const plugins = configs.map((plugin) => {
67
- const baseUrl = this.joinPaths(PLUGIN_BASE_URL, plugin.url, "dist");
68
- return {
69
- imports: { [plugin.key]: `${baseUrl}/${mode}.system.min.js?version=${plugin.version}` },
70
- styles: { [plugin.key]: `${baseUrl}/${mode}.min.css?version=${plugin.version}` }
71
- };
72
- });
73
- const all = [];
74
- plugins.forEach((plugin) => {
75
- System.addImportMap(plugin);
76
- if (plugin.imports) Object.keys(plugin.imports).forEach((key) => {
77
- const load = async () => {
78
- try {
79
- const module = await System.import(key);
80
- moduleMap[key] = module;
81
- this.module.set(key, module);
82
- } catch (error) {
83
- console.error(error);
84
- }
85
- };
86
- all.push(load());
87
- });
88
- });
89
- await Promise.all(all);
90
- }
91
- return moduleMap;
92
- }
93
- /**
94
- * 加载插件包
95
- *
96
- * @private
97
- * @static
98
- * @param {PluginModeEnum} mode
99
- * @param {Platform} platform
100
- * @returns {*}
101
- */
102
- static async loadPlugin(mode, platform, kit) {
103
- kit = ["common", ...kit];
104
- const tag = `${mode}-${platform}-${kit.join("_")}`;
105
- try {
106
- const configs = await this.loadPluginConfig(mode, platform, kit);
107
- if (!this.cacheModules.has(tag)) {
108
- const plugins = [];
109
- configs.forEach((cfg) => {
110
- if (cfg.plugins) plugins.push(...cfg.plugins);
111
- });
112
- const moduleMap = await this.loadPlugins(mode, plugins);
113
- this.cacheModules.set(tag, moduleMap);
114
- }
115
- return [configs, this.cacheModules.get(tag)];
116
- } catch (error) {
117
- console.error(error);
118
- }
119
- return [[], {}];
120
- }
121
- /**
122
- * 加载设计态插件包
123
- *
124
- * @static
125
- * @param {App} app
126
- * @param {Platform} platform
127
- * @returns {*} {Promise<LoadPluginResult>}
128
- */
129
- static async loadDesignPlugin(_app, platform, kit = []) {
130
- try {
131
- const result = await this.loadPlugin(PluginModeEnum.DESIGN, platform, kit);
132
- const [configs, moduleMap] = result;
133
- configs.forEach((config) => {
134
- config.plugins.forEach((plugin) => {
135
- const module = moduleMap[plugin.key];
136
- if (!module) {
137
- console.error(`${plugin.key} 插件加载失败,请检查插件配置是否正确`);
138
- return;
139
- }
140
- if (platform === Platform.WEB) {
141
- const cls = module.web ?? module.default;
142
- if (cls) _gct.register.designer.web.register(plugin.key, () => new cls());
143
- } else {
144
- const cls = module.mobile ?? module.default;
145
- if (cls) _gct.register.designer.mobile.register(plugin.key, () => new cls());
146
- }
147
- });
148
- });
149
- return result;
150
- } catch (error) {
151
- console.error(error);
152
- }
153
- return [[], {}];
154
- }
155
- /**
156
- * 加载设计态中,已经被从配置中移除的插件
157
- *
158
- * @static
159
- * @param {Platform} platform
160
- * @param {IObject[]} configs
161
- * @returns {*} {Promise<void>}
162
- */
163
- static async loadDesignDeletedPlugins(platform, configs = []) {
164
- try {
165
- const moduleMap = await this.loadPlugins(PluginModeEnum.DESIGN, configs);
166
- configs.forEach((plugin) => {
167
- const module = moduleMap[plugin.key];
168
- if (!module) {
169
- console.error(`${plugin.key} 插件加载失败,请检查插件配置是否正确`);
170
- return;
171
- }
172
- if (platform === Platform.WEB) {
173
- const cls = module.web ?? module.default;
174
- if (cls) _gct.register.designer.web.register(plugin.key, () => new cls());
175
- } else {
176
- const cls = module.mobile ?? module.default;
177
- if (cls) _gct.register.designer.mobile.register(plugin.key, () => new cls());
178
- }
179
- });
180
- } catch (error) {
181
- console.error(error);
182
- }
183
- }
184
- /**
185
- * 加载设计态移动端插件包
186
- *
187
- * @static
188
- * @param {App} app
189
- * @param {IObject[]} configs 界面用到的插件集合
190
- * @returns {*} {Promise<void>}
191
- */
192
- static async loadMobilePlugin(configs = []) {
193
- try {
194
- const moduleMap = await this.loadPlugins(PluginModeEnum.MOBILE, configs);
195
- configs.forEach((plugin) => {
196
- if (!moduleMap[plugin.key]) {
197
- console.error(`${plugin.key} 插件加载失败,请检查插件配置是否正确`);
198
- return;
199
- }
200
- });
201
- } catch (error) {
202
- console.error(error);
203
- }
204
- }
205
- /**
206
- * 加载设计态网页端插件包
207
- *
208
- * @static
209
- * @param {App} app
210
- * @param {IObject[]} configs 界面用到的插件集合
211
- * @returns {*} {Promise<void>}
212
- */
213
- static async loadWebPlugin(configs = []) {
214
- try {
215
- const moduleMap = await this.loadPlugins(PluginModeEnum.WEB, configs);
216
- configs.forEach((plugin) => {
217
- if (!moduleMap[plugin.key]) {
218
- console.error(`${plugin.key} 插件加载失败,请检查插件配置是否正确`);
219
- return;
220
- }
221
- });
222
- } catch (error) {
223
- console.error(error);
224
- }
225
- }
226
- };
227
- //#endregion
228
- export { PluginPgkUtil };