@gct-paas/core 0.1.6-dev.28 → 0.1.6-dev.29

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.
@@ -1,2 +1,2 @@
1
- /*! @gct-paas/core v0.1.6-dev.28 */
1
+ /*! @gct-paas/core v0.1.6-dev.29 */
2
2
  import{createElementBlock as e,defineComponent as r,openBlock as t,unref as a}from"vue";import{useRouter as p}from"vue-router";var o=/* @__PURE__ */r({__name:"redirect-index",setup(r){const{currentRoute:o,replace:i}=p(),{params:s,query:u}=a(o),{path:m,_redirect_type:n="path"}=s;Reflect.deleteProperty(s,"_redirect_type"),Reflect.deleteProperty(s,"path");const c=Array.isArray(m)?m.join("/"):m;return i("name"===n?{name:c,query:u,params:JSON.parse(s._origin_params??"{}")}:{path:c.startsWith("/")?c:"/"+c,query:u}),(r,a)=>(t(),e("div"))}});export{o as default};
@@ -1,7 +1,7 @@
1
1
  import { I18n } from 'vue-i18n';
2
2
  import { ApiMap } from '@gct-paas/api';
3
3
  import { GlobalStoreUtil } from '../../store';
4
- import { IGlobalRegister, IMessageUtil, IOverlayController } from '../../interface';
4
+ import { IConfirmUtil, IGlobalRegister, IMessageUtil, IOverlayController } from '../../interface';
5
5
  import { DictionaryUtil } from '../../utils';
6
6
  import { EnvironmentManager } from '../../modules/env-manager';
7
7
  import { MqttManager } from '../../modules/mqtt';
