@gct-paas/core 0.1.6-dev.1 → 0.1.6-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 (44) hide show
  1. package/dist/index.esm.min.js +1 -1
  2. package/es/constants/core.d.ts +1 -0
  3. package/es/constants/core.mjs +27 -1
  4. package/es/constants/index.d.ts +1 -1
  5. package/es/create-app-vue.d.ts +1 -1
  6. package/es/create-app-vue.mjs +1 -1
  7. package/es/enums/appEnum.mjs +4 -0
  8. package/es/enums/globalEnum.d.ts +29 -0
  9. package/es/enums/globalEnum.mjs +33 -1
  10. package/es/global/gct/gct.mjs +1 -0
  11. package/es/hooks/index.d.ts +1 -0
  12. package/es/hooks/index.mjs +1 -0
  13. package/es/hooks/useObserver.d.ts +13 -0
  14. package/es/hooks/useObserver.mjs +46 -0
  15. package/es/index.mjs +24 -12
  16. package/es/interface/i-kit-plugin-module/i-kit-plugin-module.d.ts +2 -2
  17. package/es/interface/i-pinia-action/i-global-actions.d.ts +3 -1
  18. package/es/locale/index.mjs +7 -2
  19. package/es/modules/env-manager/env-manager.const.d.ts +2 -0
  20. package/es/modules/env-manager/env-manager.const.mjs +3 -1
  21. package/es/modules/env-manager/env-manager.d.ts +4 -0
  22. package/es/modules/env-manager/env-manager.interface.d.ts +2 -0
  23. package/es/modules/env-manager/env-manager.mjs +11 -3
  24. package/es/modules/env-manager/index.mjs +3 -0
  25. package/es/modules/error-handler/error-handler.const.mjs +7 -0
  26. package/es/modules/mqtt/constants/mqtt.const.mjs +12 -0
  27. package/es/modules/user-stores/store/tenant.store.d.ts +3 -5
  28. package/es/modules/user-stores/store/tenant.store.mjs +10 -12
  29. package/es/modules/user-stores/store/user.store.mjs +11 -4
  30. package/es/state/global-pinia-state/global-pinia-state.mjs +3 -1
  31. package/es/store/global-store.mjs +9 -4
  32. package/es/store/index.d.ts +1 -1
  33. package/es/store/session-store.d.ts +1 -0
  34. package/es/store/session-store.mjs +5 -2
  35. package/es/store/storage-store.mjs +3 -0
  36. package/es/types/index.d.ts +6 -0
  37. package/es/utils/data-prems/const.mjs +2 -0
  38. package/es/utils/index.d.ts +1 -1
  39. package/es/utils/namespace/namespace.mjs +1 -0
  40. package/es/utils/openUtil/overlay-container/overlay-container.d.ts +1 -1
  41. package/es/utils/openUtil/overlay-container/overlay-container.mjs +28 -23
  42. package/es/utils/tools/tools.d.ts +4 -2
  43. package/es/utils/tools/tools.mjs +20 -5
  44. package/package.json +3 -3
