123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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(uaInfo)
- Vue.prototype.$uaInfo = uaInfo
- if (uaInfo.browser && uaInfo.browser.name === 'WeChat') {
- Vue.prototype.$isWeChat = true
- }
- if (uaInfo.browser && uaInfo.browser.name === 'Safari') {
- Vue.prototype.$isSafari = true
- }
- if (uaInfo.device.type !== 'mobile' && window.innerWidth > window.innerHeight) {
- if (['#/lookGoods', '#/relics-appr-no-exit', '#/relic-detail'].includes(location.hash)) {
- location.replace(process.env.VUE_APP_PC_URL_ONLY_RELICS)
- } else if (location.hash.includes('#/info/')) {
- location.replace(location.href.replace('/YHTM/', '/YHT/'))
- } else {
- location.replace(process.env.VUE_APP_PC_URL)
- }
- }
- Vue.prototype.$globalConfig = globalConfig
- Vue.prototype.$cdnPath = process.env.VUE_APP_CDN_PATH
- Vue.prototype.$swkkHotspotVideoAudioPath = process.env.VUE_APP_SWKK_HOTSPOT_VIDEO_AUDIO_PATH
- Vue.prototype.$msgCenter = new MessageCenter()
- const idealWindowInnerWidth = 1125 // 设计稿的宽度
- const idealRootFontSize = 24 // 设计稿里选择的根元素尺寸
- let windowWidthLast = window.innerWidth
- let windowHeightLast = window.innerHeight
- function onResize() {
- Vue.prototype.$oneRemToPx = window.innerWidth * idealRootFontSize / idealWindowInnerWidth
- document.documentElement.style.fontSize = Vue.prototype.$oneRemToPx + 'px'
- 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')
|