@gct-paas/core 0.1.6-dev.8 → 6.0.0-dev.1

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 (128) hide show
  1. package/README.md +322 -0
  2. package/dist/index.esm.min.js +2 -1
  3. package/dist/{redirect-index-Ck5Ddtcb.js → redirect-index-DZ5iDlhA.js} +1 -0
  4. package/es/_virtual/_rolldown/runtime.mjs +13 -0
  5. package/es/constants/expression-type/modeCfg.mjs +6 -0
  6. package/es/constants/index.d.ts +4 -0
  7. package/es/constants/index.mjs +5 -1
  8. package/es/enums/app-designer/index.d.ts +29 -3
  9. package/es/enums/app-designer/index.mjs +33 -4
  10. package/es/enums/appEnum.d.ts +5 -1
  11. package/es/enums/appEnum.mjs +6 -1
  12. package/es/enums/authActionEnum.d.ts +5 -1
  13. package/es/enums/authActionEnum.mjs +4 -0
  14. package/es/enums/developer-center/integration.d.ts +6 -0
  15. package/es/enums/developer-center/integration.mjs +8 -1
  16. package/es/enums/expressionEnum.d.ts +4 -2
  17. package/es/enums/expressionEnum.mjs +2 -0
  18. package/es/enums/globalEnum.d.ts +30 -0
  19. package/es/enums/globalEnum.mjs +40 -1
  20. package/es/enums/index.d.ts +11 -0
  21. package/es/enums/index.mjs +13 -1
  22. package/es/enums/page-designer/designer.d.ts +2 -0
  23. package/es/enums/page-designer/designer.mjs +2 -0
  24. package/es/enums/page-designer/panel.d.ts +9 -2
  25. package/es/enums/page-designer/panel.mjs +10 -2
  26. package/es/enums/pageEnum.d.ts +2 -1
  27. package/es/enums/pageEnum.mjs +1 -0
  28. package/es/enums/process.d.ts +5 -0
  29. package/es/enums/process.mjs +9 -0
  30. package/es/enums/sizeEnum.d.ts +4 -0
  31. package/es/enums/sizeEnum.mjs +6 -1
  32. package/es/global/gct/gct.d.ts +25 -19
  33. package/es/global/gct/gct.mjs +9 -5
  34. package/es/hooks/index.d.ts +1 -0
  35. package/es/hooks/index.mjs +1 -0
  36. package/es/hooks/useDebouncePromise.d.ts +14 -0
  37. package/es/hooks/useDebouncePromise.mjs +56 -0
  38. package/es/index.d.ts +2 -0
  39. package/es/index.mjs +52 -33
  40. package/es/interface/i-action-item/i-action-item.d.ts +65 -0
  41. package/es/interface/i-app-context/i-app-context.d.ts +25 -0
  42. package/es/interface/i-dictionary/i-dictionary-item.d.ts +80 -0
  43. package/es/interface/i-pinia-action/i-global-actions.d.ts +9 -0
  44. package/es/interface/i-pinia-getter/i-global-getters.d.ts +22 -1
  45. package/es/interface/i-pinia-state/i-global-state.d.ts +9 -2
  46. package/es/interface/index.d.ts +2 -1
  47. package/es/interface/open-util/i-confirm-util/i-confirm-util.d.ts +65 -0
  48. package/es/interface/open-util/i-drawer-options/i-drawer-options.d.ts +298 -0
  49. package/es/interface/open-util/i-modal/i-modal.d.ts +14 -1
  50. package/es/interface/open-util/i-modal-data/i-modal-data.d.ts +3 -3
  51. package/es/interface/open-util/i-modal-options/i-modal-options.d.ts +2 -1
  52. package/es/interface/open-util/i-overlay-controller/i-overlay-controller.d.ts +9 -0
  53. package/es/interface/open-util/index.d.ts +2 -0
  54. package/es/locale/auto-register.d.ts +2 -0
  55. package/es/locale/auto-register.mjs +13 -0
  56. package/es/locale/index.d.ts +25 -1
  57. package/es/locale/index.mjs +57 -3
  58. package/es/locale/sys/model.mjs +9 -0
  59. package/es/locale/sys.d.ts +17 -0
  60. package/es/locale/sys.mjs +26 -0
  61. package/es/modules/env-manager/env-manager.const.d.ts +2 -0
  62. package/es/modules/env-manager/env-manager.const.mjs +4 -2
  63. package/es/modules/env-manager/env-manager.d.ts +8 -13
  64. package/es/modules/env-manager/env-manager.interface.d.ts +5 -9
  65. package/es/modules/env-manager/env-manager.interface.mjs +2 -0
  66. package/es/modules/env-manager/env-manager.mjs +19 -27
  67. package/es/modules/env-manager/env-manager.util.d.ts +5 -0
  68. package/es/modules/env-manager/env-manager.util.mjs +11 -0
  69. package/es/modules/env-manager/index.d.ts +1 -0
  70. package/es/modules/env-manager/index.mjs +1 -0
  71. package/es/modules/mqtt/interfaces/i-mqtt.d.ts +6 -2
  72. package/es/modules/mqtt/mqtt-client.d.ts +8 -7
  73. package/es/modules/mqtt/mqtt-client.mjs +30 -19
  74. package/es/modules/platform-config/constants/theme.const.d.ts +9 -1
  75. package/es/modules/platform-config/constants/theme.const.mjs +13 -2
  76. package/es/modules/platform-config/enums/login.enum.d.ts +3 -1
  77. package/es/modules/platform-config/enums/login.enum.mjs +2 -0
  78. package/es/modules/platform-config/store.d.ts +18 -18
  79. package/es/modules/platform-config/useDeploySetting.d.ts +1 -2
  80. package/es/modules/platform-config/useDeploySetting.mjs +6 -3
  81. package/es/modules/platform-config/useLoginSetting.d.ts +2 -2
  82. package/es/modules/platform-config/useLoginSetting.mjs +29 -31
  83. package/es/modules/platform-config/useOrgSetting.d.ts +2 -2
  84. package/es/modules/platform-config/useOrgSetting.mjs +4 -6
  85. package/es/modules/platform-config/useSecuritySetting.d.ts +2 -2
  86. package/es/modules/platform-config/useSecuritySetting.mjs +2 -3
  87. package/es/modules/platform-config/useThemeSetting.d.ts +1 -1
  88. package/es/modules/platform-config/useThemeSetting.mjs +32 -4
  89. package/es/modules/platform-config/useWatermarkSetting.d.ts +5 -2
  90. package/es/modules/platform-config/useWatermarkSetting.mjs +2 -3
  91. package/es/modules/sign-log/index.d.ts +1 -0
  92. package/es/modules/sign-log/index.mjs +1 -0
  93. package/es/modules/sign-log/sign-log.d.ts +10 -0
  94. package/es/modules/sign-log/sign-log.mjs +109 -0
  95. package/es/modules/sign-log/sing-log.interface.d.ts +9 -0
  96. package/es/modules/system-mqtt/index.d.ts +2 -0
  97. package/es/modules/system-mqtt/index.mjs +1 -0
  98. package/es/modules/system-mqtt/system-mqtt.interface.d.ts +71 -0
  99. package/es/modules/system-mqtt/system-mqtt.service.d.ts +104 -0
  100. package/es/modules/system-mqtt/system-mqtt.service.mjs +199 -0
  101. package/es/modules/user-stores/store/permission.store.d.ts +1 -0
  102. package/es/modules/user-stores/store/permission.store.mjs +10 -0
  103. package/es/modules/user-stores/store/user.store.mjs +4 -2
  104. package/es/router/guard/index.d.ts +4 -0
  105. package/es/router/guard/index.mjs +41 -0
  106. package/es/router/index.mjs +2 -0
  107. package/es/setup-app.mjs +2 -9
  108. package/es/state/global-pinia-state/global-pinia-state.d.ts +6 -0
  109. package/es/state/global-pinia-state/global-pinia-state.mjs +6 -0
  110. package/es/store/global-store.mjs +15 -1
  111. package/es/types/index.d.ts +7 -0
  112. package/es/utils/auth-util/auth-util.d.ts +37 -0
  113. package/es/utils/auth-util/auth-util.mjs +79 -0
  114. package/es/utils/axios/check-status.d.ts +1 -0
  115. package/es/utils/axios/check-status.mjs +64 -0
  116. package/es/utils/axios/interceptors.mjs +30 -0
  117. package/es/utils/deviceFingerprint.mjs +5 -1
  118. package/es/utils/i18n/index.mjs +1 -0
  119. package/es/utils/index.d.ts +4 -2
  120. package/es/utils/index.mjs +3 -1
  121. package/es/utils/openUtil/modal/modal.d.ts +1 -1
  122. package/es/utils/openUtil/modal/modal.mjs +1 -1
  123. package/es/utils/openUtil/overlay-container/overlay-container.mjs +1 -1
  124. package/es/utils/select-user-utils.d.ts +50 -0
  125. package/es/utils/select-user-utils.mjs +129 -0
  126. package/es/utils/tools/tools.d.ts +6 -0
  127. package/es/utils/tools/tools.mjs +12 -3
  128. package/package.json +5 -3
