main.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import router from "./router";
  2. import 'normalize.css/normalize.css' // a modern alternative to CSS resets
  3. import 'element-ui/lib/theme-chalk/display.css';
  4. import Viewer from 'v-viewer';
  5. import {
  6. getToken, removeMenu,
  7. removeBtn, removeToken
  8. } from '@/utils/auth'
  9. import ElementUI from 'element-ui'
  10. import 'viewerjs/dist/viewer.css'
  11. import "element-ui/lib/theme-chalk/display.css";
  12. import "./styles/element-variables.scss";
  13. import './styles/index.scss' // global css
  14. import globalComponents from './components/globalComponents'
  15. import App from './App'
  16. import store from './store'
  17. import base from './assets/utils/prototype/index'
  18. import dataV from '@jiaminghi/data-view';
  19. // 按需引入vue-awesome图标
  20. import Icon from 'vue-awesome/components/Icon';
  21. import 'vue-awesome/icons/chart-bar.js';
  22. import 'vue-awesome/icons/chart-area.js';
  23. import 'vue-awesome/icons/chart-pie.js';
  24. import 'vue-awesome/icons/chart-line.js';
  25. import 'vue-awesome/icons/align-left.js';
  26. import echarts from 'echarts'
  27. import * as filters from './filters' // global filters
  28. Vue.component('icon', Icon);
  29. Vue.use(dataV);
  30. Vue.prototype.$echarts = echarts
  31. Array.prototype.remove = function (val) {
  32. var index = this.indexOf(val);
  33. if (index > -1) {
  34. this.splice(index, 1);
  35. }
  36. };
  37. // 兼容
  38. if (typeof String.prototype.startsWith != "function") {
  39. String.prototype.startsWith = function (prefix) {
  40. return this.slice(0, prefix.length) === prefix;
  41. };
  42. }
  43. Vue.use(globalComponents)
  44. Vue.use(Viewer, {
  45. defaultOptions: {
  46. zIndex: 9999
  47. }
  48. })
  49. Vue.use(base)
  50. import PuzzleVerification from 'vue-puzzle-verification'
  51. Vue.use(PuzzleVerification)
  52. // register global utility filters
  53. Object.keys(filters).forEach(key => {
  54. Vue.filter(key, filters[key])
  55. })
  56. Vue.config.productionTip = false
  57. Vue.use(ElementUI)
  58. window.vm = new Vue({
  59. router,
  60. store,
  61. render: h => h(App)
  62. }).$mount("#app");
  63. if (getToken() === null || getToken() === undefined || getToken() === '') {
  64. removeMenu()
  65. removeBtn()
  66. removeToken()
  67. router.replace({ name: 'login' });
  68. }