Files
FastGPT/packages/web/common/system/utils.ts
Archer a83ae8e6e8 4.13.1 features (#5728)
* fix(api): 修复二级路由下的页面判断逻辑

在请求错误处理中,添加基础URL前缀以正确判断当前是否为外部链接页面。

* perf: use global var

* remove invalid code

* feat: response limit;perf: copy avatar image;perf: markdown parse (#5719)

* feat: response limit

* remove placeholder

* perf: copy avatar image

* perf: markdown parse

* fix: child app cannot show cite

* doc

* fix: node template bugs (#5727)

* add dataset search count track (#5721)

* add dataset search count track

* remove pro

* change to track

* remove unused

* fix

* perf: track code

---------

Co-authored-by: archer <545436317@qq.com>

* http response limit

* deploy doc

* fix: test

* doc

* remove invalid code

* remove invalid code

---------

Co-authored-by: 戴盛利 <1639499287@qq.com>
Co-authored-by: heheer <heheer@sealos.io>
2025-09-30 15:05:43 +08:00

47 lines
1.3 KiB
TypeScript

import FingerprintJS from '@fingerprintjs/fingerprintjs';
export const getUserFingerprint = async () => {
const fp = await FingerprintJS.load();
const result = await fp.get();
console.log(result.visitorId);
};
export const subRoute = process.env.NEXT_PUBLIC_BASE_URL;
export const getWebReqUrl = (url: string = '') => {
if (!url) return '/';
if (!subRoute) return url;
if (!url.startsWith('/') || url.startsWith(subRoute)) return url;
return `${subRoute}${url}`;
};
export const isMobile = () => {
// SSR return false
if (typeof window === 'undefined') return false;
// 1. Check User-Agent
const userAgent = navigator.userAgent.toLowerCase();
const mobileKeywords = [
'android',
'iphone',
'ipod',
'ipad',
'windows phone',
'blackberry',
'webos',
'iemobile',
'opera mini'
];
const isMobileUA = mobileKeywords.some((keyword) => userAgent.includes(keyword));
// 2. Check screen width
const isMobileWidth = window.innerWidth <= 900;
// 3. Check if touch events are supported (exclude touch screen PCs)
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
// If any of the following conditions are met, it is considered a mobile device
return isMobileUA || (isMobileWidth && isTouchDevice);
};