Commit e054cc48 authored by 毛线's avatar 毛线

移动端兼容

parent 03df51db
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<script> <script>
import { mapActions, mapMutations } from 'vuex' import { mapActions, mapMutations } from 'vuex'
import { deviceType } from '@/utils/device-type'
import Audio from '@/components/common/audio/index' import Audio from '@/components/common/audio/index'
export default { export default {
components: { components: {
...@@ -59,14 +60,16 @@ export default { ...@@ -59,14 +60,16 @@ export default {
]), ]),
initSceen() { initSceen() {
const { innerWidth, } = window const { innerWidth, } = window
const isMobile = deviceType(navigator.userAgent)
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// return // return
} }
if (innerWidth > 750) { if (innerWidth < 750 || isMobile) {
this.initMobileSceen()
this.isMoblie = true
} else {
this.initPcSceen() this.initPcSceen()
this.isMoblie = false this.isMoblie = false
} else {
this.initMobileSceen()
} }
}, },
// 初始化pc屏幕 // 初始化pc屏幕
......
/**
*
* @param {*} UA ,就是userAgent
* @returns type: 设备类型
* env: 访问环境(微信/微博/qq)
*/
function isMoible(UA) {
return !!/(Android|webOS|iPhone|iPod|tablet|BlackBerry|Mobile)/i.test(UA)
}
export function deviceType(UA) {
if (isMoible(UA)) {
return true
} else {
return false
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment