fix: mobile bug

This commit is contained in:
张益铭
2021-03-30 11:55:31 +08:00
parent fd387fe5cd
commit 298ffd4b0f
7 changed files with 67 additions and 42 deletions

View File

@@ -21,6 +21,7 @@ import {
import { mapJson } from "../../api/map";
import greenCar from "/@/assets/green.png";
import { deviceDetection } from "../../utils/deviceDetection"
let MarkerCluster = null;
@@ -44,7 +45,7 @@ export default defineComponent({
let map: MapConfigureInter;
const mapSet: mapInter = reactive({
loading: true,
loading: deviceDetection() ? false : true,
});
// 地图创建完成(动画关闭)
@@ -134,6 +135,7 @@ export default defineComponent({
complete();
})
.catch((err) => {
mapSet.loading = false;
throw "地图加载失败,请重新加载";
});
});

View File

@@ -37,6 +37,9 @@ import axios from 'axios'
const app = createApp(App)
app.config.globalProperties.$config = getConfig()
// import vConsole from 'vconsole'
// app.config.globalProperties.$vConsole = new vConsole()
// 获取项目动态全局配置
export const getServerConfig = async (): Promise<any> => {
return axios({

View File

@@ -0,0 +1,25 @@
interface deviceInter {
match: any
}
// 检测设备类型(手机返回true,反之)
export const deviceDetection = () => {
let sUserAgent: deviceInter = navigator.userAgent.toLowerCase()
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad"
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"
let bIsMidp = sUserAgent.match(/midp/i) == "midp"
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"
let bIsAndroid = sUserAgent.match(/android/i) == "android"
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"
return bIsIphoneOs ||
bIsMidp ||
bIsUc7 ||
bIsUc ||
bIsAndroid ||
bIsCE ||
bIsWM
? true
: false
};

View File

@@ -6,36 +6,11 @@
import { onMounted } from "vue";
import Player from "xgplayer/dist/simple_player";
import { volume, playbackRate, screenShot } from "xgplayer/dist/controls";
import { deviceDetection } from "../../../utils/deviceDetection"
export interface deviceInter {
match: any;
}
export default {
setup() {
// 检测设备类型(手机返回true,反之)
const deviceDetection = () => {
let sUserAgent: deviceInter = navigator.userAgent.toLowerCase();
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
let bIsAndroid = sUserAgent.match(/android/i) == "android";
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
return bIsIphoneOs ||
bIsMidp ||
bIsUc7 ||
bIsUc ||
bIsAndroid ||
bIsCE ||
bIsWM
? true
: false;
};
onMounted(() => {
console.log("---", deviceDetection());
let player = new Player({
id: "mse",
autoplay: false,