@@ -273,6 +273,12 @@ export declare class GctGlobal {
273
273
  * @type {IMessageUtil}
274
274
  */
275
275
  message: IMessageUtil;
276
+ /**
277
+ * 确认工具类(预览、移动、网页,需要分别实现)
278
+ *
279
+ * @type {IConfirmUtil}
280
+ */
281
+ confirm: IConfirmUtil;
276
282
  /**
277
283
  * 全局数据字典工具类
278
284
  *
@@ -56,6 +56,12 @@ var GctGlobal = class {
56
56
  */
57
57
  message;
58
58
  /**
59
+ * 确认工具类(预览、移动、网页,需要分别实现)
60
+ *
61
+ * @type {IConfirmUtil}
62
+ */
63
+ confirm;
64
+ /**
59
65
  * 全局数据字典工具类
60
66
  *
61
67
  */
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 确认工具接口
3
+ *
4
+ * @export
5
+ * @interface IConfirmParams
6
+ */
7
+ export interface IConfirmParams {
8
+ /**
9
+ * 确认框标题
10
+ *
11
+ * @type {string}
12
+ */
13
+ title: string;
14
+ /**
15
+ * 确认框内容
16
+ *
17
+ * @type {string}
18
+ */
19
+ content: string;
20
+ /**
21
+ * 确认框确认按钮文本
22
+ *
23
+ * @type {string}
24
+ */
25
+ okText?: string;
26
+ /**
27
+ * 确认框取消按钮文本
28
+ *
29
+ * @type {string}
30
+ */
31
+ cancelText?: string;
32
+ }
33
+ /**
34
+ * 确认工具接口
35
+ *
36
+ * @export
37
+ * @interface IConfirmUtil
38
+ */
39
+ export interface IConfirmUtil {
40
+ /**
41
+ * 弹出确认框
42
+ *
43
+ */
44
+ confirm(options: IConfirmParams): Promise<boolean>;
45
+ /**
46
+ * 弹出信息提示框
47
+ *
48
+ */
49
+ info(options: IConfirmParams): Promise<void>;
50
+ /**
51
+ * 弹出成功提示框
52
+ *
53
+ */
54
+ success(options: IConfirmParams): Promise<void>;
55
+ /**
56
+ * 弹出警告提示框
57
+ *
58
+ */
59
+ warning(options: IConfirmParams): Promise<void>;
60
+ /**
61
+ * 弹出错误提示框
62
+ *
63
+ */
64
+ error(options: IConfirmParams): Promise<void>;
65
+ }
@@ -1,5 +1,6 @@
1
1
  export type { IDrawerOptions } from './i-drawer-options/i-drawer-options';
2
2
  export type { IAppFullScreenContainerOptions } from './i-app-full-screen-container-options/i-app-full-screen-container-options';
3
+ export type { IConfirmParams, IConfirmUtil, } from './i-confirm-util/i-confirm-util';
3
4
  export type { IMessageParams, IMessageUtil, } from './i-message-util/i-message-util';
4
5
  export type { IModal } from './i-modal/i-modal';
5
6
  export type { IModalData } from './i-modal-data/i-modal-data';
@@ -15,5 +15,8 @@ declare const _default: {
15
15
  networkExceptionMsg: string;
16
16
  notNull: string;
17
17
  regError: string;
18
+ loginWarning: string;
19
+ loginWarningContent: string;
20
+ understood: string;
18
21
  };
19
22
  export default _default;
package/es/locale/sys.mjs CHANGED
@@ -17,7 +17,10 @@ var sys_default = {
17
17
  apiTimeoutMessage: "接口请求超时,请刷新页面重试!",
18
18
  networkExceptionMsg: "网络异常,请检查您的网络连接是否正常!",
19
19
  notNull: "该值不能为空",
20
- regError: "校验格式不正确"
20
+ regError: "校验格式不正确",
21
+ loginWarning: "登录警告",
22
+ loginWarningContent: "当前账号已在其他设备登录",
23
+ understood: "知道了"
21
24
  };
22
25
  //#endregion
23
26
  export { sys_exports };
@@ -10,7 +10,7 @@ export declare class SystemMqttService {
10
10
  private static isInitialized;
11
11
  protected static client: IMqttClient | undefined;
12
12
  protected static fingerprint: string | undefined;
13
- protected static client_id: string;
13
+ protected static readonly LOGOUT_CLIENT_TAG = "USER_LOGOUT";
14
14
  /**
15
15
  * 用户登出消息 topic
16
16
  *
@@ -54,6 +54,8 @@ export declare class SystemMqttService {
54
54
  * @return {*} {Promise<void>}
55
55
  */
56
56
  static init(): Promise<void>;
57
+ protected static createMqtt(): Promise<void>;
58
+ protected static subs(): void;
57
59
  /**
58
60
  * 订阅系统级 MQTT 消息
59
61
  *
@@ -68,7 +70,7 @@ export declare class SystemMqttService {
68
70
  * @param {MqttSubCallback<IKickOutPayload>} callback
69
71
  * @return {*} {MqttCancelSub}
70
72
  */
71
- static subKickOut(callback: MqttSubCallback<IKickOutPayload>): MqttCancelSub;
73
+ protected static subKickOut(callback?: MqttSubCallback<IKickOutPayload>): MqttCancelSub;
72
74
  /**
73
75
  * 订阅未读消息变化
74
76
  *
@@ -1,5 +1,7 @@
1
- import { getTenant } from "../../utils/tools/tools.mjs";
2
- import { getPageIdentification } from "../../utils/deviceFingerprint.mjs";
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";
3
5
  import "../../utils/index.mjs";
4
6
  import "../mqtt/index.mjs";
5
7
  import { ProjectNameType } from "./system-mqtt.const.mjs";
@@ -14,7 +16,7 @@ var SystemMqttService = class {
14
16
  static isInitialized = false;
15
17
  static client;
16
18
  static fingerprint;
17
- static client_id = "";
19
+ static LOGOUT_CLIENT_TAG = "USER_LOGOUT";
18
20
  /**
19
21
  * 用户登出消息 topic
20
22
  *
@@ -39,7 +41,7 @@ var SystemMqttService = class {
39
41
  * @type {string}
40
42
  */
41
43
  static get INTERNAL_MESSAGE_TOPIC() {
42
- return `${_gct.env.getEnv()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/INTERNAL_MESSAGE`;
44
+ return `${_gct.env.getEnv().toUpperCase()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/INTERNAL_MESSAGE`;
43
45
  }
44
46
  /**
45
47
  * 待办消息数量 topic
@@ -49,7 +51,7 @@ var SystemMqttService = class {
49
51
  * @type {string}
50
52
  */
51
53
  static get TASK_TODO_COUNT_TOPIC() {
52
- return `${_gct.env.getEnv()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/TASK_TODO_COUNT`;
54
+ return `${_gct.env.getEnv().toUpperCase()}/USER/${getTenant()}/${_gct.store.userInfo.userId}/TASK_TODO_COUNT`;
53
55
  }
54
56
  /**
55
57
  * 强制刷新并清空缓存 topic
@@ -69,10 +71,15 @@ var SystemMqttService = class {
69
71
  return;
70
72
  }
71
73
  this.isInitialized = true;
74
+ this.fingerprint = await getBrowserFingerprint();
75
+ await this.createMqtt();
76
+ this.subs();
77
+ }
78
+ static async createMqtt() {
72
79
  const willDelayInterval = 20;
73
80
  const userInfo = _gct.store.userInfo;
74
81
  const mqttProperties = userInfo.mqttProperties || {};
75
- _gct.mqtt.create("USER_LOGOUT", {
82
+ this.client = _gct.mqtt.create(this.LOGOUT_CLIENT_TAG, {
76
83
  ...mqttProperties,
77
84
  clientId: "logout" + this.fingerprint + getPageIdentification(),
78
85
  protocolVersion: 5,
@@ -94,7 +101,10 @@ var SystemMqttService = class {
94
101
  },
95
102
  properties: { sessionExpiryInterval: willDelayInterval * 2 }
96
103
  });
104
+ }
105
+ static subs() {
97
106
  this.subCleanCache();
107
+ this.subKickOut();
98
108
  }
99
109
  /**
100
110
  * 订阅系统级 MQTT 消息
@@ -104,10 +114,10 @@ var SystemMqttService = class {
104
114
  */
105
115
  static subscribe(topic, callback) {
106
116
  if (!this.client) throw new Error("MQTT client is not initialized");
107
- return this.client.subscribe(topic, (topic, payload) => {
108
- console.debug(`收到系统级 MQTT 消息,topic: ${topic}, payload:`, payload);
117
+ return this.client.subscribe(topic, (_topic, payload) => {
109
118
  try {
110
- callback(JSON.parse(payload.toString()));
119
+ const payloadStr = payload.toString();
120
+ callback(JSON.parse(payloadStr));
111
121
  } catch (error) {
112
122
  console.error("解析 MQTT 消息 payload 失败:", error);
113
123
  }
@@ -121,7 +131,19 @@ var SystemMqttService = class {
121
131
  * @return {*} {MqttCancelSub}
122
132
  */
123
133
  static subKickOut(callback) {
124
- return this.subscribe(this.KICK_OUT_TOPIC, 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
+ });
125
147
  }
126
148
  /**
127
149
  * 订阅未读消息变化
@@ -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];
@@ -15,6 +15,12 @@ export declare class AuthUtil {
15
15
  */
16
16
  loadUser(): Promise<void>;
17
17
  logout(goLogin?: boolean): Promise<void>;
18
+ /**
19
+ * 清除认证信息并跳转到登录页
20
+ *
21
+ * @return {*} {Promise<void>}
22
+ */
23
+ clearAuthAndGoLogin(): Promise<void>;
18
24
  /**
19
25
  * 跳转到首页
20
26
  *
@@ -1,6 +1,6 @@
1
1
  import { useUserStore } from "../../modules/user-stores/store/user.store.mjs";
2
2
  import "../../modules/user-stores/index.mjs";
3
- import { getToken } from "../tools/tools.mjs";
3
+ import { getToken, setTenant, setToken } from "../tools/tools.mjs";
4
4
  //#region src/utils/auth-util/auth-util.ts
5
5
  /**
6
6
  * 认证工具类
@@ -39,6 +39,18 @@ var AuthUtil = class AuthUtil {
39
39
  }
40
40
  }
41
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
+ /**
42
54
  * 跳转到首页
43
55
  *
44
56
  * @return {*} {Promise<void>}
@@ -9,7 +9,7 @@ function checkStatus(status, msg, errorMessageMode = "message") {
9
9
  break;
10
10
  case 401:
11
11
  errMessage = msg || t("sys.errMsg401");
12
- AuthUtil.getInstance().logout(true);
12
+ AuthUtil.getInstance().clearAuthAndGoLogin();
13
13
  break;
14
14
  case 402:
15
15
  setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.1.6-dev.28",
3
+ "version": "0.1.6-dev.29",
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.6-dev.14",
36
+ "@gct-paas/api": "^0.1.6-dev.15",
37
37
  "@module-federation/runtime": "^2.2.3",
38
38
  "@vueuse/core": "^14.1.0",
39
39
  "async-validator": "^4.2.5",
@@ -60,7 +60,7 @@
60
60
  "playwright": "^1.58.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "@gct-paas/api": "^0.1.6-dev.14",
63
+ "@gct-paas/api": "^0.1.6-dev.15",
64
64
  "vue": ">=3",
65
65
  "vue-i18n": ">=11",
66
66
  "vue-router": ">=4"