@gct-paas/core 0.1.6-dev.3 → 0.1.6-dev.30

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 (138) hide show
  1. package/dist/index.esm.min.js +2 -1
  2. package/dist/{redirect-index-Ck5Ddtcb.js → redirect-index-DpUqbadn.js} +1 -0
  3. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  4. package/es/constants/core.d.ts +1 -0
  5. package/es/constants/core.mjs +27 -1
  6. package/es/constants/expression-type/modeCfg.mjs +6 -0
  7. package/es/constants/index.d.ts +5 -1
  8. package/es/constants/index.mjs +5 -1
  9. package/es/create-app-vue.d.ts +1 -1
  10. package/es/create-app-vue.mjs +1 -1
  11. package/es/enums/app-designer/index.d.ts +29 -3
  12. package/es/enums/app-designer/index.mjs +33 -4
  13. package/es/enums/appEnum.d.ts +5 -1
  14. package/es/enums/appEnum.mjs +6 -1
  15. package/es/enums/authActionEnum.d.ts +5 -1
  16. package/es/enums/authActionEnum.mjs +4 -0
  17. package/es/enums/developer-center/integration.d.ts +6 -0
  18. package/es/enums/developer-center/integration.mjs +8 -1
  19. package/es/enums/expressionEnum.d.ts +4 -2
  20. package/es/enums/expressionEnum.mjs +2 -0
  21. package/es/enums/globalEnum.d.ts +29 -0
  22. package/es/enums/globalEnum.mjs +31 -1
  23. package/es/enums/index.d.ts +11 -0
  24. package/es/enums/index.mjs +13 -1
  25. package/es/enums/page-designer/designer.d.ts +2 -0
  26. package/es/enums/page-designer/designer.mjs +2 -0
  27. package/es/enums/page-designer/panel.d.ts +1 -2
  28. package/es/enums/page-designer/panel.mjs +0 -1
  29. package/es/enums/pageEnum.d.ts +2 -1
  30. package/es/enums/pageEnum.mjs +1 -0
  31. package/es/enums/process.d.ts +5 -0
  32. package/es/enums/process.mjs +9 -0
  33. package/es/enums/sizeEnum.d.ts +4 -0
  34. package/es/enums/sizeEnum.mjs +6 -1
  35. package/es/global/gct/gct.d.ts +25 -19
  36. package/es/global/gct/gct.mjs +10 -5
  37. package/es/hooks/index.d.ts +2 -0
  38. package/es/hooks/index.mjs +2 -0
  39. package/es/hooks/useDebouncePromise.d.ts +14 -0
  40. package/es/hooks/useDebouncePromise.mjs +56 -0
  41. package/es/hooks/useObserver.d.ts +13 -0
  42. package/es/hooks/useObserver.mjs +46 -0
  43. package/es/index.d.ts +1 -0
  44. package/es/index.mjs +54 -34
  45. package/es/interface/i-action-item/i-action-item.d.ts +65 -0
  46. package/es/interface/i-app-context/i-app-context.d.ts +25 -0
  47. package/es/interface/i-dictionary/i-dictionary-item.d.ts +80 -0
  48. package/es/interface/i-kit-plugin-module/i-kit-plugin-module.d.ts +2 -2
  49. package/es/interface/i-pinia-action/i-global-actions.d.ts +9 -0
  50. package/es/interface/i-pinia-getter/i-global-getters.d.ts +22 -1
  51. package/es/interface/i-pinia-state/i-global-state.d.ts +9 -2
  52. package/es/interface/index.d.ts +2 -1
  53. package/es/interface/open-util/i-confirm-util/i-confirm-util.d.ts +65 -0
  54. package/es/interface/open-util/i-drawer-options/i-drawer-options.d.ts +298 -0
  55. package/es/interface/open-util/i-modal/i-modal.d.ts +14 -1
  56. package/es/interface/open-util/i-modal-data/i-modal-data.d.ts +3 -3
  57. package/es/interface/open-util/i-modal-options/i-modal-options.d.ts +2 -1
  58. package/es/interface/open-util/i-overlay-controller/i-overlay-controller.d.ts +9 -0
  59. package/es/interface/open-util/index.d.ts +2 -0
  60. package/es/locale/auto-register.d.ts +2 -0
  61. package/es/locale/auto-register.mjs +13 -0
  62. package/es/locale/index.d.ts +17 -1
  63. package/es/locale/index.mjs +34 -0
  64. package/es/locale/sys/model.mjs +9 -0
  65. package/es/locale/sys.d.ts +17 -0
  66. package/es/locale/sys.mjs +26 -0
  67. package/es/modules/env-manager/env-manager.const.d.ts +2 -0
  68. package/es/modules/env-manager/env-manager.const.mjs +4 -2
  69. package/es/modules/env-manager/env-manager.d.ts +8 -13
  70. package/es/modules/env-manager/env-manager.interface.d.ts +6 -8
  71. package/es/modules/env-manager/env-manager.interface.mjs +2 -0
  72. package/es/modules/env-manager/env-manager.mjs +20 -26
  73. package/es/modules/env-manager/env-manager.util.d.ts +5 -0
  74. package/es/modules/env-manager/env-manager.util.mjs +11 -0
  75. package/es/modules/env-manager/index.d.ts +1 -0
  76. package/es/modules/env-manager/index.mjs +4 -0
  77. package/es/modules/mqtt/interfaces/i-mqtt.d.ts +6 -2
  78. package/es/modules/mqtt/mqtt-client.d.ts +7 -7
  79. package/es/modules/mqtt/mqtt-client.mjs +20 -19
  80. package/es/modules/platform-config/constants/theme.const.d.ts +9 -1
  81. package/es/modules/platform-config/constants/theme.const.mjs +13 -2
  82. package/es/modules/platform-config/enums/login.enum.d.ts +3 -1
  83. package/es/modules/platform-config/enums/login.enum.mjs +2 -0
  84. package/es/modules/platform-config/store.d.ts +18 -18
  85. package/es/modules/platform-config/useDeploySetting.d.ts +1 -2
  86. package/es/modules/platform-config/useDeploySetting.mjs +6 -3
  87. package/es/modules/platform-config/useLoginSetting.d.ts +2 -2
  88. package/es/modules/platform-config/useLoginSetting.mjs +29 -31
  89. package/es/modules/platform-config/useOrgSetting.d.ts +2 -2
  90. package/es/modules/platform-config/useOrgSetting.mjs +4 -6
  91. package/es/modules/platform-config/useSecuritySetting.d.ts +2 -2
  92. package/es/modules/platform-config/useSecuritySetting.mjs +2 -3
  93. package/es/modules/platform-config/useThemeSetting.d.ts +1 -1
  94. package/es/modules/platform-config/useThemeSetting.mjs +32 -4
  95. package/es/modules/platform-config/useWatermarkSetting.d.ts +5 -2
  96. package/es/modules/platform-config/useWatermarkSetting.mjs +2 -3
  97. package/es/modules/system-mqtt/index.d.ts +3 -0
  98. package/es/modules/system-mqtt/index.mjs +2 -0
  99. package/es/modules/system-mqtt/system-mqtt.const.d.ts +1 -0
  100. package/es/modules/system-mqtt/system-mqtt.const.mjs +13 -0
  101. package/es/modules/system-mqtt/system-mqtt.interface.d.ts +71 -0
  102. package/es/modules/system-mqtt/system-mqtt.service.d.ts +104 -0
  103. package/es/modules/system-mqtt/system-mqtt.service.mjs +198 -0
  104. package/es/modules/user-stores/store/permission.store.d.ts +1 -0
  105. package/es/modules/user-stores/store/permission.store.mjs +10 -0
  106. package/es/modules/user-stores/store/tenant.store.d.ts +3 -5
  107. package/es/modules/user-stores/store/tenant.store.mjs +10 -12
  108. package/es/modules/user-stores/store/user.store.mjs +7 -5
  109. package/es/router/guard/index.d.ts +4 -0
  110. package/es/router/guard/index.mjs +41 -0
  111. package/es/router/index.mjs +2 -0
  112. package/es/setup-app.mjs +2 -9
  113. package/es/state/global-pinia-state/global-pinia-state.d.ts +6 -0
  114. package/es/state/global-pinia-state/global-pinia-state.mjs +6 -0
  115. package/es/store/global-store.mjs +18 -4
  116. package/es/store/index.d.ts +1 -1
  117. package/es/store/session-store.d.ts +1 -0
  118. package/es/store/session-store.mjs +2 -1
  119. package/es/types/index.d.ts +13 -0
  120. package/es/utils/auth-util/auth-util.d.ts +37 -0
  121. package/es/utils/auth-util/auth-util.mjs +79 -0
  122. package/es/utils/axios/check-status.d.ts +1 -0
  123. package/es/utils/axios/check-status.mjs +64 -0
  124. package/es/utils/axios/interceptors.mjs +30 -0
  125. package/es/utils/deviceFingerprint.mjs +5 -1
  126. package/es/utils/i18n/index.mjs +1 -0
  127. package/es/utils/index.d.ts +4 -2
  128. package/es/utils/index.mjs +3 -1
  129. package/es/utils/namespace/namespace.mjs +1 -0
  130. package/es/utils/openUtil/modal/modal.d.ts +1 -1
  131. package/es/utils/openUtil/modal/modal.mjs +1 -1
  132. package/es/utils/openUtil/overlay-container/overlay-container.d.ts +1 -1
  133. package/es/utils/openUtil/overlay-container/overlay-container.mjs +28 -23
  134. package/es/utils/select-user-utils.d.ts +50 -0
  135. package/es/utils/select-user-utils.mjs +129 -0
  136. package/es/utils/tools/tools.d.ts +10 -2
  137. package/es/utils/tools/tools.mjs +31 -7
  138. package/package.json +5 -3
