Skip to content

Commit

Permalink
feat: optimize display for mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lxchapu committed Aug 19, 2023
1 parent d5339e9 commit bd44b15
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { RouterView } from 'vue-router'
/**
* 判断设备是否为移动端
*/
function isMobile() {
const userAgentInfo = navigator.userAgent
const agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
let flag = false
for (let v = 0; v < agents.length; v++) {
if (userAgentInfo.indexOf(agents[v]) > 0) {
flag = true
break
}
}
return flag
}
onMounted(() => {
if (isMobile()) {
document.body.style.zoom = window.innerWidth / 1500 + ''
}
})
</script>

<template>
Expand Down

0 comments on commit bd44b15

Please sign in to comment.