Add favicon SVG with gradient background and letter "R"
This commit is contained in:
32
packages/distribute/composables/usePlatformDetection.ts
Normal file
32
packages/distribute/composables/usePlatformDetection.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { Platform } from '~/types'
|
||||
|
||||
export function usePlatformDetection() {
|
||||
const platform = useState<Platform>('platform', () => 'unknown')
|
||||
|
||||
function detectPlatform(): Platform {
|
||||
if (import.meta.server)
|
||||
return 'unknown'
|
||||
|
||||
const ua = navigator.userAgent.toLowerCase()
|
||||
|
||||
if (/iphone|ipad|ipod/.test(ua))
|
||||
return 'ios'
|
||||
else if (/android/.test(ua))
|
||||
return 'android'
|
||||
else if (/windows|macintosh|linux/.test(ua))
|
||||
return 'desktop'
|
||||
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
platform.value = detectPlatform()
|
||||
})
|
||||
|
||||
return {
|
||||
platform: readonly(platform),
|
||||
isIOS: computed(() => platform.value === 'ios'),
|
||||
isAndroid: computed(() => platform.value === 'android'),
|
||||
isDesktop: computed(() => platform.value === 'desktop'),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user