@@ -25,6 +25,9 @@ var useGlobalStore = defineStore("global-store", {
25
25
  async setContext(ctx = {}) {
26
26
  Object.assign(this.context, ctx);
27
27
  },
28
+ async setAid(aid) {
29
+ this.setContext({ aid });
30
+ },
28
31
  async init() {
29
32
  const paramStr = location.pathname.split("/")[2];
30
33
  if (paramStr) {
@@ -33,12 +36,14 @@ var useGlobalStore = defineStore("global-store", {
33
36
  }
34
37
  },
35
38
  async loadAppInfo() {
36
- this.appInfo = await _api.apaas.designerCommon.getGetApp();
39
+ const res = await _api.apaas.designerCommon.getGetApp();
40
+ this.appInfo = res;
37
41
  },
42
+ /**加載运行时全局常量显示 */
38
43
  async loadEmptySetting() {
39
- const { value } = await _gct.api.apaas.basicConfig.getDetail({ configEnum: PlatformSettingEnum.GLOBAL });
40
- if (!value) return;
41
- Object.assign(this.globalSetting, JSON.parse(value));
44
+ const res = await _gct.api.apaas.basicConfig.getDetail({ configEnum: PlatformSettingEnum.GLOBAL });
45
+ if (!res?.value) return;
46
+ Object.assign(this.globalSetting, JSON.parse(res.value));
42
47
  },
43
48
  setProjectName(name) {
44
49
  this.projectName = name;
@@ -1,7 +1,7 @@
1
1
  import { IGlobalStore } from './global-store';
2
2
  import { IPlatformConfigStore } from '../modules/platform-config';
3
3
  export { globalRefStorage } from './storage-store';
4
- export { globalRefSession } from './session-store';
4
+ export { globalRefSession, ENV } from './session-store';
5
5
  /**
6
6
  * 全局的状态管理工具类
7
7
  *
@@ -5,3 +5,4 @@ export declare const globalRefSession: import('@vueuse/core').RemovableRef<{
5
5
  /**登录登出标识 */
6
6
  currentPlatOrAppId: string;
7
7
  }>;
8
+ export declare const ENV: import('@vueuse/core').RemovableRef<string>;
@@ -2,6 +2,9 @@ import { useSessionStorage } from "@vueuse/core";
2
2
  /**
3
3
  * 全局双向绑定持续化缓存Map
4
4
  */
5
- var globalRefSession = useSessionStorage("GCT_GLOBAL_SESSION:PAAS", { currentPlatOrAppId: "" });
5
+ var globalRefSession = useSessionStorage("GCT_GLOBAL_SESSION:PAAS", {
6
+ /**登录登出标识 */
7
+ currentPlatOrAppId: "" });
8
+ var ENV = useSessionStorage("ENV", "");
6
9
  //#endregion
7
- export { globalRefSession };
10
+ export { ENV, globalRefSession };
@@ -3,8 +3,11 @@ import { useStorage } from "@vueuse/core";
3
3
  * 全局双向绑定持续化缓存Map
4
4
  */
5
5
  var globalRefStorage = useStorage("GCT_GLOBAL_STORAGE:PAAS", {
6
+ /**时区 */
6
7
  timezone: "UTC+08:00",
8
+ /**语言标识 */
7
9
  lang: "",
10
+ /**登录登出专用标识 */
8
11
  signWay: ""
9
12
  });
10
13
  //#endregion
@@ -61,6 +61,12 @@ declare global {
61
61
  * @type {ModuleFederation}
62
62
  */
63
63
  // _mf: ModuleFederation;
64
+ /**
65
+ * 安卓混合开发模式标识,由原生层注入,值为 true 时表示在安卓混合开发模式下运行
66
+ *
67
+ * @type {boolean}
68
+ */
69
+ __GCT_ANDROID__?: boolean;
64
70
  }
65
71
 
66
72
  interface ImportMetaEnv {
@@ -49,6 +49,7 @@ var moduleConfig = {
49
49
  }
50
50
  };
51
51
  var getInterfaceApi = {
52
+ /** 获取分类列表 */
52
53
  getCategoryList: ({ moduleType }) => {
53
54
  if (moduleType === CategoryModuleEnum.CHECK_LIST) return _api.apaas.formRelate.getCategory({ moduleType });
54
55
  const { modelKey, bsKeyList } = moduleConfig[moduleType] || {};
@@ -58,6 +59,7 @@ var getInterfaceApi = {
58
59
  bsKey: bsKeyList.list
59
60
  }, {}, {});
60
61
  },
62
+ /** 获取模板列表 */
61
63
  getTmplsList: (params, config) => {
62
64
  if (params.moduleType === CategoryModuleEnum.CHECK_LIST) throw new Error("该模块不支持模板列表接口");
63
65
  const { isQuery, ...otherParams } = params || {};
@@ -13,7 +13,7 @@ export * from './openUtil';
13
13
  export { KitPkgUtil } from './kit-pkg-util/kit-pkg-util';
14
14
  export { PluginPgkUtil, type IModuleMap, type LoadPluginResult, } from './plugin-pkg-util/plugin-pkg-util';
15
15
  export { PluginStaticResource } from './plugin-static-resource/plugin-static-resource';
16
- export { getToken, setToken, getTenant, isMobile, setTenant, deepMerge, stringifyMatrixParams, parseMatrixParams, createWhiteImageWithText, } from './tools/tools';
16
+ export { getToken, setToken, getTenant, tenantRef, isMobile, setTenant, deepMerge, stringifyMatrixParams, parseMatrixParams, createWhiteImageWithText, } from './tools/tools';
17
17
  export * from './uuid/uuid';
18
18
  export * from './value-helper/value-helper';
19
19
  export { interceptors } from './axios/interceptors';
@@ -30,6 +30,7 @@ function _bem(namespace, block, blockSuffix, element, modifier) {
30
30
  * @class Namespace
31
31
  */
32
32
  var Namespace = class {
33
+ block;
33
34
  /**
34
35
  * 命名空间
35
36
  *
@@ -61,7 +61,7 @@ export declare class OverlayContainer<O> implements IOverlayContainer {
61
61
  * @param {O} [opts]
62
62
  */
63
63
  constructor(component: unknown, render: (...args: any[]) => VNode, opts?: O | undefined);
64
- static createVueApp(rootComponent: Component, rootProps?: IData): Promise<App<Element>>;
64
+ static createVueApp(rootComponent: Component, rootProps?: IData): App<Element>;
65
65
  /**
66
66
  * 初始化飘窗
67
67
  *
@@ -1,4 +1,4 @@
1
- import { createApp, h, nextTick } from "vue";
1
+ import { createApp, h } from "vue";
2
2
  import { QXEvent } from "qx-util";
3
3
  //#region src/utils/openUtil/overlay-container/overlay-container.ts
4
4
  /**
@@ -12,6 +12,9 @@ import { QXEvent } from "qx-util";
12
12
  * @template O
13
13
  */
14
14
  var OverlayContainer = class OverlayContainer {
15
+ component;
16
+ render;
17
+ opts;
15
18
  vm;
16
19
  /**
17
20
  * 具体模态组件对象
@@ -61,7 +64,7 @@ var OverlayContainer = class OverlayContainer {
61
64
  this.opts = opts;
62
65
  this._initPromise = this.init();
63
66
  }
64
- static async createVueApp(rootComponent, rootProps) {
67
+ static createVueApp(rootComponent, rootProps) {
65
68
  console.error("没有注入createVueApp方法");
66
69
  return createApp(rootComponent, rootProps);
67
70
  }
@@ -78,27 +81,30 @@ var OverlayContainer = class OverlayContainer {
78
81
  const { render, opts } = this;
79
82
  const container = document.createElement("div");
80
83
  document.body.appendChild(container);
81
- const vm = await OverlayContainer.createVueApp({
82
- mounted() {
83
- self.modal = this.$refs.root;
84
- },
85
- unmounted() {
86
- document.body.removeChild(container);
87
- self.evt.emit("dismiss", self.result);
88
- },
89
- render() {
90
- return h(self.component, {
91
- ref: "root",
92
- opts,
93
- onDismiss(data) {
94
- self.result = data;
95
- vm.unmount();
96
- }
97
- }, { default: render });
98
- }
84
+ return new Promise((resolve) => {
85
+ const vm = OverlayContainer.createVueApp({
86
+ mounted() {
87
+ self.modal = this.$refs.root;
88
+ resolve();
89
+ },
90
+ unmounted() {
91
+ document.body.removeChild(container);
92
+ self.evt.emit("dismiss", self.result);
93
+ },
94
+ render() {
95
+ return h(self.component, {
96
+ ref: "root",
97
+ opts,
98
+ onDismiss(data) {
99
+ self.result = data;
100
+ vm.unmount();
101
+ }
102
+ }, { default: render });
103
+ }
104
+ });
105
+ vm.mount(container);
106
+ this.vm = vm;
99
107
  });
100
- vm.mount(container);
101
- this.vm = vm;
102
108
  }
103
109
  /**
104
110
  * 打开飘窗
@@ -109,7 +115,6 @@ var OverlayContainer = class OverlayContainer {
109
115
  */
110
116
  async present() {
111
117
  await this._initPromise;
112
- await nextTick();
113
118
  return this.modal.present();
114
119
  }
115
120
  /**
@@ -1,3 +1,5 @@
1
+ import { Ref } from 'vue';
2
+ export declare const tenantRef: Readonly<Ref<string>>;
1
3
  /**
2
4
  * 获取认证令牌
3
5
  *
@@ -23,9 +25,9 @@ export declare function getTenant(): string | null;
23
25
  * 设置租户标识至 cookie
24
26
  *
25
27
  * @export
26
- * @param {string} tenant
28
+ * @param {string} [tenant]
27
29
  */
28
- export declare function setTenant(tenant: string): void;
30
+ export declare function setTenant(tenant?: string): void;
29
31
  /**
30
32
  * 是否为移动端设备
31
33
  */
@@ -2,9 +2,25 @@ import { CoreConst } from "../../constants/core.mjs";
2
2
  import "../../constants/index.mjs";
3
3
  import qs from "qs";
4
4
  import { cloneDeep, isEqual, mergeWith, unionWith } from "lodash-es";
5
+ import { customRef, readonly } from "vue";
5
6
  import { clearCookie, getCookie, setCookie } from "qx-util";
6
7
  //#region src/utils/tools/tools.ts
7
8
  /**
9
+ * 租户 cookie 双向绑定响应式引用:get 直接读 cookie,set 直接写 cookie
10
+ */
11
+ var _tenantRef = customRef((track, trigger) => ({
12
+ get() {
13
+ track();
14
+ return getCookie(CoreConst.TENANT) || "";
15
+ },
16
+ set(value) {
17
+ if (value) setCookie(CoreConst.TENANT, value, 7, true);
18
+ else clearCookie(CoreConst.TENANT, true);
19
+ trigger();
20
+ }
21
+ }));
22
+ var tenantRef = readonly(_tenantRef);
23
+ /**
8
24
  * 获取认证令牌
9
25
  *
10
26
  * @export
@@ -30,17 +46,16 @@ function setToken(token) {
30
46
  * @returns {*} {(string | null)}
31
47
  */
32
48
  function getTenant() {
33
- return getCookie(CoreConst.TENANT);
49
+ return _tenantRef.value || null;
34
50
  }
35
51
  /**
36
52
  * 设置租户标识至 cookie
37
53
  *
38
54
  * @export
39
- * @param {string} tenant
55
+ * @param {string} [tenant]
40
56
  */
41
57
  function setTenant(tenant) {
42
- if (tenant) setCookie(CoreConst.TENANT, tenant, 7, true);
43
- else clearCookie(CoreConst.TENANT, true);
58
+ _tenantRef.value = tenant || "";
44
59
  }
45
60
  /**
46
61
  * 是否为移动端设备
@@ -140,4 +155,4 @@ function createWhiteImageWithText(name, width, height) {
140
155
  return canvas.toDataURL("image/png");
141
156
  }
142
157
  //#endregion
143
- export { createWhiteImageWithText, deepMerge, getTenant, getToken, isMobile, parseMatrixParams, setTenant, setToken, stringifyMatrixParams };
158
+ export { createWhiteImageWithText, deepMerge, getTenant, getToken, isMobile, parseMatrixParams, setTenant, setToken, stringifyMatrixParams, tenantRef };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.1.6-dev.1",
3
+ "version": "0.1.6-dev.10",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "loader": "dist/index.esm.min.js",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@fingerprintjs/fingerprintjs": "^5.1.0",
35
35
  "@floating-ui/dom": "^1.7.6",
36
- "@gct-paas/api": "^0.1.4-dev.4",
36
+ "@gct-paas/api": "^0.1.6-dev.5",
37
37
  "@module-federation/runtime": "^2.2.3",
38
38
  "@vueuse/core": "^14.1.0",
39
39
  "async-validator": "^4.2.5",
@@ -58,7 +58,7 @@
58
58
  "playwright": "^1.58.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@gct-paas/api": "^0.1.4-dev.4",
61
+ "@gct-paas/api": "^0.1.6-dev.5",
62
62
  "vue": ">=3",
63
63
  "vue-i18n": ">=11",
64
64
  "vue-router": ">=4"