🐛 fix(dashboard): Update platform detection logic and improve layout responsiveness
This commit is contained in:
parent
30ae781f05
commit
b0aa3645f8
@ -29,6 +29,7 @@ export const useGlobalStore = create<GlobalStore>((set) => ({
|
||||
sms_expire_time: 0,
|
||||
},
|
||||
email: {
|
||||
email_enabled: false,
|
||||
email_enable_verify: false,
|
||||
email_enable_domain_suffix: false,
|
||||
email_domain_suffix_list: '',
|
||||
|
||||
@ -123,7 +123,7 @@ export default function Content() {
|
||||
<Card key={item.id}>
|
||||
<CardHeader className='flex flex-row flex-wrap items-center justify-between gap-2 space-y-0'>
|
||||
<CardTitle className='font-medium'>{item.subscribe.name}</CardTitle>
|
||||
<div className='flex gap-2'>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button size='sm' variant='destructive'>
|
||||
@ -214,7 +214,7 @@ export default function Content() {
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
<div className='grid grid-cols-3 gap-4 lg:grid-cols-4 xl:grid-cols-6'>
|
||||
<div className='grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6'>
|
||||
{application?.[platform]?.map((app) => (
|
||||
<div
|
||||
key={app.name}
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
"react-dom": "^19.0.0",
|
||||
"react-turnstile": "^1.1.4",
|
||||
"rtl-detect": "^1.1.2",
|
||||
"ua-parser-js": "^2.0.0",
|
||||
"universal-cookie": "^7.2.2",
|
||||
"zustand": "^5.0.3"
|
||||
},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { locales, NEXT_PUBLIC_DEFAULT_LANGUAGE } from '@/config/constants';
|
||||
import { isBrowser } from '@workspace/ui/utils';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
import Cookies from 'universal-cookie';
|
||||
|
||||
const cookies = new Cookies(null, {
|
||||
@ -51,26 +52,24 @@ export function Logout() {
|
||||
}
|
||||
|
||||
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 parser = new UAParser();
|
||||
const os = parser.getOS();
|
||||
const osName = os.name?.toLowerCase() || '';
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
||||
if (osName.includes('windows')) return 'windows';
|
||||
if (osName.includes('mac')) return 'mac';
|
||||
if (
|
||||
osName.includes('linux') ||
|
||||
osName.includes('ubuntu') ||
|
||||
osName.includes('debian') ||
|
||||
osName.includes('fedora') ||
|
||||
osName.includes('red hat') ||
|
||||
osName.includes('centos') ||
|
||||
osName.includes('arch')
|
||||
)
|
||||
return 'linux';
|
||||
if (osName.includes('android')) return 'android';
|
||||
if (osName.includes('ios')) return 'ios';
|
||||
|
||||
return 'windows';
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user