main.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import store from './store'
  5. import httpServer from '@client/service/httpServer' // axios拦截器配置
  6. import '@/permission' // 权限控制
  7. import * as mUtils from '@/common/js/mUtils' //工具类
  8. import config from '@/config'
  9. import filters from './filters/index' //过滤器
  10. import AES from '@/common/js/secret'
  11. import * as API from '@/api/index'
  12. import Element from 'element-ui'
  13. import '@/common/styles/element-variables.scss'
  14. import '@/common/styles/index.scss' // 自定义 css
  15. import 'animate.css' //动画 css
  16. import VueClipboard from 'vue-clipboard2' //获取剪切板
  17. import hotKey from '@client/libs/keypress/keypress' //快捷键
  18. import Contextmenu from "vue-contextmenujs"
  19. // 视频组件,todo:后期改为局部注册
  20. import vueMiniPlayer from 'vue-mini-player'
  21. import 'vue-mini-player/lib/vue-mini-player.css'
  22. // import VCharts from 'v-charts'
  23. // Vue.use(VCharts)
  24. Vue.use(Element);
  25. Vue.use(VueClipboard)
  26. Vue.use(hotKey)
  27. Vue.use(Contextmenu);
  28. Vue.use(vueMiniPlayer);
  29. /**
  30. * 引入公共方法mUtils
  31. */
  32. Vue.prototype.$mUtils = mUtils;
  33. Vue.prototype.AES = AES
  34. Vue.prototype.$axios = httpServer;
  35. Vue.prototype.$api = API;
  36. Vue.prototype.$API = API;
  37. /**
  38. * 公共配置信息
  39. */
  40. Vue.prototype.$config = config
  41. // 注册全局过滤器
  42. Object.keys(filters).forEach(key => {
  43. Vue.filter(key, filters[key])
  44. })
  45. // 登录后跳转回之前停留页面
  46. Vue.prototype.goBeforeLoginUrl = () => {
  47. let url = mUtils.Cookie.get('beforeLoginUrl')
  48. url = decodeURIComponent(url)
  49. if (!url || url.indexOf('/author') != -1) {
  50. router.push('/login')
  51. } else {
  52. router.push(url)
  53. mUtils.Cookie.set('beforeLoginUrl', '', 1 / 24 / 60, window.location.host, window.location.pathname.substring(0, window.location.pathname.length - 1))
  54. }
  55. };
  56. // 查询多个,全局替换
  57. String.prototype.replaceAll = function(s1, s2) {
  58. return this.replace(new RegExp(s1, "gm"), s2);
  59. }
  60. Vue.config.productionTip = false
  61. store.commit('UPDATE_USER_FROM_LOCAL')
  62. new Vue({
  63. router,
  64. store,
  65. render: h => h(App)
  66. }).$mount('#app')