🐛 fix(config): SubLink

This commit is contained in:
web@ppanel
2024-12-09 14:08:38 +07:00
parent 2cc18cf559
commit 1c619669a6
3 changed files with 50 additions and 24 deletions
+25
View File
@@ -49,3 +49,28 @@ export function Logout() {
location.href = `/`;
}
}
export function getPlatform(): 'windows' | 'mac' | 'linux' | 'android' | 'ios' {
if (typeof navigator === 'undefined') {
console.log('This function can only run in a browser environment.');
return 'windows';
}
const userAgent = navigator.userAgent;
const platformPatterns: Record<string, RegExp> = {
windows: /Windows NT/,
mac: /Mac OS X/,
linux: /Linux/,
android: /Android/,
ios: /iPhone OS|iPad; CPU OS/,
};
for (const [platform, regex] of Object.entries(platformPatterns)) {
if (regex.test(userAgent)) {
return platform as 'windows' | 'mac' | 'linux' | 'android' | 'ios';
}
}
return 'windows';
}