@@ -0,0 +1,104 @@
1
+ import { MqttCancelSub, IMqttClient } from '../mqtt';
2
+ import { IInternalMessagePayload, IKickOutPayload, IToDoMessagePayload, MqttSubCallback } from './system-mqtt.interface';
3
+ /**
4
+ * 系统级 MQTT 业务
5
+ *
6
+ * @export
7
+ * @class SystemMqttService
8
+ */
9
+ export declare class SystemMqttService {
10
+ private static isInitialized;
11
+ protected static client: IMqttClient | undefined;
12
+ protected static fingerprint: string | undefined;
13
+ protected static readonly LOGOUT_CLIENT_TAG = "USER_LOGOUT";
14
+ /**
15
+ * 用户登出消息 topic
16
+ *
17
+ * @static
18
+ */
19
+ static readonly USER_LOGOUT_TOPIC = "users/logout/msg";
20
+ /**
21
+ * 踢出用户消息 topic
22
+ *
23
+ * @readonly
24
+ * @static
25
+ * @type {string}
26
+ */
27
+ static get KICK_OUT_TOPIC(): string;
28
+ /**
29
+ * 未读消息变化 topic
30
+ *
31
+ * @readonly
32
+ * @static
33
+ * @type {string}
34
+ */
35
+ static get INTERNAL_MESSAGE_TOPIC(): string;
36
+ /**
37
+ * 待办消息数量 topic
38
+ *
39
+ * @readonly
40
+ * @static
41
+ * @type {string}
42
+ */
43
+ static get TASK_TODO_COUNT_TOPIC(): string;
44
+ /**
45
+ * 强制刷新并清空缓存 topic
46
+ *
47
+ * @static
48
+ */
49
+ static readonly CLEAN_CACHE_TOPIC = "CLEAN_CACHE";
50
+ /**
51
+ * 初始化系统级 MQTT 客户端,需要在用户信息以及应用信息加载完成后调用
52
+ *
53
+ * @static
54
+ * @return {*} {Promise<void>}
55
+ */
56
+ static init(): Promise<void>;
57
+ protected static createMqtt(): Promise<void>;
58
+ protected static subs(): void;
59
+ /**
60
+ * 订阅系统级 MQTT 消息
61
+ *
62
+ * @static
63
+ * @param {string} topic
64
+ */
65
+ protected static subscribe<T = IObject>(topic: string, callback: MqttSubCallback<T>): MqttCancelSub;
66
+ /**
67
+ * 订阅用户被踢出消息
68
+ *
69
+ * @static
70
+ * @param {MqttSubCallback<IKickOutPayload>} callback
71
+ * @return {*} {MqttCancelSub}
72
+ */
73
+ protected static subKickOut(callback?: MqttSubCallback<IKickOutPayload>): MqttCancelSub;
74
+ /**
75
+ * 订阅未读消息变化
76
+ *
77
+ * @static
78
+ * @param {MqttSubCallback<IInternalMessagePayload>} callback
79
+ * @return {*} {MqttCancelSub}
80
+ */
81
+ static subInternalMessage(callback: MqttSubCallback<IInternalMessagePayload>): MqttCancelSub;
82
+ /**
83
+ * 订阅待办消息数量变化
84
+ *
85
+ * @static
86
+ * @param {MqttSubCallback<IToDoMessagePayload>} callback
87
+ * @return {*} {MqttCancelSub}
88
+ */
89
+ static subTaskTodoCount(callback: MqttSubCallback<IToDoMessagePayload>): MqttCancelSub;
90
+ /**
91
+ * 强制用户界面刷新
92
+ *
93
+ * @static
94
+ * @param {MqttSubCallback<void>} callback
95
+ * @return {*} {MqttCancelSub}
96
+ */
97
+ static subCleanCache(): MqttCancelSub;
98
+ /**
99
+ * 发送用户登出消息
100
+ *
101
+ * @static
102
+ */
103
+ static pubLogout(): void;
104
+ }
@@ -0,0 +1,199 @@
1
+ import { ProjectNameType } from "../../enums/globalEnum.mjs";
2
+ import "../../enums/index.mjs";
3
+ import { getTenant, getToken } from "../../utils/tools/tools.mjs";
4
+ import { AuthUtil } from "../../utils/auth-util/auth-util.mjs";
5
+ import { t } from "../../utils/i18n/index.mjs";
6
+ import { getBrowserFingerprint, getPageIdentification } from "../../utils/deviceFingerprint.mjs";
7
+ import "../../utils/index.mjs";
8
+ import "../mqtt/index.mjs";
9
+ //#region src/modules/system-mqtt/system-mqtt.service.ts
10
+ /**
11
+ * 系统级 MQTT 业务
12
+ *
13
+ * @export
14
+ * @class SystemMqttService
15
+ */
16
+ var SystemMqttService = class {
17
+ static isInitialized = false;
18
+ static client;
19
+ static fingerprint;
20
+ static LOGOUT_CLIENT_TAG = "USER_LOGOUT";
21
+ /**
22
+ * 用户登出消息 topic
23
+ *
24
+ * @static
25
+ */
26
+ static USER_LOGOUT_TOPIC = `users/logout/msg`;
27
+ /**
28
+ * 踢出用户消息 topic
29
+ *
30
+ * @readonly
31
+ * @static
32
+ * @type {string}
33
+ */
34
+ static get KICK_OUT_TOPIC() {
35
+ return `USER/${_gct.store.userInfo.userId}/KICK_OUT`;
36
+ }
37
+ /**
38
+ * 未读消息变化 topic
39
+ *
40
+ * @readonly
41
+ * @static
42
+ * @type {string}
43
+ */
44
+ static get INTERNAL_MESSAGE_TOPIC() {
45
+ return `${_gct.env.getEnv().toUpperCase()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/INTERNAL_MESSAGE`;
46
+ }
47
+ /**
48
+ * 待办消息数量 topic
49
+ *
50
+ * @readonly
51
+ * @static
52
+ * @type {string}
53
+ */
54
+ static get TASK_TODO_COUNT_TOPIC() {
55
+ return `${_gct.env.getEnv().toUpperCase()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/TASK_TODO_COUNT`;
56
+ }
57
+ /**
58
+ * 强制刷新并清空缓存 topic
59
+ *
60
+ * @static
61
+ */
62
+ static CLEAN_CACHE_TOPIC = "CLEAN_CACHE";
63
+ /**
64
+ * 初始化系统级 MQTT 客户端,需要在用户信息以及应用信息加载完成后调用
65
+ *
66
+ * @static
67
+ * @return {*} {Promise<void>}
68
+ */
69
+ static async init() {
70
+ if (this.isInitialized) {
71
+ console.warn("SystemMqttService 已经初始化,请勿重复调用 init 方法");
72
+ return;
73
+ }
74
+ this.isInitialized = true;
75
+ this.fingerprint = await getBrowserFingerprint();
76
+ await this.createMqtt();
77
+ this.subs();
78
+ }
79
+ static async createMqtt() {
80
+ const willDelayInterval = 20;
81
+ const userInfo = _gct.store.userInfo;
82
+ const mqttProperties = userInfo.mqttProperties || {};
83
+ this.client = _gct.mqtt.create(this.LOGOUT_CLIENT_TAG, {
84
+ ...mqttProperties,
85
+ clientId: "logout" + this.fingerprint + getPageIdentification(),
86
+ protocolVersion: 5,
87
+ clean: false,
88
+ will: {
89
+ topic: this.USER_LOGOUT_TOPIC,
90
+ payload: JSON.stringify({
91
+ appId: _gct.store.appInfo.id,
92
+ ipAddress: userInfo.ip,
93
+ signLog: `${userInfo.userId}.${_gct.env.getEnv()}.${this.fingerprint}.${ProjectNameType[_gct.store.projectName]}.web.${getPageIdentification()}`,
94
+ tenantId: getTenant()
95
+ }),
96
+ qos: 1,
97
+ retain: true,
98
+ properties: {
99
+ willDelayInterval,
100
+ messageExpiryInterval: willDelayInterval * 10
101
+ }
102
+ },
103
+ properties: { sessionExpiryInterval: willDelayInterval * 2 }
104
+ });
105
+ }
106
+ static subs() {
107
+ this.subCleanCache();
108
+ this.subKickOut();
109
+ }
110
+ /**
111
+ * 订阅系统级 MQTT 消息
112
+ *
113
+ * @static
114
+ * @param {string} topic
115
+ */
116
+ static subscribe(topic, callback) {
117
+ if (!this.client) throw new Error("MQTT client is not initialized");
118
+ return this.client.subscribe(topic, (_topic, payload) => {
119
+ try {
120
+ const payloadStr = payload.toString();
121
+ callback(JSON.parse(payloadStr));
122
+ } catch (error) {
123
+ console.error("解析 MQTT 消息 payload 失败:", error);
124
+ }
125
+ });
126
+ }
127
+ /**
128
+ * 订阅用户被踢出消息
129
+ *
130
+ * @static
131
+ * @param {MqttSubCallback<IKickOutPayload>} callback
132
+ * @return {*} {MqttCancelSub}
133
+ */
134
+ static subKickOut(callback) {
135
+ return this.subscribe(this.KICK_OUT_TOPIC, (data) => {
136
+ const token = getToken();
137
+ if (token && token === data?.token) {
138
+ _gct.confirm.warning({
139
+ title: t("sys.loginWarning"),
140
+ content: t("sys.loginWarningContent"),
141
+ okText: t("sys.understood")
142
+ }).then(() => {
143
+ AuthUtil.getInstance().clearAuthAndGoLogin();
144
+ });
145
+ callback?.(data);
146
+ }
147
+ });
148
+ }
149
+ /**
150
+ * 订阅未读消息变化
151
+ *
152
+ * @static
153
+ * @param {MqttSubCallback<IInternalMessagePayload>} callback
154
+ * @return {*} {MqttCancelSub}
155
+ */
156
+ static subInternalMessage(callback) {
157
+ return this.subscribe(this.INTERNAL_MESSAGE_TOPIC, callback);
158
+ }
159
+ /**
160
+ * 订阅待办消息数量变化
161
+ *
162
+ * @static
163
+ * @param {MqttSubCallback<IToDoMessagePayload>} callback
164
+ * @return {*} {MqttCancelSub}
165
+ */
166
+ static subTaskTodoCount(callback) {
167
+ return this.subscribe(this.TASK_TODO_COUNT_TOPIC, callback);
168
+ }
169
+ /**
170
+ * 强制用户界面刷新
171
+ *
172
+ * @static
173
+ * @param {MqttSubCallback<void>} callback
174
+ * @return {*} {MqttCancelSub}
175
+ */
176
+ static subCleanCache() {
177
+ return this.subscribe(this.CLEAN_CACHE_TOPIC, () => {
178
+ const url = new URL(window.location.href);
179
+ url.searchParams.set("reloadTime", Date.now().toString());
180
+ window.location.replace(url.toString());
181
+ location.reload();
182
+ });
183
+ }
184
+ /**
185
+ * 发送用户登出消息
186
+ *
187
+ * @static
188
+ */
189
+ static pubLogout() {
190
+ this.client?.publish(this.USER_LOGOUT_TOPIC, JSON.stringify({
191
+ appId: _gct.store.appInfo.id,
192
+ ipAddress: _gct.store.userInfo.ip,
193
+ signLog: `${_gct.store.userInfo.userId}.${_gct.env.getEnv()}.${this.fingerprint}.${ProjectNameType[_gct.store.projectName]}.web.${getPageIdentification()}`,
194
+ tenantId: getTenant()
195
+ }));
196
+ }
197
+ };
198
+ //#endregion
199
+ 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,4 +1,4 @@
1
- import { getToken, setToken, tenantRef } 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";
@@ -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();
@@ -47,6 +52,15 @@ var useGlobalStore = defineStore("global-store", {
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
  });
@@ -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
  *
@@ -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;