@@ -0,0 +1,198 @@
1
+ import { getTenant, getToken } from "../../utils/tools/tools.mjs";
2
+ import { AuthUtil } from "../../utils/auth-util/auth-util.mjs";
3
+ import { t } from "../../utils/i18n/index.mjs";
4
+ import { getBrowserFingerprint, getPageIdentification } from "../../utils/deviceFingerprint.mjs";
5
+ import "../../utils/index.mjs";
6
+ import "../mqtt/index.mjs";
7
+ import { ProjectNameType } from "./system-mqtt.const.mjs";
8
+ //#region src/modules/system-mqtt/system-mqtt.service.ts
9
+ /**
10
+ * 系统级 MQTT 业务
11
+ *
12
+ * @export
13
+ * @class SystemMqttService
14
+ */
15
+ var SystemMqttService = class {
16
+ static isInitialized = false;
17
+ static client;
18
+ static fingerprint;
19
+ static LOGOUT_CLIENT_TAG = "USER_LOGOUT";
20
+ /**
21
+ * 用户登出消息 topic
22
+ *
23
+ * @static
24
+ */
25
+ static USER_LOGOUT_TOPIC = `users/logout/msg`;
26
+ /**
27
+ * 踢出用户消息 topic
28
+ *
29
+ * @readonly
30
+ * @static
31
+ * @type {string}
32
+ */
33
+ static get KICK_OUT_TOPIC() {
34
+ return `USER/${_gct.store.userInfo.userId}/KICK_OUT`;
35
+ }
36
+ /**
37
+ * 未读消息变化 topic
38
+ *
39
+ * @readonly
40
+ * @static
41
+ * @type {string}
42
+ */
43
+ static get INTERNAL_MESSAGE_TOPIC() {
44
+ return `${_gct.env.getEnv().toUpperCase()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/INTERNAL_MESSAGE`;
45
+ }
46
+ /**
47
+ * 待办消息数量 topic
48
+ *
49
+ * @readonly
50
+ * @static
51
+ * @type {string}
52
+ */
53
+ static get TASK_TODO_COUNT_TOPIC() {
54
+ return `${_gct.env.getEnv().toUpperCase()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/TASK_TODO_COUNT`;
55
+ }
56
+ /**
57
+ * 强制刷新并清空缓存 topic
58
+ *
59
+ * @static
60
+ */
61
+ static CLEAN_CACHE_TOPIC = "CLEAN_CACHE";
62
+ /**
63
+ * 初始化系统级 MQTT 客户端,需要在用户信息以及应用信息加载完成后调用
64
+ *
65
+ * @static
66
+ * @return {*} {Promise<void>}
67
+ */
68
+ static async init() {
69
+ if (this.isInitialized) {
70
+ console.warn("SystemMqttService 已经初始化,请勿重复调用 init 方法");
71
+ return;
72
+ }
73
+ this.isInitialized = true;
74
+ this.fingerprint = await getBrowserFingerprint();
75
+ await this.createMqtt();
76
+ this.subs();
77
+ }
78
+ static async createMqtt() {
79
+ const willDelayInterval = 20;
80
+ const userInfo = _gct.store.userInfo;
81
+ const mqttProperties = userInfo.mqttProperties || {};
82
+ this.client = _gct.mqtt.create(this.LOGOUT_CLIENT_TAG, {
83
+ ...mqttProperties,
84
+ clientId: "logout" + this.fingerprint + getPageIdentification(),
85
+ protocolVersion: 5,
86
+ clean: false,
87
+ will: {
88
+ topic: this.USER_LOGOUT_TOPIC,
89
+ payload: JSON.stringify({
90
+ appId: _gct.store.appInfo.id,
91
+ ipAddress: userInfo.ip,
92
+ signLog: `${userInfo.userId}.${_gct.env.getEnv()}.${this.fingerprint}.${ProjectNameType[_gct.store.projectName]}.web.${getPageIdentification()}`,
93
+ tenantId: getTenant()
94
+ }),
95
+ qos: 1,
96
+ retain: true,
97
+ properties: {
98
+ willDelayInterval,
99
+ messageExpiryInterval: willDelayInterval * 10
100
+ }
101
+ },
102
+ properties: { sessionExpiryInterval: willDelayInterval * 2 }
103
+ });
104
+ }
105
+ static subs() {
106
+ this.subCleanCache();
107
+ this.subKickOut();
108
+ }
109
+ /**
110
+ * 订阅系统级 MQTT 消息
111
+ *
112
+ * @static
113
+ * @param {string} topic
114
+ */
115
+ static subscribe(topic, callback) {
116
+ if (!this.client) throw new Error("MQTT client is not initialized");
117
+ return this.client.subscribe(topic, (_topic, payload) => {
118
+ try {
119
+ const payloadStr = payload.toString();
120
+ callback(JSON.parse(payloadStr));
121
+ } catch (error) {
122
+ console.error("解析 MQTT 消息 payload 失败:", error);
123
+ }
124
+ });
125
+ }
126
+ /**
127
+ * 订阅用户被踢出消息
128
+ *
129
+ * @static
130
+ * @param {MqttSubCallback<IKickOutPayload>} callback
131
+ * @return {*} {MqttCancelSub}
132
+ */
133
+ static subKickOut(callback) {
134
+ return this.subscribe(this.KICK_OUT_TOPIC, (data) => {
135
+ const token = getToken();
136
+ if (token && token === data?.token) {
137
+ _gct.confirm.warning({
138
+ title: t("sys.loginWarning"),
139
+ content: t("sys.loginWarningContent"),
140
+ okText: t("sys.understood")
141
+ }).then(() => {
142
+ AuthUtil.getInstance().clearAuthAndGoLogin();
143
+ });
144
+ callback?.(data);
145
+ }
146
+ });
147
+ }
148
+ /**
149
+ * 订阅未读消息变化
150
+ *
151
+ * @static
152
+ * @param {MqttSubCallback<IInternalMessagePayload>} callback
153
+ * @return {*} {MqttCancelSub}
154
+ */
155
+ static subInternalMessage(callback) {
156
+ return this.subscribe(this.INTERNAL_MESSAGE_TOPIC, callback);
157
+ }
158
+ /**
159
+ * 订阅待办消息数量变化
160
+ *
161
+ * @static
162
+ * @param {MqttSubCallback<IToDoMessagePayload>} callback
163
+ * @return {*} {MqttCancelSub}
164
+ */
165
+ static subTaskTodoCount(callback) {
166
+ return this.subscribe(this.TASK_TODO_COUNT_TOPIC, callback);
167
+ }
168
+ /**
169
+ * 强制用户界面刷新
170
+ *
171
+ * @static
172
+ * @param {MqttSubCallback<void>} callback
173
+ * @return {*} {MqttCancelSub}
174
+ */
175
+ static subCleanCache() {
176
+ return this.subscribe(this.CLEAN_CACHE_TOPIC, () => {
177
+ const url = new URL(window.location.href);
178
+ url.searchParams.set("reloadTime", Date.now().toString());
179
+ window.location.replace(url.toString());
180
+ location.reload();
181
+ });
182
+ }
183
+ /**
184
+ * 发送用户登出消息
185
+ *
186
+ * @static
187
+ */
188
+ static pubLogout() {
189
+ this.client?.publish(this.USER_LOGOUT_TOPIC, JSON.stringify({
190
+ appId: _gct.store.appInfo.id,
191
+ ipAddress: _gct.store.userInfo.ip,
192
+ signLog: `${_gct.store.userInfo.userId}.${_gct.env.getEnv()}.${this.fingerprint}.${ProjectNameType[_gct.store.projectName]}.web.${getPageIdentification()}`,
193
+ tenantId: getTenant()
194
+ }));
195
+ }
196
+ };
197
+ //#endregion
198
+ export { SystemMqttService };
@@ -16,6 +16,7 @@ export declare const usePermissionStore: import('pinia').StoreDefinition<"permis
16
16
  };
