@gct-paas/core 0.1.6-dev.9 → 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.
- package/README.md +322 -0
- package/dist/index.esm.min.js +2 -1
- package/dist/{redirect-index-Ck5Ddtcb.js → redirect-index-DZ5iDlhA.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/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 +36 -27
- 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 -0
- 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
package/es/locale/index.mjs
CHANGED
|
@@ -98,15 +98,35 @@ var LocaleUtil = class {
|
|
|
98
98
|
}
|
|
99
99
|
async loadMessages(url, locale = this.locale) {
|
|
100
100
|
if (!url) return;
|
|
101
|
-
const
|
|
101
|
+
const data = await HttpUtil.get(url, {}, {}, {}, {
|
|
102
102
|
headers: { "Content-Type": void 0 },
|
|
103
103
|
nativeData: true
|
|
104
|
-
})
|
|
104
|
+
});
|
|
105
|
+
const messages = this.parseMessages(data);
|
|
106
|
+
this.i18n.global.mergeLocaleMessage(locale, messages);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 容错解析多语言文件内容。
|
|
110
|
+
* 兼容:已解析的 JSON 对象、JSON 字符串、双重编码的 JSON 字符串、旧版按行 key:value 文本。
|
|
111
|
+
*
|
|
112
|
+
* @param data 接口返回的多语言内容
|
|
113
|
+
* @returns 解析后的 key→文案 映射
|
|
114
|
+
*/
|
|
115
|
+
parseMessages(data) {
|
|
116
|
+
if (data !== null && typeof data === "object" && !Array.isArray(data)) return data;
|
|
117
|
+
if (typeof data !== "string") return {};
|
|
118
|
+
const str = data.trim();
|
|
119
|
+
if (!str) return {};
|
|
120
|
+
try {
|
|
121
|
+
let parsed = JSON.parse(str);
|
|
122
|
+
if (typeof parsed === "string") parsed = JSON.parse(parsed);
|
|
123
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
124
|
+
} catch {}
|
|
125
|
+
return str.split("\n").reduce((acc, item) => {
|
|
105
126
|
const [key, ...value] = item.split(":");
|
|
106
127
|
acc[key] = value.join(":");
|
|
107
128
|
return acc;
|
|
108
129
|
}, {});
|
|
109
|
-
this.i18n.global.mergeLocaleMessage(locale, messages);
|
|
110
130
|
}
|
|
111
131
|
getMessageUrl(payload) {
|
|
112
132
|
if ("app" in payload) {
|
|
@@ -116,6 +136,40 @@ var LocaleUtil = class {
|
|
|
116
136
|
return `/minio/locale-js/${payload.locale}__platform__.json`;
|
|
117
137
|
}
|
|
118
138
|
/**
|
|
139
|
+
* 自动注册 import.meta.glob 扫描到的 locale 模块。
|
|
140
|
+
* 根据文件路径生成 key(去除 locale 目录和 .ts 后缀,/ 替换为 .),
|
|
141
|
+
* 构建嵌套对象后合并到 i18n 实例。
|
|
142
|
+
*
|
|
143
|
+
* @param globResult - import.meta.glob 返回的模块映射
|
|
144
|
+
* @param locale - 目标语言标识,默认 'zh-CN'
|
|
145
|
+
*/
|
|
146
|
+
autoRegisterLocale(globResult, locale = "zh-CN") {
|
|
147
|
+
for (const path in globResult) {
|
|
148
|
+
const mod = globResult[path];
|
|
149
|
+
if (!mod?.default) continue;
|
|
150
|
+
const key = this.pathToLocaleKey(path);
|
|
151
|
+
if (!key) continue;
|
|
152
|
+
const messages = this.flattenObject(mod.default, key);
|
|
153
|
+
this.addLocaleMessages(locale, messages);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** 路径转 key: './sys/pageDesigner.ts' → 'sys.pageDesigner',排除 index */
|
|
157
|
+
pathToLocaleKey(path) {
|
|
158
|
+
const cleaned = path.replace(/^\.\//, "").replace(/\.ts$/, "");
|
|
159
|
+
if (cleaned === "index" || cleaned.endsWith("/index")) return null;
|
|
160
|
+
return cleaned.replace(/\//g, ".");
|
|
161
|
+
}
|
|
162
|
+
/** 将嵌套对象展平为点号路径: { a: { b: 'hi' } }, 'prefix' → { 'prefix.a.b': 'hi' } */
|
|
163
|
+
flattenObject(obj, prefix) {
|
|
164
|
+
const result = {};
|
|
165
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
166
|
+
const fullKey = `${prefix}.${k}`;
|
|
167
|
+
if (v !== null && typeof v === "object" && !Array.isArray(v)) Object.assign(result, this.flattenObject(v, fullKey));
|
|
168
|
+
else result[fullKey] = v;
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
119
173
|
* 设置 HTML 根元素的 lang 属性,供浏览器、辅助技术识别当前语言
|
|
120
174
|
*
|
|
121
175
|
* @param locale 语言标识,如 zh-CN、en
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region src/locale/sys/model.ts
|
|
3
|
+
var model_exports = /* @__PURE__ */ __exportAll({ default: () => model_default });
|
|
4
|
+
var model_default = {
|
|
5
|
+
modelNameError: "不能包含表情符号及以下特殊字符:?*:,[]#",
|
|
6
|
+
notModelNameError: "不能包含表情符号及以下特殊字符:\\/?*:,[]#"
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { model_exports };
|
package/es/locale/sys.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
errMsg401: string;
|
|
3
|
+
errMsg403: string;
|
|
4
|
+
errMsg404: string;
|
|
5
|
+
errMsg405: string;
|
|
6
|
+
errMsg408: string;
|
|
7
|
+
errMsg500: string;
|
|
8
|
+
errMsg501: string;
|
|
9
|
+
errMsg502: string;
|
|
10
|
+
errMsg503: string;
|
|
11
|
+
errMsg504: string;
|
|
12
|
+
errMsg505: string;
|
|
13
|
+
errorTip: string;
|
|
14
|
+
apiTimeoutMessage: string;
|
|
15
|
+
networkExceptionMsg: string;
|
|
2
16
|
notNull: string;
|
|
3
17
|
regError: string;
|
|
18
|
+
loginWarning: string;
|
|
19
|
+
loginWarningContent: string;
|
|
20
|
+
understood: string;
|
|
4
21
|
};
|
|
5
22
|
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
//#region src/locale/sys.ts
|
|
3
|
+
var sys_exports = /* @__PURE__ */ __exportAll({ default: () => sys_default });
|
|
4
|
+
var sys_default = {
|
|
5
|
+
errMsg401: "请重新登录",
|
|
6
|
+
errMsg403: "用户得到授权,但是访问是被禁止的!",
|
|
7
|
+
errMsg404: "网络请求错误,未找到该资源!",
|
|
8
|
+
errMsg405: "网络请求错误,请求方法未允许!",
|
|
9
|
+
errMsg408: "网络请求超时!",
|
|
10
|
+
errMsg500: "服务器错误,请联系管理员!",
|
|
11
|
+
errMsg501: "网络未实现!",
|
|
12
|
+
errMsg502: "网络错误!",
|
|
13
|
+
errMsg503: "服务不可用,服务器暂时过载或维护!",
|
|
14
|
+
errMsg504: "网络超时!",
|
|
15
|
+
errMsg505: "http版本不支持该请求!",
|
|
16
|
+
errorTip: "错误提示",
|
|
17
|
+
apiTimeoutMessage: "接口请求超时,请刷新页面重试!",
|
|
18
|
+
networkExceptionMsg: "网络异常,请检查您的网络连接是否正常!",
|
|
19
|
+
notNull: "该值不能为空",
|
|
20
|
+
regError: "校验格式不正确",
|
|
21
|
+
loginWarning: "登录警告",
|
|
22
|
+
loginWarningContent: "当前账号已在其他设备登录",
|
|
23
|
+
understood: "知道了"
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { sys_exports };
|
|
@@ -14,6 +14,8 @@ var DEV_SINGLE_PATH_REG = /\/dev-single\//;
|
|
|
14
14
|
/** 测试环境单应用路径正则表达式 */
|
|
15
15
|
var TEST_SINGLE_PATH_REG = /\/test-single\//;
|
|
16
16
|
/** 沙箱环境路径正则表达式 */
|
|
17
|
-
var SANDBOX_PATH_REG = /(mobile|pad)-sandbox/;
|
|
17
|
+
var SANDBOX_PATH_REG = /(mobile|pad|web)-sandbox/;
|
|
18
|
+
/** 单应用环境路径正则表达式 */
|
|
19
|
+
var SINGLE_PATH_REG = /\/web-single\/|dev-single\/|test-single\//;
|
|
18
20
|
//#endregion
|
|
19
|
-
export { APP_PREVIEW_PATH_REG, APP_PROD_PATH_REG, APP_RUN_PATH_REG, DEV_SINGLE_PATH_REG, HOST_REG, IP_REG, SANDBOX_PATH_REG, TEST_SINGLE_PATH_REG };
|
|
21
|
+
export { APP_PREVIEW_PATH_REG, APP_PROD_PATH_REG, APP_RUN_PATH_REG, DEV_SINGLE_PATH_REG, HOST_REG, IP_REG, SANDBOX_PATH_REG, SINGLE_PATH_REG, TEST_SINGLE_PATH_REG };
|
|
@@ -18,21 +18,9 @@ export declare class EnvironmentManager implements IEnvironmentManager {
|
|
|
18
18
|
/**安卓混合开发模式下 */
|
|
19
19
|
get isAndroid(): boolean;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
get isAppRun(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* 是否为应用前端运行时生产环境包含测试环境
|
|
21
|
+
* 是否为生产环境
|
|
26
22
|
*/
|
|
27
23
|
get isAppProd(): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* 是否为应用前端运行时预览环境
|
|
30
|
-
*/
|
|
31
|
-
get isAppPreview(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* 是否为dev环境单应用
|
|
34
|
-
*/
|
|
35
|
-
get isDevSingleEnv(): boolean;
|
|
36
24
|
/**
|
|
37
25
|
* 是否为测试环境
|
|
38
26
|
*/
|
|
@@ -49,6 +37,13 @@ export declare class EnvironmentManager implements IEnvironmentManager {
|
|
|
49
37
|
* 测试环境租户数据
|
|
50
38
|
*/
|
|
51
39
|
get testTenantData(): Tenant;
|
|
40
|
+
/**
|
|
41
|
+
* 是否为单应用模式
|
|
42
|
+
*
|
|
43
|
+
* @readonly
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
get isAppSingle(): boolean;
|
|
52
47
|
/**
|
|
53
48
|
* 是否为沙箱环境
|
|
54
49
|
*/
|
|
@@ -8,7 +8,9 @@ export declare enum EnvironmentType {
|
|
|
8
8
|
/** 测试环境 */
|
|
9
9
|
TEST = "test",
|
|
10
10
|
/** 生产环境 */
|
|
11
|
-
PROD = "prod"
|
|
11
|
+
PROD = "prod",
|
|
12
|
+
/** 沙箱环境 */
|
|
13
|
+
SANDBOX = "sbx"
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* 环境管理器接口
|
|
@@ -16,14 +18,8 @@ export declare enum EnvironmentType {
|
|
|
16
18
|
export interface IEnvironmentManager {
|
|
17
19
|
/** 是否为安卓混合模式下运行 */
|
|
18
20
|
readonly isAndroid: boolean;
|
|
19
|
-
/**
|
|
20
|
-
readonly isAppRun: boolean;
|
|
21
|
-
/** 是否为应用前端运行时生产环境 */
|
|
21
|
+
/** 是否为生产环境 */
|
|
22
22
|
readonly isAppProd: boolean;
|
|
23
|
-
/** 是否为应用前端运行时预览环境 */
|
|
24
|
-
readonly isAppPreview: boolean;
|
|
25
|
-
/** 是否为dev环境单应用 */
|
|
26
|
-
readonly isDevSingleEnv: boolean;
|
|
27
23
|
/** 是否为测试环境 */
|
|
28
24
|
readonly isTestEnv: boolean;
|
|
29
25
|
/** 平台地址 */
|
|
@@ -33,7 +29,7 @@ export interface IEnvironmentManager {
|
|
|
33
29
|
/** 测试环境租户数据 */
|
|
34
30
|
readonly testTenantData: Tenant;
|
|
35
31
|
/** 是否为沙箱环境 */
|
|
36
|
-
|
|
32
|
+
isSandbox: boolean;
|
|
37
33
|
/**
|
|
38
34
|
* 检测是否为测试环境
|
|
39
35
|
* @param loadTenant 是否加载租户信息
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ENV } from "../../store/session-store.mjs";
|
|
2
1
|
import { EnvironmentType } from "./env-manager.interface.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { ENV } from "../../store/session-store.mjs";
|
|
3
|
+
import { HOST_REG, IP_REG } from "./env-manager.const.mjs";
|
|
4
4
|
//#region src/modules/env-manager/env-manager.ts
|
|
5
5
|
/**
|
|
6
6
|
* 环境管理器
|
|
@@ -25,34 +25,16 @@ var EnvironmentManager = class {
|
|
|
25
25
|
return window.__GCT_ANDROID__ === true;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
get isAppRun() {
|
|
31
|
-
return APP_RUN_PATH_REG.test(location.pathname);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 是否为应用前端运行时生产环境包含测试环境
|
|
28
|
+
* 是否为生产环境
|
|
35
29
|
*/
|
|
36
30
|
get isAppProd() {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 是否为应用前端运行时预览环境
|
|
41
|
-
*/
|
|
42
|
-
get isAppPreview() {
|
|
43
|
-
return APP_PREVIEW_PATH_REG.test(location.pathname);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 是否为dev环境单应用
|
|
47
|
-
*/
|
|
48
|
-
get isDevSingleEnv() {
|
|
49
|
-
return DEV_SINGLE_PATH_REG.test(location.pathname);
|
|
31
|
+
return _gct.store.context.env === EnvironmentType.PROD;
|
|
50
32
|
}
|
|
51
33
|
/**
|
|
52
34
|
* 是否为测试环境
|
|
53
35
|
*/
|
|
54
36
|
get isTestEnv() {
|
|
55
|
-
return
|
|
37
|
+
return this._testEnv || _gct.store.context.env === EnvironmentType.TEST;
|
|
56
38
|
}
|
|
57
39
|
/**
|
|
58
40
|
* 平台地址
|
|
@@ -73,10 +55,19 @@ var EnvironmentManager = class {
|
|
|
73
55
|
return this._testTenantData;
|
|
74
56
|
}
|
|
75
57
|
/**
|
|
58
|
+
* 是否为单应用模式
|
|
59
|
+
*
|
|
60
|
+
* @readonly
|
|
61
|
+
* @type {boolean}
|
|
62
|
+
*/
|
|
63
|
+
get isAppSingle() {
|
|
64
|
+
return _gct.store.context.mode === "single";
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
76
67
|
* 是否为沙箱环境
|
|
77
68
|
*/
|
|
78
69
|
get isSandbox() {
|
|
79
|
-
return
|
|
70
|
+
return _gct.store.context.env === EnvironmentType.SANDBOX;
|
|
80
71
|
}
|
|
81
72
|
/**
|
|
82
73
|
* 检测是否为测试环境
|
|
@@ -101,6 +92,7 @@ var EnvironmentManager = class {
|
|
|
101
92
|
}
|
|
102
93
|
}
|
|
103
94
|
}
|
|
95
|
+
if (this._testEnv) await _gct.store.setContext({ env: EnvironmentType.TEST });
|
|
104
96
|
}
|
|
105
97
|
/**
|
|
106
98
|
* 获取当前环境类型
|
|
@@ -108,9 +100,9 @@ var EnvironmentManager = class {
|
|
|
108
100
|
*/
|
|
109
101
|
getEnv() {
|
|
110
102
|
if (ENV.value) return ENV.value;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
if (this.isTestEnv) return EnvironmentType.TEST;
|
|
104
|
+
if (_gct.store.context.env) return _gct.store.context.env;
|
|
105
|
+
return EnvironmentType.DEV;
|
|
114
106
|
}
|
|
115
107
|
};
|
|
116
108
|
//#endregion
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EnvironmentType } from "./env-manager.interface.mjs";
|
|
2
|
+
//#region src/modules/env-manager/env-manager.util.ts
|
|
3
|
+
var ENV_VALUES = new Set(Object.values(EnvironmentType));
|
|
4
|
+
/**
|
|
5
|
+
* 校验并规范化环境类型
|
|
6
|
+
*/
|
|
7
|
+
function normalizeEnv(env) {
|
|
8
|
+
if (typeof env === "string" && ENV_VALUES.has(env)) return env;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { normalizeEnv };
|
|
@@ -7,6 +7,10 @@ import { MqttConnectionStatus } from '../enums/mqtt-status.enum';
|
|
|
7
7
|
* @param payload 消息内容
|
|
8
8
|
*/
|
|
9
9
|
export type IMqttMessageCallback = (topic: string, payload: Buffer) => void;
|
|
10
|
+
/**
|
|
11
|
+
* 取消订阅函数类型
|
|
12
|
+
*/
|
|
13
|
+
export type MqttCancelSub = () => void;
|
|
10
14
|
/**
|
|
11
15
|
* MQTT 客户端事件回调函数类型映射
|
|
12
16
|
*/
|
|
@@ -66,13 +70,13 @@ export interface IMqttClient {
|
|
|
66
70
|
* @param callback 消息回调函数
|
|
67
71
|
* @returns 取消订阅函数
|
|
68
72
|
*/
|
|
69
|
-
subscribe(topics: string
|
|
73
|
+
subscribe(topics: string, callback: IMqttMessageCallback): MqttCancelSub;
|
|
70
74
|
/**
|
|
71
75
|
* 取消订阅一个或多个主题
|
|
72
76
|
*
|
|
73
77
|
* @param topics 主题或主题数组
|
|
74
78
|
*/
|
|
75
|
-
unsubscribe(topics: string
|
|
79
|
+
unsubscribe(topics: string): void;
|
|
76
80
|
/**
|
|
77
81
|
* 向指定主题发布消息
|
|
78
82
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MqttConnectionStatus } from './enums/mqtt-status.enum';
|
|
2
|
-
import { IMqttClient, IMqttClientEventMap, IMqttConnectOptions, IMqttMessageCallback, IMqttPublishOptions } from './interfaces/i-mqtt';
|
|
2
|
+
import { MqttCancelSub, IMqttClient, IMqttClientEventMap, IMqttConnectOptions, IMqttMessageCallback, IMqttPublishOptions } from './interfaces/i-mqtt';
|
|
3
3
|
/**
|
|
4
4
|
* MQTT 客户端
|
|
5
5
|
*
|
|
@@ -48,19 +48,19 @@ export declare class MqttClient implements IMqttClient {
|
|
|
48
48
|
*/
|
|
49
49
|
disconnect(): void;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* 订阅一个主题
|
|
52
52
|
*
|
|
53
|
-
* @param
|
|
53
|
+
* @param topic 主题
|
|
54
54
|
* @param callback 消息回调函数
|
|
55
55
|
* @returns 取消订阅函数
|
|
56
56
|
*/
|
|
57
|
-
subscribe(
|
|
57
|
+
subscribe(topic: string, callback: IMqttMessageCallback): MqttCancelSub;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* 取消订阅一个主题,取消订阅时会移除所有回调函数
|
|
60
60
|
*
|
|
61
|
-
* @param
|
|
61
|
+
* @param topic 主题
|
|
62
62
|
*/
|
|
63
|
-
unsubscribe(
|
|
63
|
+
unsubscribe(topic: string): void;
|
|
64
64
|
/**
|
|
65
65
|
* 向指定主题发布消息
|
|
66
66
|
*
|
|
@@ -84,6 +84,7 @@ export declare class MqttClient implements IMqttClient {
|
|
|
84
84
|
* @param listener 监听函数
|
|
85
85
|
*/
|
|
86
86
|
off<E extends keyof IMqttClientEventMap>(event: E, listener: IMqttClientEventMap[E]): void;
|
|
87
|
+
private _connect;
|
|
87
88
|
/**
|
|
88
89
|
* 绑定 mqtt.js 内部事件
|
|
89
90
|
*
|
|
@@ -85,33 +85,34 @@ var MqttClient = class {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* 订阅一个主题
|
|
89
89
|
*
|
|
90
|
-
* @param
|
|
90
|
+
* @param topic 主题
|
|
91
91
|
* @param callback 消息回调函数
|
|
92
92
|
* @returns 取消订阅函数
|
|
93
93
|
*/
|
|
94
|
-
subscribe(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this._subscriptions.get(topic)
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
subscribe(topic, callback) {
|
|
95
|
+
if (!this._subscriptions.has(topic)) {
|
|
96
|
+
this._subscriptions.set(topic, /* @__PURE__ */ new Set());
|
|
97
|
+
if (this._client && this._status === MqttConnectionStatus.CONNECTED) this._client.subscribe(topic);
|
|
98
|
+
}
|
|
99
|
+
this._subscriptions.get(topic).add(callback);
|
|
100
|
+
return () => {
|
|
101
|
+
const arr = this._subscriptions.get(topic);
|
|
102
|
+
if (arr) {
|
|
103
|
+
arr.delete(callback);
|
|
104
|
+
if (arr.size === 0) this.unsubscribe(topic);
|
|
105
|
+
} else console.warn(`MqttClient [${this.instanceId}]: 取消订阅时未找到 topic [${topic}] 的回调集合`);
|
|
106
|
+
};
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
106
|
-
*
|
|
109
|
+
* 取消订阅一个主题,取消订阅时会移除所有回调函数
|
|
107
110
|
*
|
|
108
|
-
* @param
|
|
111
|
+
* @param topic 主题
|
|
109
112
|
*/
|
|
110
|
-
unsubscribe(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (this._client && this._status === MqttConnectionStatus.CONNECTED) this._client.unsubscribe(topic);
|
|
114
|
-
});
|
|
113
|
+
unsubscribe(topic) {
|
|
114
|
+
this._subscriptions.delete(topic);
|
|
115
|
+
if (this._client && this._status === MqttConnectionStatus.CONNECTED) this._client.unsubscribe(topic);
|
|
115
116
|
}
|
|
116
117
|
/**
|
|
117
118
|
* 向指定主题发布消息
|
|
@@ -155,6 +156,11 @@ var MqttClient = class {
|
|
|
155
156
|
off(event, listener) {
|
|
156
157
|
this._eventListeners[event].delete(listener);
|
|
157
158
|
}
|
|
159
|
+
_connect() {
|
|
160
|
+
this._subscriptions.forEach((_, topic) => {
|
|
161
|
+
if (this._client) this._client.subscribe(topic);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
158
164
|
/**
|
|
159
165
|
* 绑定 mqtt.js 内部事件
|
|
160
166
|
*
|
|
@@ -163,17 +169,22 @@ var MqttClient = class {
|
|
|
163
169
|
_bindClientEvents() {
|
|
164
170
|
if (!this._client) return;
|
|
165
171
|
this._client.on("connect", (_connack) => {
|
|
172
|
+
console.debug(`[${this._options.clientId}] MQTT 已连接`);
|
|
173
|
+
this._connect();
|
|
166
174
|
this._status = MqttConnectionStatus.CONNECTED;
|
|
167
175
|
this._emitEvent(MQTT_CLIENT_EVENT.CONNECT);
|
|
168
176
|
});
|
|
169
177
|
this._client.on("reconnect", () => {
|
|
178
|
+
console.debug(`[${this._options.clientId}] MQTT 正在尝试重连...`);
|
|
170
179
|
this._status = MqttConnectionStatus.RECONNECTING;
|
|
171
180
|
this._emitEvent(MQTT_CLIENT_EVENT.RECONNECT);
|
|
172
181
|
});
|
|
173
182
|
this._client.on("error", (err) => {
|
|
183
|
+
console.error(`[${this._options.clientId}] MQTT 连接错误:`, err);
|
|
174
184
|
this._emitEvent(MQTT_CLIENT_EVENT.ERROR, err);
|
|
175
185
|
});
|
|
176
186
|
this._client.on("close", () => {
|
|
187
|
+
console.debug(`[${this._options.clientId}] MQTT 连接已关闭`);
|
|
177
188
|
if (this._status !== MqttConnectionStatus.DISCONNECTING) this._status = MqttConnectionStatus.DISCONNECTED;
|
|
178
189
|
});
|
|
179
190
|
this._client.on("message", (topic, payload) => {
|
|
@@ -5,5 +5,13 @@
|
|
|
5
5
|
export declare const MENU_COLLAPSED_WIDTH = 46;
|
|
6
6
|
/** 菜单宽度范围 */
|
|
7
7
|
export declare const MENU_WIDTH_RANGE: number[];
|
|
8
|
+
/** 默认主题色(蓝) */
|
|
9
|
+
export declare const THEME_COLOR_BLUE = "#026AC8";
|
|
10
|
+
/** 青绿主题色 */
|
|
11
|
+
export declare const THEME_COLOR_TEAL = "#0DAA9C";
|
|
8
12
|
/** 可选的主题颜色列表 */
|
|
9
|
-
export declare const THEME_COLORS:
|
|
13
|
+
export declare const THEME_COLORS: readonly ["#026AC8", "#0DAA9C"];
|
|
14
|
+
/** 非默认主题色对应的 class 名 */
|
|
15
|
+
export declare const THEME_COLOR_CLASS = "theme-color-teal";
|
|
16
|
+
/** 主题色 hex → class 映射;null 表示默认色(移除 class 即可) */
|
|
17
|
+
export declare const THEME_COLOR_CLASS_MAP: Record<string, string | null>;
|
|
@@ -6,7 +6,18 @@
|
|
|
6
6
|
var MENU_COLLAPSED_WIDTH = 46;
|
|
7
7
|
/** 菜单宽度范围 */
|
|
8
8
|
var MENU_WIDTH_RANGE = [100, 1e3];
|
|
9
|
+
/** 默认主题色(蓝) */
|
|
10
|
+
var THEME_COLOR_BLUE = "#026AC8";
|
|
11
|
+
/** 青绿主题色 */
|
|
12
|
+
var THEME_COLOR_TEAL = "#0DAA9C";
|
|
9
13
|
/** 可选的主题颜色列表 */
|
|
10
|
-
var THEME_COLORS = [
|
|
14
|
+
var THEME_COLORS = [THEME_COLOR_BLUE, THEME_COLOR_TEAL];
|
|
15
|
+
/** 非默认主题色对应的 class 名 */
|
|
16
|
+
var THEME_COLOR_CLASS = "theme-color-teal";
|
|
17
|
+
/** 主题色 hex → class 映射;null 表示默认色(移除 class 即可) */
|
|
18
|
+
var THEME_COLOR_CLASS_MAP = {
|
|
19
|
+
[THEME_COLOR_BLUE]: null,
|
|
20
|
+
[THEME_COLOR_TEAL]: THEME_COLOR_CLASS
|
|
21
|
+
};
|
|
11
22
|
//#endregion
|
|
12
|
-
export { MENU_COLLAPSED_WIDTH, MENU_WIDTH_RANGE, THEME_COLORS };
|
|
23
|
+
export { MENU_COLLAPSED_WIDTH, MENU_WIDTH_RANGE, THEME_COLORS, THEME_COLOR_BLUE, THEME_COLOR_CLASS, THEME_COLOR_CLASS_MAP, THEME_COLOR_TEAL };
|
|
@@ -24,6 +24,8 @@ var LoginTypeEnum = /* @__PURE__ */ function(LoginTypeEnum) {
|
|
|
24
24
|
LoginTypeEnum["FEISHU"] = "FEISHU";
|
|
25
25
|
/** 企业微信 */
|
|
26
26
|
LoginTypeEnum["QIYEWEIXIN"] = "QIYEWEIXIN";
|
|
27
|
+
/** 微软 */
|
|
28
|
+
LoginTypeEnum["MICROSOFT"] = "MICROSOFT";
|
|
27
29
|
return LoginTypeEnum;
|
|
28
30
|
}({});
|
|
29
31
|
//#endregion
|