🐛 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,
|
sms_expire_time: 0,
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
|
email_enabled: false,
|
||||||
email_enable_verify: false,
|
email_enable_verify: false,
|
||||||
email_enable_domain_suffix: false,
|
email_enable_domain_suffix: false,
|
||||||
email_domain_suffix_list: '',
|
email_domain_suffix_list: '',
|
||||||
|
|||||||
@ -123,7 +123,7 @@ export default function Content() {
|
|||||||
<Card key={item.id}>
|
<Card key={item.id}>
|
||||||
<CardHeader className='flex flex-row flex-wrap items-center justify-between gap-2 space-y-0'>
|
<CardHeader className='flex flex-row flex-wrap items-center justify-between gap-2 space-y-0'>
|
||||||
<CardTitle className='font-medium'>{item.subscribe.name}</CardTitle>
|
<CardTitle className='font-medium'>{item.subscribe.name}</CardTitle>
|
||||||
<div className='flex gap-2'>
|
<div className='flex flex-wrap gap-2'>
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
<Button size='sm' variant='destructive'>
|
<Button size='sm' variant='destructive'>
|
||||||
@ -214,7 +214,7 @@ export default function Content() {
|
|||||||
</div>
|
</div>
|
||||||
</AccordionTrigger>
|
</AccordionTrigger>
|
||||||
<AccordionContent>
|
<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) => (
|
{application?.[platform]?.map((app) => (
|
||||||
<div
|
<div
|
||||||
key={app.name}
|
key={app.name}
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
"react-turnstile": "^1.1.4",
|
"react-turnstile": "^1.1.4",
|
||||||
"rtl-detect": "^1.1.2",
|
"rtl-detect": "^1.1.2",
|
||||||
|
"ua-parser-js": "^2.0.0",
|
||||||
"universal-cookie": "^7.2.2",
|
"universal-cookie": "^7.2.2",
|
||||||
"zustand": "^5.0.3"
|
"zustand": "^5.0.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { locales, NEXT_PUBLIC_DEFAULT_LANGUAGE } from '@/config/constants';
|
import { locales, NEXT_PUBLIC_DEFAULT_LANGUAGE } from '@/config/constants';
|
||||||
import { isBrowser } from '@workspace/ui/utils';
|
import { isBrowser } from '@workspace/ui/utils';
|
||||||
|
import { UAParser } from 'ua-parser-js';
|
||||||
import Cookies from 'universal-cookie';
|
import Cookies from 'universal-cookie';
|
||||||
|
|
||||||
const cookies = new Cookies(null, {
|
const cookies = new Cookies(null, {
|
||||||
@ -51,26 +52,24 @@ export function Logout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPlatform(): 'windows' | 'mac' | 'linux' | 'android' | 'ios' {
|
export function getPlatform(): 'windows' | 'mac' | 'linux' | 'android' | 'ios' {
|
||||||
if (typeof navigator === 'undefined') {
|
const parser = new UAParser();
|
||||||
console.log('This function can only run in a browser environment.');
|
const os = parser.getOS();
|
||||||
return 'windows';
|
const osName = os.name?.toLowerCase() || '';
|
||||||
}
|
|
||||||
|
|
||||||
const userAgent = navigator.userAgent;
|
if (osName.includes('windows')) return 'windows';
|
||||||
|
if (osName.includes('mac')) return 'mac';
|
||||||
const platformPatterns: Record<string, RegExp> = {
|
if (
|
||||||
windows: /Windows NT/,
|
osName.includes('linux') ||
|
||||||
mac: /Mac OS X/,
|
osName.includes('ubuntu') ||
|
||||||
linux: /Linux/,
|
osName.includes('debian') ||
|
||||||
android: /Android/,
|
osName.includes('fedora') ||
|
||||||
ios: /iPhone OS|iPad; CPU OS/,
|
osName.includes('red hat') ||
|
||||||
};
|
osName.includes('centos') ||
|
||||||
|
osName.includes('arch')
|
||||||
for (const [platform, regex] of Object.entries(platformPatterns)) {
|
)
|
||||||
if (regex.test(userAgent)) {
|
return 'linux';
|
||||||
return platform as 'windows' | 'mac' | 'linux' | 'android' | 'ios';
|
if (osName.includes('android')) return 'android';
|
||||||
}
|
if (osName.includes('ios')) return 'ios';
|
||||||
}
|
|
||||||
|
|
||||||
return 'windows';
|
return 'windows';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user