@gct-paas/core 0.1.4-dev.11 → 0.1.4-dev.13
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/dist/index.esm.min.js +4522 -0
- package/es/constants/core.mjs +5 -4
- package/es/constants/default-date-type/default-date-type.mjs +73 -21
- package/es/constants/editor-register/editor-register.mjs +17 -5
- package/es/constants/expression-type/BuiltOperators.mjs +152 -147
- package/es/constants/expression-type/FunctionKeys.mjs +75 -79
- package/es/constants/expression-type/editor.mjs +10 -3
- package/es/constants/expression-type/function.mjs +602 -613
- package/es/constants/expression-type/index.mjs +111 -113
- package/es/constants/expression-type/modeCfg.mjs +256 -263
- package/es/constants/expression-type/variable.mjs +43 -39
- package/es/constants/form-container-type/form-container-type.mjs +17 -5
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.mjs +31 -10
- package/es/constants/page-designer/model.mjs +15 -5
- package/es/constants/page-designer/regex.d.ts +2 -0
- package/es/constants/page-designer/regex.mjs +5 -0
- package/es/create-app-vue.mjs +15 -9
- package/es/enums/app-designer/index.d.ts +19 -0
- package/es/enums/app-designer/index.mjs +131 -63
- package/es/enums/appEnum.mjs +681 -360
- package/es/enums/appStateEnum.mjs +17 -10
- package/es/enums/authActionEnum.mjs +63 -51
- package/es/enums/breakpointEnum.mjs +27 -26
- package/es/enums/cacheEnum.mjs +22 -21
- package/es/enums/designEnum.mjs +110 -71
- package/es/enums/developer-center/integration.mjs +7 -6
- package/es/enums/exceptionEnum.mjs +21 -17
- package/es/enums/expressionEnum.d.ts +1 -1
- package/es/enums/expressionEnum.mjs +81 -74
- package/es/enums/globalEnum.mjs +59 -36
- package/es/enums/httpEnum.mjs +71 -61
- package/es/enums/index.mjs +44 -14
- package/es/enums/menuEnum.mjs +42 -38
- package/es/enums/page-designer/designer.mjs +403 -407
- package/es/enums/page-designer/index.d.ts +1 -0
- package/es/enums/page-designer/index.mjs +5 -0
- package/es/enums/page-designer/layout.d.ts +12 -0
- package/es/enums/page-designer/layout.mjs +17 -0
- package/es/enums/page-designer/panel.mjs +341 -213
- package/es/enums/page-designer/toolkit.mjs +13 -12
- package/es/enums/page-designer/widget.mjs +425 -338
- package/es/enums/pageEnum.mjs +14 -13
- package/es/enums/plugin-enum.mjs +23 -7
- package/es/enums/processEnum.mjs +95 -60
- package/es/enums/roleEnum.mjs +7 -6
- package/es/enums/sizeEnum.d.ts +18 -0
- package/es/enums/sizeEnum.mjs +28 -8
- package/es/global/gct/gct.mjs +84 -96
- package/es/global/index.mjs +1 -0
- package/es/hooks/index.mjs +4 -0
- package/es/hooks/use-app-inst/use-app-inst.mjs +11 -5
- package/es/hooks/use-modal/use-modal.mjs +16 -10
- package/es/hooks/use-sub-app-utils/use-sub-app-utils.mjs +43 -23
- package/es/hooks/useCopyToClipboard.mjs +50 -50
- package/es/index.mjs +125 -114
- package/es/interface/i-pinia-state/i-global-state.d.ts +0 -11
- package/es/locale/index.mjs +50 -57
- package/es/modules/env-manager/env-manager.const.mjs +16 -8
- package/es/modules/env-manager/env-manager.d.ts +2 -0
- package/es/modules/env-manager/env-manager.interface.d.ts +2 -0
- package/es/modules/env-manager/env-manager.interface.mjs +14 -7
- package/es/modules/env-manager/env-manager.mjs +108 -107
- package/es/modules/error-handler/error-handler.const.mjs +11 -16
- package/es/modules/error-handler/error-strategy.mjs +199 -175
- package/es/modules/error-handler/index.mjs +120 -106
- package/es/modules/mqtt/constants/mqtt.const.mjs +21 -24
- package/es/modules/mqtt/enums/mqtt-status.enum.mjs +23 -9
- package/es/modules/mqtt/index.mjs +4 -0
- package/es/modules/mqtt/mqtt-client.mjs +228 -261
- package/es/modules/mqtt/mqtt-manager.mjs +117 -77
- package/es/modules/platform-config/constants/index.mjs +4 -0
- package/es/modules/platform-config/constants/login.const.mjs +48 -45
- package/es/modules/platform-config/constants/org.const.mjs +57 -52
- package/es/modules/platform-config/constants/theme.const.mjs +11 -4
- package/es/modules/platform-config/constants/watermark.const.mjs +17 -12
- package/es/modules/platform-config/enums/deploy.enum.mjs +13 -6
- package/es/modules/platform-config/enums/login.enum.mjs +29 -15
- package/es/modules/platform-config/enums/platform.enum.mjs +16 -13
- package/es/modules/platform-config/index.mjs +9 -0
- package/es/modules/platform-config/store.mjs +68 -79
- package/es/modules/platform-config/useBasicSetting.mjs +47 -35
- package/es/modules/platform-config/useDeploySetting.mjs +29 -21
- package/es/modules/platform-config/useLoginSetting.mjs +151 -173
- package/es/modules/platform-config/useOrgSetting.mjs +63 -62
- package/es/modules/platform-config/useProjectSetting.mjs +14 -6
- package/es/modules/platform-config/useSecuritySetting.mjs +68 -56
- package/es/modules/platform-config/useThemeSetting.mjs +78 -59
- package/es/modules/platform-config/useWatermarkSetting.mjs +37 -23
- package/es/modules/user-stores/index.mjs +3 -0
- package/es/modules/user-stores/store/permission.store.mjs +27 -36
- package/es/modules/user-stores/store/tenant.store.mjs +20 -22
- package/es/modules/user-stores/store/user.store.mjs +94 -117
- package/es/router/index.mjs +25 -28
- package/es/setup-app.mjs +23 -39
- package/es/state/global-pinia-state/global-pinia-state.d.ts +0 -6
- package/es/state/global-pinia-state/global-pinia-state.mjs +43 -71
- package/es/state/index.mjs +1 -0
- package/es/store/global-store.mjs +50 -72
- package/es/store/index.mjs +25 -19
- package/es/types/index.d.ts +7 -0
- package/es/utils/axios/interceptors.mjs +21 -17
- package/es/utils/cache-adapter/cache-adapter.mjs +61 -56
- package/es/utils/css-loader/css-loader.d.ts +36 -0
- package/es/utils/css-loader/css-loader.mjs +82 -0
- package/es/utils/design/design.mjs +18 -12
- package/es/utils/deviceFingerprint.mjs +77 -63
- package/es/utils/dictionary/dictionary.mjs +142 -145
- package/es/utils/file/base64Conver.mjs +35 -30
- package/es/utils/file/download.mjs +94 -98
- package/es/utils/file/parser.d.ts +3 -0
- package/es/utils/file/parser.mjs +29 -0
- package/es/utils/i18n/index.mjs +14 -3
- package/es/utils/index.d.ts +3 -1
- package/es/utils/index.mjs +32 -0
- package/es/utils/is-sort-filed/is-sort-filed.mjs +42 -37
- package/es/utils/linked-list/linked-list.mjs +115 -118
- package/es/utils/linked-node/linked-node.mjs +41 -31
- package/es/utils/lowcode/utils.mjs +13 -18
- package/es/utils/lowcode/validate.mjs +20 -26
- package/es/utils/mitt/mitt.mjs +4 -4
- package/es/utils/model-loader/model-loader.mjs +280 -325
- package/es/utils/namespace/namespace.mjs +178 -164
- package/es/utils/openUtil/index.mjs +2 -0
- package/es/utils/openUtil/modal/modal.mjs +72 -79
- package/es/utils/openUtil/overlay-container/overlay-container.mjs +144 -138
- package/es/utils/permission.mjs +33 -37
- package/es/utils/plugin-static-resource/plugin-static-resource.mjs +46 -42
- package/es/utils/style/index.mjs +94 -138
- package/es/utils/tools/tools.mjs +86 -54
- package/es/utils/treeHelper/treeHelper.mjs +205 -233
- package/es/utils/uploader/uploader.mjs +81 -115
- package/es/utils/useUUid.mjs +79 -87
- package/es/utils/util.mjs +55 -35
- package/es/utils/uuid/uuid.d.ts +2 -0
- package/es/utils/uuid/uuid.mjs +33 -43
- package/es/utils/validate.mjs +15 -19
- package/es/utils/value-helper/value-helper.mjs +113 -98
- package/package.json +9 -18
- package/dist/index.esm.min.mjs +0 -18322
- package/dist/index.min.cjs +0 -393
- package/dist/index.system.min.js +0 -393
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { getTenant, getTimezone, getToken, isMobile } from "../tools/tools.mjs";
|
|
2
|
+
import { AxiosHeaders } from "axios";
|
|
3
|
+
//#region src/utils/axios/interceptors.ts
|
|
4
|
+
/**
|
|
5
|
+
* 安装拦截器
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @param {AxiosInstance} axios
|
|
9
|
+
*/
|
|
4
10
|
function interceptors(axios) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return config;
|
|
17
|
-
});
|
|
11
|
+
axios.interceptors.request.use((config) => {
|
|
12
|
+
if (!config.headers) config.headers = new AxiosHeaders();
|
|
13
|
+
Object.assign(config.headers, {
|
|
14
|
+
Token: getToken(),
|
|
15
|
+
Source: isMobile ? 502 : 501,
|
|
16
|
+
Lang: _gct.store.lang,
|
|
17
|
+
"Tenant-Id": getTenant(),
|
|
18
|
+
Timezone: getTimezone()
|
|
19
|
+
});
|
|
20
|
+
return config;
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
//#endregion
|
|
20
24
|
export { interceptors };
|
|
@@ -1,59 +1,64 @@
|
|
|
1
|
-
import qs from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import qs from "qs";
|
|
2
|
+
//#region src/utils/cache-adapter/cache-adapter.ts
|
|
3
|
+
/**异步缓存函数 */
|
|
4
|
+
var gctMemoizeAsync = (...arg) => cacheAdapter.bind(null, ...arg);
|
|
5
|
+
/**
|
|
6
|
+
*异步缓存
|
|
7
|
+
* @param args
|
|
8
|
+
* @param adapter
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
4
11
|
function cacheAdapter(adapter, ...args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
/**默认缓存5分钟 */
|
|
13
|
+
const maxAge = 1e3 * 60 * 5;
|
|
14
|
+
const requestKey = typeof args === "object" ? qs.stringify(args) : args;
|
|
15
|
+
let responsePromise = MemoryCache.get(requestKey);
|
|
16
|
+
if (!responsePromise) {
|
|
17
|
+
responsePromise = (async () => {
|
|
18
|
+
try {
|
|
19
|
+
return await adapter(...args);
|
|
20
|
+
} catch (reason) {
|
|
21
|
+
MemoryCache.delete(requestKey);
|
|
22
|
+
throw reason;
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
MemoryCache.set(requestKey, responsePromise, maxAge);
|
|
26
|
+
return responsePromise;
|
|
27
|
+
}
|
|
28
|
+
return responsePromise;
|
|
21
29
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
30
|
+
var MemoryCache = class {
|
|
31
|
+
static cachedata = {};
|
|
32
|
+
static set(key, value, maxAge) {
|
|
33
|
+
this.cachedata[key] = {
|
|
34
|
+
maxAge: maxAge || 0,
|
|
35
|
+
value,
|
|
36
|
+
now: Date.now()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
static get(key) {
|
|
40
|
+
this.reset();
|
|
41
|
+
const cachedItem = this.cachedata[key];
|
|
42
|
+
if (!cachedItem) return null;
|
|
43
|
+
return cachedItem.value;
|
|
44
|
+
}
|
|
45
|
+
static delete(key) {
|
|
46
|
+
return delete this.cachedata[key];
|
|
47
|
+
}
|
|
48
|
+
static clear() {
|
|
49
|
+
this.cachedata = {};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
*清空过期的数据
|
|
53
|
+
*/
|
|
54
|
+
static reset() {
|
|
55
|
+
for (const key in this.cachedata) {
|
|
56
|
+
const cachedItem = this.cachedata[key];
|
|
57
|
+
if (cachedItem) {
|
|
58
|
+
if (Date.now() - cachedItem.now > cachedItem.maxAge) this.delete(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
59
64
|
export { gctMemoizeAsync };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS 动态加载工具类
|
|
3
|
+
*
|
|
4
|
+
* 从 CDN 动态加载 CSS 文件,具备以下特性:
|
|
5
|
+
* - 已成功加载的路径永久缓存,避免重复插入 link 标签
|
|
6
|
+
* - 同一时刻对同一路径的多次调用共享同一个 Promise(请求去重)
|
|
7
|
+
* - 加载失败不写入缓存,允许下次重试
|
|
8
|
+
* - 加载前检查 DOM 中是否已存在相同 href 的 link 标签
|
|
9
|
+
*
|
|
10
|
+
* @author chitanda
|
|
11
|
+
* @date 2026-03-16
|
|
12
|
+
* @class CssLoader
|
|
13
|
+
*/
|
|
14
|
+
declare class CssLoader {
|
|
15
|
+
/** 已成功加载的 CSS URL 集合(永久缓存) */
|
|
16
|
+
private _loadedSet;
|
|
17
|
+
/** 正在加载中的 CSS URL 对应的 Promise(用于请求去重) */
|
|
18
|
+
private _pendingMap;
|
|
19
|
+
/**
|
|
20
|
+
* 动态加载单个 CSS 文件
|
|
21
|
+
*
|
|
22
|
+
* @param {string} url CSS 文件的完整 URL
|
|
23
|
+
* @returns {Promise<void>} 加载完成后 resolve;加载失败则 reject
|
|
24
|
+
*/
|
|
25
|
+
load(url: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 并发加载多个 CSS 文件
|
|
28
|
+
*
|
|
29
|
+
* @param {string[]} urls CSS 文件 URL 列表
|
|
30
|
+
* @returns {Promise<void>} 所有文件均加载完成后 resolve;任一失败则 reject
|
|
31
|
+
*/
|
|
32
|
+
loadBatch(urls: string[]): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/** CSS 动态加载工具单例 */
|
|
35
|
+
export declare const cssLoader: CssLoader;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region src/utils/css-loader/css-loader.ts
|
|
2
|
+
/**
|
|
3
|
+
* CSS 动态加载工具类
|
|
4
|
+
*
|
|
5
|
+
* 从 CDN 动态加载 CSS 文件,具备以下特性:
|
|
6
|
+
* - 已成功加载的路径永久缓存,避免重复插入 link 标签
|
|
7
|
+
* - 同一时刻对同一路径的多次调用共享同一个 Promise(请求去重)
|
|
8
|
+
* - 加载失败不写入缓存,允许下次重试
|
|
9
|
+
* - 加载前检查 DOM 中是否已存在相同 href 的 link 标签
|
|
10
|
+
*
|
|
11
|
+
* @author chitanda
|
|
12
|
+
* @date 2026-03-16
|
|
13
|
+
* @class CssLoader
|
|
14
|
+
*/
|
|
15
|
+
var CssLoader = class {
|
|
16
|
+
/** 已成功加载的 CSS URL 集合(永久缓存) */
|
|
17
|
+
_loadedSet = /* @__PURE__ */ new Set();
|
|
18
|
+
/** 正在加载中的 CSS URL 对应的 Promise(用于请求去重) */
|
|
19
|
+
_pendingMap = /* @__PURE__ */ new Map();
|
|
20
|
+
/**
|
|
21
|
+
* 动态加载单个 CSS 文件
|
|
22
|
+
*
|
|
23
|
+
* @param {string} url CSS 文件的完整 URL
|
|
24
|
+
* @returns {Promise<void>} 加载完成后 resolve;加载失败则 reject
|
|
25
|
+
*/
|
|
26
|
+
load(url) {
|
|
27
|
+
if (this._loadedSet.has(url)) return Promise.resolve();
|
|
28
|
+
if (this._pendingMap.has(url)) return this._pendingMap.get(url);
|
|
29
|
+
if (typeof document !== "undefined") {
|
|
30
|
+
if (document.querySelector(`link[rel="stylesheet"][href="${CSS.escape ? CSS.escape(url) : url}"]`)) {
|
|
31
|
+
this._loadedSet.add(url);
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const promise = new Promise((resolve, reject) => {
|
|
36
|
+
if (typeof document === "undefined") {
|
|
37
|
+
reject(/* @__PURE__ */ new Error(`[CssLoader] 当前环境不支持 DOM,无法加载 CSS: ${url}`));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const link = document.createElement("link");
|
|
41
|
+
link.rel = "stylesheet";
|
|
42
|
+
link.type = "text/css";
|
|
43
|
+
link.href = url;
|
|
44
|
+
/** 加载成功回调 */
|
|
45
|
+
const onLoad = () => {
|
|
46
|
+
cleanup();
|
|
47
|
+
this._loadedSet.add(url);
|
|
48
|
+
this._pendingMap.delete(url);
|
|
49
|
+
resolve();
|
|
50
|
+
};
|
|
51
|
+
/** 加载失败回调 */
|
|
52
|
+
const onError = () => {
|
|
53
|
+
cleanup();
|
|
54
|
+
this._pendingMap.delete(url);
|
|
55
|
+
reject(/* @__PURE__ */ new Error(`[CssLoader] CSS 文件加载失败: ${url}`));
|
|
56
|
+
};
|
|
57
|
+
/** 移除事件监听,防止内存泄漏 */
|
|
58
|
+
const cleanup = () => {
|
|
59
|
+
link.removeEventListener("load", onLoad);
|
|
60
|
+
link.removeEventListener("error", onError);
|
|
61
|
+
};
|
|
62
|
+
link.addEventListener("load", onLoad);
|
|
63
|
+
link.addEventListener("error", onError);
|
|
64
|
+
document.head.appendChild(link);
|
|
65
|
+
});
|
|
66
|
+
this._pendingMap.set(url, promise);
|
|
67
|
+
return promise;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 并发加载多个 CSS 文件
|
|
71
|
+
*
|
|
72
|
+
* @param {string[]} urls CSS 文件 URL 列表
|
|
73
|
+
* @returns {Promise<void>} 所有文件均加载完成后 resolve;任一失败则 reject
|
|
74
|
+
*/
|
|
75
|
+
async loadBatch(urls) {
|
|
76
|
+
await Promise.all(urls.map((url) => this.load(url)));
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/** CSS 动态加载工具单例 */
|
|
80
|
+
var cssLoader = new CssLoader();
|
|
81
|
+
//#endregion
|
|
82
|
+
export { cssLoader };
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { notSingleArr } from "../../enums/designEnum.mjs";
|
|
2
|
+
import "../../enums/index.mjs";
|
|
3
|
+
import { intersection } from "lodash-es";
|
|
4
|
+
//#region src/utils/design/design.ts
|
|
5
|
+
/**
|
|
6
|
+
* 是否完全为多选算子
|
|
7
|
+
*
|
|
8
|
+
* @description 只有全部是多选算子时,下拉才可以算是多选
|
|
9
|
+
* @author zhanghanrui
|
|
10
|
+
* @date 2024-09-20 11:09:47
|
|
11
|
+
* @export
|
|
12
|
+
* @param {string[]} arr
|
|
13
|
+
* @return {*} {boolean}
|
|
14
|
+
*/
|
|
7
15
|
function isMultipleOperator(arr) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
16
|
+
const items = intersection(arr, notSingleArr);
|
|
17
|
+
if (items.length > 0 && items.length === arr.length) return true;
|
|
18
|
+
return false;
|
|
13
19
|
}
|
|
14
|
-
|
|
20
|
+
//#endregion
|
|
15
21
|
export { isMultipleOperator };
|
|
@@ -1,73 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/utils/deviceFingerprint.ts
|
|
2
|
+
/** 指纹缓存 key */
|
|
3
|
+
var FINGERPRINT_KEY = "FINGERPRINT";
|
|
4
|
+
/** 判断是否浏览器环境 */
|
|
4
5
|
function isBrowserEnv() {
|
|
5
|
-
|
|
6
|
+
return typeof window !== "undefined" && typeof navigator !== "undefined";
|
|
6
7
|
}
|
|
8
|
+
/** 获取客户端平台(浏览器 / 移动系统) */
|
|
7
9
|
function getClientPlatform() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
10
|
+
if (!isBrowserEnv()) return {
|
|
11
|
+
type: "unknown",
|
|
12
|
+
name: "unknown"
|
|
13
|
+
};
|
|
14
|
+
const ua = navigator.userAgent;
|
|
15
|
+
if (/iPad|iPhone|iPod/i.test(ua)) return {
|
|
16
|
+
type: "mobile",
|
|
17
|
+
name: "iOS"
|
|
18
|
+
};
|
|
19
|
+
if (/Android/i.test(ua)) return {
|
|
20
|
+
type: "mobile",
|
|
21
|
+
name: "Android"
|
|
22
|
+
};
|
|
23
|
+
if (/Windows Phone/i.test(ua)) return {
|
|
24
|
+
type: "mobile",
|
|
25
|
+
name: "Windows Phone"
|
|
26
|
+
};
|
|
27
|
+
if (/BlackBerry/i.test(ua)) return {
|
|
28
|
+
type: "mobile",
|
|
29
|
+
name: "BlackBerry"
|
|
30
|
+
};
|
|
31
|
+
if (/Edg/i.test(ua)) return {
|
|
32
|
+
type: "web",
|
|
33
|
+
name: "Edge"
|
|
34
|
+
};
|
|
35
|
+
if (/OPR|Opera/i.test(ua)) return {
|
|
36
|
+
type: "web",
|
|
37
|
+
name: "Opera"
|
|
38
|
+
};
|
|
39
|
+
if (/Firefox/i.test(ua)) return {
|
|
40
|
+
type: "web",
|
|
41
|
+
name: "Firefox"
|
|
42
|
+
};
|
|
43
|
+
if (/Chrome/i.test(ua)) return {
|
|
44
|
+
type: "web",
|
|
45
|
+
name: "Chrome"
|
|
46
|
+
};
|
|
47
|
+
if (/Safari/i.test(ua)) return {
|
|
48
|
+
type: "web",
|
|
49
|
+
name: "Safari"
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
type: "unknown",
|
|
53
|
+
name: "unknown"
|
|
54
|
+
};
|
|
40
55
|
}
|
|
56
|
+
/** 获取浏览器指纹对象 */
|
|
41
57
|
async function getFingerprint() {
|
|
42
|
-
|
|
43
|
-
return agent.get();
|
|
58
|
+
return (await (await import("@fingerprintjs/fingerprintjs")).load()).get();
|
|
44
59
|
}
|
|
60
|
+
/** 获取设备指纹标识(统一入口) */
|
|
45
61
|
async function getDeviceFingerprint() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
const fingerprint = await getFingerprint();
|
|
58
|
-
const visitorId = fingerprint.visitorId;
|
|
59
|
-
if (isWeb) {
|
|
60
|
-
localStorage.setItem(FINGERPRINT_KEY, visitorId);
|
|
61
|
-
}
|
|
62
|
-
return `${name}/${visitorId}`;
|
|
62
|
+
if (!isBrowserEnv()) return "unknown/unknown";
|
|
63
|
+
const { type, name } = getClientPlatform();
|
|
64
|
+
const isWeb = type === "web";
|
|
65
|
+
if (isWeb) {
|
|
66
|
+
const cached = localStorage.getItem(FINGERPRINT_KEY);
|
|
67
|
+
if (cached) return `${name}/${cached}`;
|
|
68
|
+
}
|
|
69
|
+
const visitorId = (await getFingerprint()).visitorId;
|
|
70
|
+
if (isWeb) localStorage.setItem(FINGERPRINT_KEY, visitorId);
|
|
71
|
+
return `${name}/${visitorId}`;
|
|
63
72
|
}
|
|
73
|
+
/** mobile 端指纹(语义兼容) */
|
|
74
|
+
function getMobileBrowserFingerprint() {
|
|
75
|
+
return getDeviceFingerprint();
|
|
76
|
+
}
|
|
77
|
+
/** 页签唯一标识 */
|
|
64
78
|
function getPageIdentification() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
let pageTag = sessionStorage.getItem("currentPageTag");
|
|
80
|
+
if (!pageTag) {
|
|
81
|
+
pageTag = Date.now().toString();
|
|
82
|
+
sessionStorage.setItem("currentPageTag", pageTag);
|
|
83
|
+
}
|
|
84
|
+
return pageTag;
|
|
71
85
|
}
|
|
72
|
-
|
|
73
|
-
export {
|
|
86
|
+
//#endregion
|
|
87
|
+
export { getDeviceFingerprint, getMobileBrowserFingerprint, getPageIdentification };
|