import Vue from 'vue' import 'normalize.css/normalize.css' // A modern alternative to CSS resets import '../theme/index.css' // 引入自定义主题 import ElementUI from 'element-ui' // import 'element-ui/lib/theme-chalk/index.css' import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n import '@/styles/index.scss' // global css import App from './App' import store from './store' import router from './router' import '@/icons' // icon import '@/permission' // permission control /** * This project originally used easy-mock to simulate data, * but its official service is very unstable, * and you can build your own service if you need it. * So here I use Mock.js for local emulation, * it will intercept your request, so you won't see the request in the network. * If you remove `../mock` it will automatically request easy-mock data. */ // 兼容IE11 import 'babel-polyfill' // import '../mock' // simulation data import { hasPermission, showWellType, showDeviceType, showIpConfig, isOperation, isAdministrator } from './utils/permission' Vue.prototype.hasPerm = hasPermission Vue.prototype.showWellType = showWellType Vue.prototype.showDeviceType = showDeviceType Vue.prototype.showIpConfig = showIpConfig Vue.prototype.isOperation = isOperation Vue.prototype.isAdministrator = isAdministrator // 引入Element-ui Vue.use(ElementUI, { locale }) // 引入高德地图 import VueAMap from 'vue-amap' Vue.use(VueAMap) VueAMap.initAMapApiLoader({ key: 'b6c27a2051691fcb386543c800356e05', // key plugin: ['Autocomplete', 'PlaceSearch', 'Scale', 'OverView', 'ToolBar', 'MapType', 'PolyEditor', 'AMap.CircleEditor', 'MarkerClusterer'], // 插件 // uiVersion: '1.1', // ui组件库版本号 v: '1.4.4' // sdk版本 }) Vue.config.productionTip = false // 引入v-charts import VCharts from 'v-charts' Vue.use(VCharts) new Vue({ el: '#app', router, store, render: h => h(App) }) // 引入音频文件 import audio from '@/assets/audio/alarm.mp3' // 方法1:注册播放音频事件到Vue实例上 Vue.prototype.playAudio = (audioName) => { const buttonAudio = document.getElementById('eventAudio') buttonAudio.setAttribute('src', audio) console.log(buttonAudio) const playPromise = buttonAudio.play() if (playPromise) { playPromise.then(() => { // 音频加载成功 console.log('音频加载成功') }).catch((e) => { // 音频加载失败 console.error(e.message) }) } if (buttonAudio.paused === true) { buttonAudio.load() } else { buttonAudio.pause() buttonAudio.play() } }