quanyawei
2024-11-15 f752f50a484f63fc3786ab1c7ad563f3b17cce77
src/main.js
@@ -20,31 +20,15 @@
import '@/permission' // permission control
// clipboard是一款实现复制文本到剪贴板功能的JS插件
import clipboard from 'clipboard'
// 注册到vue原型上
Vue.prototype.$clipboard = clipboard
// 高德地图
import AMap from 'vue-amap'
Vue.use(AMap)
AMap.initAMapApiLoader({
  key: 'be57d4add7dc10fb7f7924763a2179ae',
  plugin: ['AMap.moveAnimation', 'AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale',
    'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor',
    'AMap.DistrictSearch'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
})
Vue.prototype.$AMap = AMap
// crypto加密
import { Encrypt } from '@/utils/AES.js'
import { getToken } from '@/utils/auth'
import request from '@/utils/request'
Vue.prototype.$request = request.service
Vue.prototype.$axiosRequest = request.reqServe
// Vue.prototype.$postRequest=request.reqServe1
/**
 * If you don't want to use mock-server
@@ -55,11 +39,41 @@
 * please remove it before going online! ! !
 */
import { mockXHR } from '../mock'
import echarts from 'echarts'
import JsonExcel from 'vue-json-excel'
// 注册到vue原型上
Vue.prototype.$clipboard = clipboard
Vue.use(AMap)
AMap.initAMapApiLoader({
  key: 'f4ba1c4d94654309b97a557d41857b48',
  plugin: [
    'AMap.moveAnimation',
    'AMap.Autocomplete',
    'AMap.PlaceSearch',
    'AMap.Scale',
    'AMap.OverView',
    'AMap.ToolBar',
    'AMap.MapType',
    'AMap.PolyEditor',
    'AMap.CircleEditor',
    'AMap.DistrictSearch',
    'AMap.Geolocation'
  ],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
})
window._AMapSecurityConfig = {
  securityJsCode: 'ef9c2027d42f060b979814c849eea7b9'
}
Vue.prototype.$AMap = AMap
Vue.prototype.$request = request.service
Vue.prototype.$axiosRequest = request.reqServe
if (process.env.NODE_ENV === 'production') {
  mockXHR()
}
import echarts from 'echarts'
Vue.prototype.$Cookies = Cookies
@@ -72,25 +86,26 @@
Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.prototype.$Bus = Bus
import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel)
Vue.component('DownloadExcel', JsonExcel)
function getServerConfig() {
  return new Promise((resolve, reject) => {
    axios.get('/serverConfig.json').then((result) => {
      //   console.log(result) // 看打印出来的结果
      const config = result.data
      for (const key in config) {
        Vue.prototype[key] = config[key]
      }
      // 验证是否已经把属性挂在了Vue上
      // console.log(Vue.prototype.BASE_ADDR)
      resolve()
    }).catch((error) => {
      console.log(error)
      reject()
    })
    axios
      .get('/serverConfig.json')
      .then(result => {
        //   console.log(result) // 看打印出来的结果
        const config = result.data
        for (const key in config) {
          Vue.prototype[key] = config[key]
        }
        // 验证是否已经把属性挂在了Vue上
        // console.log(Vue.prototype.BASE_ADDR)
        resolve()
      })
      .catch(error => {
        console.log(error)
        reject()
      })
  })
}
@@ -118,11 +133,13 @@
  for (const k in opt) {
    ret = new RegExp('(' + k + ')').exec(fmt)
    if (ret) {
      fmt = fmt.replace(ret[1], (ret[1].length === 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, '0')))
      fmt = fmt.replace(
        ret[1],
        ret[1].length === 1 ? opt[k] : opt[k].padStart(ret[1].length, '0')
      )
    }
  }
  return fmt
}
init()