提交 aea2a7a4 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 新增移动端判断

上级 e380d013
<script lang="ts" setup>
// import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
// const breakpoints = useBreakpoints(breakpointsTailwind)
// const isMobile = breakpoints.smaller('md')
const isMobile = false
<script setup lang="ts">
import { useDevice } from '@/composables/useDevice'
const { mobile } = useDevice()
</script>
<template>
<router-view :class="{ 'is-h5': isMobile, 'is-pc': !isMobile }" />
<router-view :class="{ 'is-h5': mobile, 'is-pc': !mobile }" />
</template>
export function useDevice() {
const navigator = window.navigator
const userAgent = ref(navigator.userAgent)
const mobile = computed(() => {
return /iphone/i.test(userAgent.value) || (/android/i.test(userAgent.value) && /mobile/i.test(userAgent.value))
})
const wechat = computed(() => {
return /micromessenger/i.test(userAgent.value)
})
const alipay = computed(() => {
return /alipayclient/i.test(userAgent.value)
})
addEventListener('resize', () => {
if (navigator) userAgent.value = navigator.userAgent
})
return { userAgent, mobile, wechat, alipay }
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论