17
17
  }>): boolean;
18
18
  }, {
19
+ initPremission(): Promise<void>;
19
20
  getPermissionByKey(pageId: string, key?: string): boolean;
20
21
  initPermission(): Promise<void>;
21
22
  }>;
@@ -9,6 +9,16 @@ var usePermissionStore = defineStore("permission", {
9
9
  return !!state.userPermissions.appSuperAdmin || !!state.userPermissions.permissions["POINT.*"];
10
10
  } },
11
11
  actions: {
12
+ async initPremission() {
13
+ const res = await _api.apaas.designerCommon.getUserInfo();
14
+ Object.assign(this.userPermissions, {
15
+ ...res,
16
+ permissions: res?.permissions ? res?.permissions.reduce((map, item) => {
17
+ map[item] = true;
18
+ return map;
19
+ }, {}) : {}
20
+ });
21
+ },
12
22
  getPermissionByKey(pageId, key) {
13
23
  if (this.hasAllPermissions) return true;
14
24
  if (!key) return this.userPermissions.permissions[pageId];
@@ -1,7 +1,5 @@
1
1
  import { UserOfTenantDTO } from '@gct-paas/api/platform';
2
2
  import { tenantState } from '../types/tenant';
3
- export declare const useTenantStore: import('pinia').StoreDefinition<"tenant", tenantState, {
4
- getTenantUserInfoAction(state: {
5
- tenantUserInfo: Record<string, UserOfTenantDTO>;
6
- } & import('pinia').PiniaCustomStateProperties<tenantState>): () => Promise<UserOfTenantDTO>;
7
- }, {}>;
3
+ export declare const useTenantStore: import('pinia').StoreDefinition<"tenant", tenantState, {}, {
4
+ getTenantUserInfoAction(): Promise<UserOfTenantDTO>;
5
+ }>;
@@ -1,20 +1,18 @@
1
- import { getTenant } from "../../../utils/tools/tools.mjs";
1
+ import { tenantRef } from "../../../utils/tools/tools.mjs";
2
2
  import "../../../utils/index.mjs";
3
3
  import { defineStore } from "pinia";
4
4
  //#region src/modules/user-stores/store/tenant.store.ts
5
5
  var useTenantStore = defineStore("tenant", {
6
6
  state: () => ({ tenantUserInfo: {} }),
7
- getters: { getTenantUserInfoAction(state) {
8
- return async () => {
9
- const tenantId = getTenant();
10
- if (!tenantId) return Promise.reject(null);
11
- if (state.tenantUserInfo[tenantId]) return state.tenantUserInfo[tenantId];
12
- const info = await _api.platform.tenant.getUserInfo();
13
- state.tenantUserInfo[tenantId] = info;
14
- return info;
15
- };
16
- } },
17
- actions: {}
7
+ getters: {},
8
+ actions: { async getTenantUserInfoAction() {
9
+ const tenantId = tenantRef.value;
10
+ if (!tenantId) return Promise.reject(null);
11
+ if (this.tenantUserInfo[tenantId]) return this.tenantUserInfo[tenantId];
12
+ const info = await _api.platform.tenant.getUserInfo();
13
+ this.tenantUserInfo[tenantId] = info;
14
+ return info;
15
+ } }
18
16
  });
19
17
  //#endregion
20
18
  export { useTenantStore };
@@ -1,4 +1,4 @@
1
- import { getTenant, getToken, setToken } from "../../../utils/tools/tools.mjs";
1
+ import { getToken, setTenant, setToken, tenantRef } from "../../../utils/tools/tools.mjs";
2
2
  import { sha256 } from "../../../utils/uuid/uuid.mjs";
3
3
  import { getDeviceFingerprint, getPageIdentification } from "../../../utils/deviceFingerprint.mjs";
4
4
  import "../../../utils/index.mjs";
@@ -23,7 +23,7 @@ var useUserStore = defineStore("user", {
23
23
  },
24
24
  /**用户信息下的租户信息 */
25
25
  getTenantInfo(state) {
26
- return state.userInfo?.tenantList?.find((i) => i.id === getTenant());
26
+ return state.userInfo?.tenantList?.find((i) => i.id === tenantRef.value);
27
27
  }
28
28
  },
29
29
  actions: {
@@ -38,7 +38,7 @@ var useUserStore = defineStore("user", {
38
38
  }
39
39
  },
40
40
  async getUserInfoAction(Token) {
41
- if (!getToken && !Token) return null;
41
+ if (!getToken() && !Token) return null;
42
42
  const info = await _api.platform.user.getInfo({ headers: { Token } });
43
43
  this.setUserInfo(info);
44
44
  this.userPermissions = (info?.platformManagerPermissions ?? []).reduce((map, item) => {
@@ -51,7 +51,7 @@ var useUserStore = defineStore("user", {
51
51
  async afterLoginSingleApp() {},
52
52
  /**登录后逻辑 */
53
53
  async afterLoginAction() {
54
- if (!getToken) return null;
54
+ if (!getToken()) return null;
55
55
  },
56
56
  /**退出登录 接口*/
57
57
  async submitLoginOut() {
@@ -63,7 +63,8 @@ var useUserStore = defineStore("user", {
63
63
  */
64
64
  async appLoginOut() {
65
65
  setToken();
66
- this.setUserInfo({});
66
+ setTenant();
67
+ await this.setUserInfo({});
67
68
  },
68
69
  async setUserInfo(info) {
69
70
  this.userInfo = {
@@ -103,6 +104,7 @@ async function loginApi(params, { hasError = true } = {}) {
103
104
  * 登出
104
105
  */
105
106
  async function doLogout() {
107
+ if (!getToken()) return;
106
108
  const session = sessionStorage.getItem("currentPlatOrAppId");
107
109
  const env = _gct.env.getEnv();
108
110
  const fingerprint = await getDeviceFingerprint();
@@ -0,0 +1,4 @@
1
+ import { Router } from 'vue-router';
2
+ export declare function createPageLoadingGuard(router: Router): void;
3
+ export declare function createProgressGuard(router: Router): void;
4
+ export declare function createGuard(router: Router): void;
@@ -0,0 +1,41 @@
1
+ import { getToken } from "../../utils/tools/tools.mjs";
2
+ import "../../utils/index.mjs";
3
+ import { usePlatformConfigStore } from "../../modules/platform-config/store.mjs";
4
+ import "../../modules/platform-config/index.mjs";
5
+ import nProgress from "nprogress";
6
+ //#region src/router/guard/index.ts
7
+ function createPageLoadingGuard(router) {
8
+ const platformStore = usePlatformConfigStore();
9
+ router.beforeEach(async (to) => {
10
+ if (!getToken() || to.meta.loaded) return true;
11
+ if (platformStore.themeSetting.pageLoading == true) {
12
+ _gct.store.setPageLoading(true);
13
+ return true;
14
+ }
15
+ return true;
16
+ });
17
+ router.afterEach(async () => {
18
+ setTimeout(() => {
19
+ _gct.store.setPageLoading(false);
20
+ }, 220);
21
+ return true;
22
+ });
23
+ }
24
+ function createProgressGuard(router) {
25
+ const platformStore = usePlatformConfigStore();
26
+ router.beforeEach(async (to) => {
27
+ if (to.meta.loaded) return true;
28
+ if (platformStore.themeSetting.pageProgress == true) nProgress.start();
29
+ return true;
30
+ });
31
+ router.afterEach(async () => {
32
+ nProgress.done();
33
+ return true;
34
+ });
35
+ }
36
+ function createGuard(router) {
37
+ createPageLoadingGuard(router);
38
+ createProgressGuard(router);
39
+ }
40
+ //#endregion
41
+ export { createGuard };
@@ -1,3 +1,4 @@
1
+ import { createGuard } from "./guard/index.mjs";
1
2
  import "vue";
2
3
  import { createRouter, createWebHashHistory } from "vue-router";
3
4
  //#region src/router/index.ts
@@ -9,6 +10,7 @@ var RouterUtil = class {
9
10
  history: createWebHashHistory(),
10
11
  routes
11
12
  });
13
+ createGuard(this.router);
12
14
  }
13
15
  /**
14
16
  * 添加路由
package/es/setup-app.mjs CHANGED
@@ -1,10 +1,8 @@
1
- import { getToken } from "./utils/tools/tools.mjs";
2
1
  import { interceptors } from "./utils/axios/interceptors.mjs";
3
2
  import "./utils/index.mjs";
4
3
  import { usePlatformConfigStore } from "./modules/platform-config/store.mjs";
5
4
  import "./modules/platform-config/index.mjs";
6
- import { useUserStore } from "./modules/user-stores/store/user.store.mjs";
7
- import "./modules/user-stores/index.mjs";
5
+ import { registerCoreLocale } from "./locale/auto-register.mjs";
8
6
  import { HttpUtil } from "@gct-paas/api";
9
7
  //#region src/setup-app.ts
10
8
  /**
@@ -16,13 +14,8 @@ import { HttpUtil } from "@gct-paas/api";
16
14
  async function setupApp(_app) {
17
15
  HttpUtil.use(interceptors);
18
16
  await _gct.init();
17
+ registerCoreLocale();
19
18
  await usePlatformConfigStore().init();
20
- const token = getToken();
21
- if (token) try {
22
- await useUserStore().getUserInfoAction(token);
23
- } catch (error) {
24
- console.error("获取用户信息失败", error);
25
- }
26
19
  }
27
20
  //#endregion
28
21
  export { setupApp };
@@ -17,6 +17,12 @@ export declare class GlobalPiniaState implements IGlobalState {
17
17
  /**运行时空值显示 */
18
18
  emptyDisplay: emptyDisplayType;
19
19
  };
20
+ /**
21
+ * 是否出发路由全局设置中开启的 loading
22
+ *
23
+ * @type {boolean}
24
+ */
25
+ pageLoading: boolean;
20
26
  /**
21
27
  * 应用信息
22
28
  *
@@ -23,6 +23,12 @@ var GlobalPiniaState = class {
23
23
  globalSetting = {
24
24
  /**运行时空值显示 */
25
25
  emptyDisplay: "--" };
26
+ /**
27
+ * 是否出发路由全局设置中开启的 loading
28
+ *
29
+ * @type {boolean}
30
+ */
31
+ pageLoading = false;
26
32
  /**
27
33
  * 应用信息
28
34
  *
@@ -4,6 +4,7 @@ import { GlobalPiniaState } from "../state/global-pinia-state/global-pinia-state
4
4
  import "../state/index.mjs";
5
5
  import { parseMatrixParams } from "../utils/tools/tools.mjs";
6
6
  import "../utils/index.mjs";
7
+ import { normalizeEnv } from "../modules/env-manager/env-manager.util.mjs";
7
8
  import { defineStore } from "pinia";
8
9
  //#region src/store/global-store.ts
9
10
  var useGlobalStore = defineStore("global-store", {
@@ -19,6 +20,9 @@ var useGlobalStore = defineStore("global-store", {
19
20
  },
20
21
  getEmptyDisplay() {
21
22
  return nullDisplayEnum[this.globalSetting.emptyDisplay];
23
+ },
24
+ getPageLoading() {
25
+ return this.pageLoading;
22
26
  }
23
27
  },
24
28
  actions: {
@@ -32,8 +36,9 @@ var useGlobalStore = defineStore("global-store", {
32
36
  const paramStr = location.pathname.split("/")[2];
33
37
  if (paramStr) {
34
38
  const params = parseMatrixParams(paramStr);
35
- if (params) this.context = params;
39
+ if (params && Object.keys(params).length) Object.assign(this.context, params);
36
40
  }
41
+ this.context.env = normalizeEnv(this.context.env);
37
42
  },
38
43
  async loadAppInfo() {
39
44
  const res = await _api.apaas.designerCommon.getGetApp();
@@ -41,12 +46,21 @@ var useGlobalStore = defineStore("global-store", {
41
46
  },
42
47
  /**加載运行时全局常量显示 */
43
48
  async loadEmptySetting() {
44
- const { value } = await _gct.api.apaas.basicConfig.getDetail({ configEnum: PlatformSettingEnum.GLOBAL });
45
- if (!value) return;
46
- Object.assign(this.globalSetting, JSON.parse(value));
49
+ const res = await _gct.api.apaas.basicConfig.getDetail({ configEnum: PlatformSettingEnum.GLOBAL });
50
+ if (!res?.value) return;
51
+ Object.assign(this.globalSetting, JSON.parse(res.value));
47
52
  },
48
53
  setProjectName(name) {
49
54
  this.projectName = name;
55
+ },
56
+ setPageLoading(loading) {
57
+ this.pageLoading = loading;
58
+ },
59
+ updateUserInfo(data) {
60
+ this.userInfo = {
61
+ ...this.userInfo,
62
+ ...data
63
+ };
50
64
  }
51
65
  }
52
66
  });
@@ -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>;
@@ -5,5 +5,6 @@ import { useSessionStorage } from "@vueuse/core";
5
5
  var globalRefSession = useSessionStorage("GCT_GLOBAL_SESSION:PAAS", {
6
6
  /**登录登出标识 */
7
7
  currentPlatOrAppId: "" });
8
+ var ENV = useSessionStorage("ENV", "");
8
9
  //#endregion
9
- export { globalRefSession };
10
+ export { ENV, globalRefSession };
@@ -2,6 +2,7 @@
2
2
  import '@gct-paas/api/global-type';
3
3
  import 'systemjs';
4
4
  import 'vite/types/importMeta.d.ts';
5
+ import type { Composer } from 'vue-i18n';
5
6
  import type { GctGlobal } from '../global';
6
7
  import type { ApiManage as APaasApiManage } from '@gct-paas/api/apaas';
7
8
  import type { ApiManage as PlatformApiManage } from '@gct-paas/api/platform';
@@ -49,6 +50,12 @@ declare global {
49
50
  * @type {GlobalApi}
50
51
  */
51
52
  _api: GlobalApi;
53
+ /**
54
+ * 多语言转换函数
55
+ *
56
+ * @type {Composer['t']}
57
+ */
58
+ $t: Composer['t'];
52
59
  /**
53
60
  * wujie 微前端对象,当作为微前端子应用运行时可用
54
61
  *
@@ -61,6 +68,12 @@ declare global {
61
68
  * @type {ModuleFederation}
62
69
  */
63
70
  // _mf: ModuleFederation;
71
+ /**
72
+ * 安卓混合开发模式标识,由原生层注入,值为 true 时表示在安卓混合开发模式下运行
73
+ *
74
+ * @type {boolean}
75
+ */
76
+ __GCT_ANDROID__?: boolean;
64
77
  }
65
78
 
66
79
  interface ImportMetaEnv {
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 认证工具类
3
+ *
4
+ * @export
5
+ * @class AuthUtil
6
+ */
7
+ export declare class AuthUtil {
8
+ private static instance;
9
+ private constructor();
10
+ /**
11
+ * 加载用户信息
12
+ *
13
+ * @description 现阶段的认证在 paas-front 系统中登录,此处直接获取 token 并加载用户信息,无认证信息或者登录过期直接跳转到登录页
14
+ * @return {*} {Promise<void>}
15
+ */
16
+ loadUser(): Promise<void>;
17
+ logout(goLogin?: boolean): Promise<void>;
18
+ /**
19
+ * 清除认证信息并跳转到登录页
20
+ *
21
+ * @return {*} {Promise<void>}
22
+ */
23
+ clearAuthAndGoLogin(): Promise<void>;
24
+ /**
25
+ * 跳转到首页
26
+ *
27
+ * @return {*} {Promise<void>}
28
+ */
29
+ goHome(): Promise<void>;
30
+ /**
31
+ * 跳转到租户选择页
32
+ *
33
+ * @return {*} {Promise<void>}
34
+ */
35
+ goTenantSelect(): Promise<void>;
36
+ static getInstance(): AuthUtil;
37
+ }
@@ -0,0 +1,79 @@
1
+ import { useUserStore } from "../../modules/user-stores/store/user.store.mjs";
2
+ import "../../modules/user-stores/index.mjs";
3
+ import { getToken, setTenant, setToken } from "../tools/tools.mjs";
4
+ //#region src/utils/auth-util/auth-util.ts
5
+ /**
6
+ * 认证工具类
7
+ *
8
+ * @export
9
+ * @class AuthUtil
10
+ */
11
+ var AuthUtil = class AuthUtil {
12
+ static instance;
13
+ constructor() {}
14
+ /**
15
+ * 加载用户信息
16
+ *
17
+ * @description 现阶段的认证在 paas-front 系统中登录,此处直接获取 token 并加载用户信息,无认证信息或者登录过期直接跳转到登录页
18
+ * @return {*} {Promise<void>}
19
+ */
20
+ async loadUser() {
21
+ const token = getToken();
22
+ if (token) try {
23
+ await useUserStore().getUserInfoAction(token);
24
+ } catch (error) {
25
+ console.error("获取用户信息失败", error);
26
+ }
27
+ }
28
+ async logout(goLogin) {
29
+ await useUserStore().submitLoginOut();
30
+ if (goLogin) {
31
+ const url = new URL(`${location.origin}/paas-front/portal`);
32
+ if (_gct.env.isSandbox || _gct.env.isAppSingle) {
33
+ if (_gct.store.context.aid) url.searchParams.set("aid", _gct.store.context.aid);
34
+ url.searchParams.set("env", _gct.env.getEnv());
35
+ if (_gct.env.isAppSingle) url.searchParams.set("mode", "single");
36
+ }
37
+ url.hash = `/login`;
38
+ window.location.href = url.toString();
39
+ }
40
+ }
41
+ /**
42
+ * 清除认证信息并跳转到登录页
43
+ *
44
+ * @return {*} {Promise<void>}
45
+ */
46
+ async clearAuthAndGoLogin() {
47
+ setToken();
48
+ setTenant();
49
+ const url = new URL(`${location.origin}/paas-front/portal`);
50
+ url.hash = `/login`;
51
+ window.location.href = url.toString();
52
+ }
53
+ /**
54
+ * 跳转到首页
55
+ *
56
+ * @return {*} {Promise<void>}
57
+ */
58
+ async goHome() {
59
+ const url = new URL(`${location.origin}/paas-front/portal`);
60
+ url.hash = `/home`;
61
+ window.location.href = url.toString();
62
+ }
63
+ /**
64
+ * 跳转到租户选择页
65
+ *
66
+ * @return {*} {Promise<void>}
67
+ */
68
+ async goTenantSelect() {
69
+ const url = new URL(`${location.origin}/paas-front/portal`);
70
+ url.hash = `/tenant`;
71
+ window.location.href = url.toString();
72
+ }
73
+ static getInstance() {
74
+ if (!AuthUtil.instance) AuthUtil.instance = new AuthUtil();
75
+ return AuthUtil.instance;
76
+ }
77
+ };
78
+ //#endregion
79
+ export { AuthUtil };
@@ -0,0 +1 @@
1
+ export declare function checkStatus(status: number, msg: string, errorMessageMode?: string): void;