import Vue from 'vue' import App from './App.vue' import router from './router' import store from './store' import UAParser from "@/libs/ua-parser.min.js" import "@/assets/style/reset.css" import "@/assets/style/my-reset.css" import clickOutside from "@/directives/v-click-outside.js" import 'viewerjs/dist/viewer.css' import Viewer from 'v-viewer' import VueLazyload from 'vue-lazyload' import { MessageCenter } from "@/utils.js" import infiniteScroll from 'vue-infinite-scroll' console.log(`version: ${process.env.VUE_APP_VERSION}`) // 供全局使用的audio节点 const audioNode = document.createElement("audio") audioNode.id = 'global-audio' audioNode.style.display = 'none' audioNode.loop = true document.body.appendChild(audioNode) const uaParser = new UAParser() const uaInfo = uaParser.getResult() console.log('user agent: ', uaInfo) Vue.prototype.$uaInfo = uaInfo if (uaInfo.device.type === 'mobile') { Vue.prototype.$isMobile = true } else { Vue.prototype.$isMobile = false } if (uaInfo.browser && uaInfo.browser.name === 'WeChat') { Vue.prototype.$isWeChat = true } if (uaInfo.browser && uaInfo.browser.name === 'Safari') { Vue.prototype.$isSafari = true } // 酌情跳转到PC版 // if (uaInfo.device.type !== 'mobile' && window.innerWidth > window.innerHeight) { // location.replace(process.env.VUE_APP_PC_URL) // } Vue.prototype.$origin = process.env.VUE_APP_ORIGIN Vue.prototype.$globalConfig = globalConfig Vue.prototype.$cdnPath = process.env.VUE_APP_CDN_PATH Vue.prototype.$msgCenter = new MessageCenter() // let windowWidthLast = window.innerWidth // let windowHeightLast = window.innerHeight // function onResize() { // if (window.innerWidth === windowWidthLast) { // // 发生了高度变化,认为发生了软键盘显隐 // if (uaInfo.os.name === 'Android') { // if (window.innerHeight < windowHeightLast) { // Vue.prototype.$msgCenter.publish('need-hide-bottom-bar') // } else if (window.innerHeight > windowHeightLast) { // Vue.prototype.$msgCenter.publish('need-show-bottom-bar') // } // } // } // windowWidthLast = window.innerWidth // windowHeightLast = window.innerHeight // } // onResize() // window.addEventListener('resize', () => { // onResize() // }) // 禁用上下文菜单 document.oncontextmenu = function(e) { e.preventDefault() } Vue.config.productionTip = false Vue.use(clickOutside) Vue.use(Viewer) Vue.use(VueLazyload) Vue.use(infiniteScroll) new Vue({ router, store, render: h => h(App) }).$mount('#app') // 必须在vue根组件挂载之后执行 if (Vue.prototype.$isMobile) { document.getElementById('app').classList.add('mobile') }