@gct-paas/core 0.1.6-dev.9 → 6.0.0-dev.2
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.
- package/README.md +322 -0
- package/dist/index.esm.min.js +2 -1
- package/dist/{redirect-index-Ck5Ddtcb.js → redirect-index-B9IS3qL6.js} +1 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/constants/expression-type/modeCfg.mjs +6 -0
- package/es/constants/index.d.ts +4 -0
- package/es/constants/index.mjs +5 -1
- package/es/enums/app-designer/index.d.ts +29 -3
- package/es/enums/app-designer/index.mjs +33 -4
- package/es/enums/appEnum.d.ts +5 -1
- package/es/enums/appEnum.mjs +6 -1
- package/es/enums/authActionEnum.d.ts +5 -1
- package/es/enums/authActionEnum.mjs +4 -0
- package/es/enums/developer-center/integration.d.ts +6 -0
- package/es/enums/developer-center/integration.mjs +8 -1
- package/es/enums/expressionEnum.d.ts +4 -2
- package/es/enums/expressionEnum.mjs +2 -0
- package/es/enums/globalEnum.d.ts +30 -0
- package/es/enums/globalEnum.mjs +40 -1
- package/es/enums/index.d.ts +11 -0
- package/es/enums/index.mjs +13 -1
- package/es/enums/page-designer/designer.d.ts +2 -0
- package/es/enums/page-designer/designer.mjs +2 -0
- package/es/enums/page-designer/layout.d.ts +6 -0
- package/es/enums/page-designer/layout.mjs +8 -1
- package/es/enums/page-designer/panel.d.ts +9 -2
- package/es/enums/page-designer/panel.mjs +10 -2
- package/es/enums/pageEnum.d.ts +2 -1
- package/es/enums/pageEnum.mjs +1 -0
- package/es/enums/process.d.ts +5 -0
- package/es/enums/process.mjs +9 -0
- package/es/enums/sizeEnum.d.ts +4 -0
- package/es/enums/sizeEnum.mjs +6 -1
- package/es/global/gct/gct.d.ts +25 -19
- package/es/global/gct/gct.mjs +9 -5
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.mjs +1 -0
- package/es/hooks/useDebouncePromise.d.ts +14 -0
- package/es/hooks/useDebouncePromise.mjs +56 -0
- package/es/index.d.ts +2 -0
- package/es/index.mjs +37 -28
- package/es/interface/i-action-item/i-action-item.d.ts +65 -0
- package/es/interface/i-app-context/i-app-context.d.ts +25 -1
- package/es/interface/i-dictionary/i-dictionary-item.d.ts +80 -0
- package/es/interface/i-pinia-action/i-global-actions.d.ts +9 -0
- package/es/interface/i-pinia-getter/i-global-getters.d.ts +22 -1
- package/es/interface/i-pinia-state/i-global-state.d.ts +9 -2
- package/es/interface/index.d.ts +2 -1
- package/es/interface/open-util/i-confirm-util/i-confirm-util.d.ts +65 -0
- package/es/interface/open-util/i-drawer-options/i-drawer-options.d.ts +298 -0
- package/es/interface/open-util/i-modal/i-modal.d.ts +14 -1
- package/es/interface/open-util/i-modal-data/i-modal-data.d.ts +3 -3
- package/es/interface/open-util/i-modal-options/i-modal-options.d.ts +2 -1
- package/es/interface/open-util/i-overlay-controller/i-overlay-controller.d.ts +9 -0
- package/es/interface/open-util/index.d.ts +2 -0
- package/es/locale/auto-register.d.ts +2 -0
- package/es/locale/auto-register.mjs +13 -0
- package/es/locale/index.d.ts +25 -1
- package/es/locale/index.mjs +57 -3
- package/es/locale/sys/model.mjs +9 -0
- package/es/locale/sys.d.ts +17 -0
- package/es/locale/sys.mjs +26 -0
- package/es/modules/env-manager/env-manager.const.d.ts +2 -0
- package/es/modules/env-manager/env-manager.const.mjs +4 -2
- package/es/modules/env-manager/env-manager.d.ts +8 -13
- package/es/modules/env-manager/env-manager.interface.d.ts +5 -9
- package/es/modules/env-manager/env-manager.interface.mjs +2 -0
- package/es/modules/env-manager/env-manager.mjs +19 -27
- package/es/modules/env-manager/env-manager.util.d.ts +5 -0
- package/es/modules/env-manager/env-manager.util.mjs +11 -0
- package/es/modules/env-manager/index.d.ts +1 -0
- package/es/modules/env-manager/index.mjs +1 -0
- package/es/modules/mqtt/interfaces/i-mqtt.d.ts +6 -2
- package/es/modules/mqtt/mqtt-client.d.ts +8 -7
- package/es/modules/mqtt/mqtt-client.mjs +30 -19
- package/es/modules/platform-config/constants/theme.const.d.ts +9 -1
- package/es/modules/platform-config/constants/theme.const.mjs +13 -2
- package/es/modules/platform-config/enums/login.enum.d.ts +3 -1
- package/es/modules/platform-config/enums/login.enum.mjs +2 -0
- package/es/modules/platform-config/store.d.ts +18 -18
- package/es/modules/platform-config/useDeploySetting.d.ts +1 -2
- package/es/modules/platform-config/useDeploySetting.mjs +6 -3
- package/es/modules/platform-config/useLoginSetting.d.ts +2 -2
- package/es/modules/platform-config/useLoginSetting.mjs +29 -31
- package/es/modules/platform-config/useOrgSetting.d.ts +2 -2
- package/es/modules/platform-config/useOrgSetting.mjs +4 -6
- package/es/modules/platform-config/useSecuritySetting.d.ts +2 -2
- package/es/modules/platform-config/useSecuritySetting.mjs +2 -3
- package/es/modules/platform-config/useThemeSetting.d.ts +1 -1
- package/es/modules/platform-config/useThemeSetting.mjs +32 -4
- package/es/modules/platform-config/useWatermarkSetting.d.ts +5 -2
- package/es/modules/platform-config/useWatermarkSetting.mjs +2 -3
- package/es/modules/sign-log/index.d.ts +1 -0
- package/es/modules/sign-log/index.mjs +1 -0
- package/es/modules/sign-log/sign-log.d.ts +10 -0
- package/es/modules/sign-log/sign-log.mjs +109 -0
- package/es/modules/sign-log/sing-log.interface.d.ts +9 -0
- package/es/modules/system-mqtt/index.d.ts +2 -0
- package/es/modules/system-mqtt/index.mjs +1 -0
- package/es/modules/system-mqtt/system-mqtt.interface.d.ts +71 -0
- package/es/modules/system-mqtt/system-mqtt.service.d.ts +104 -0
- package/es/modules/system-mqtt/system-mqtt.service.mjs +199 -0
- package/es/modules/user-stores/store/permission.store.d.ts +1 -0
- package/es/modules/user-stores/store/permission.store.mjs +10 -0
- package/es/modules/user-stores/store/user.store.mjs +4 -2
- package/es/router/guard/index.d.ts +4 -0
- package/es/router/guard/index.mjs +41 -0
- package/es/router/index.mjs +2 -0
- package/es/setup-app.mjs +2 -9
- package/es/state/global-pinia-state/global-pinia-state.d.ts +6 -0
- package/es/state/global-pinia-state/global-pinia-state.mjs +6 -0
- package/es/store/global-store.mjs +15 -1
- package/es/types/index.d.ts +7 -0
- package/es/utils/auth-util/auth-util.d.ts +37 -0
- package/es/utils/auth-util/auth-util.mjs +79 -0
- package/es/utils/axios/check-status.d.ts +1 -0
- package/es/utils/axios/check-status.mjs +64 -0
- package/es/utils/axios/interceptors.mjs +30 -0
- package/es/utils/deviceFingerprint.mjs +5 -1
- package/es/utils/i18n/index.mjs +1 -0
- package/es/utils/index.d.ts +4 -2
- package/es/utils/index.mjs +3 -1
- package/es/utils/openUtil/modal/modal.d.ts +1 -1
- package/es/utils/openUtil/modal/modal.mjs +1 -1
- package/es/utils/openUtil/overlay-container/overlay-container.mjs +1 -1
- package/es/utils/select-user-utils.d.ts +50 -0
- package/es/utils/select-user-utils.mjs +129 -0
- package/es/utils/tools/tools.d.ts +6 -0
- package/es/utils/tools/tools.mjs +12 -3
- 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 };
|
|
@@ -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
|
-
|
|
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,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 };
|
package/es/router/index.mjs
CHANGED
|
@@ -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 {
|
|
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 };
|
|
@@ -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
|
|
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
|
});
|
package/es/types/index.d.ts
CHANGED
|
@@ -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;
|