main.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 noAuth from './components/NoAuth/index.vue'
  10. import ElementUI from 'element-ui'
  11. import 'viewerjs/dist/viewer.css'
  12. import "element-ui/lib/theme-chalk/display.css";
  13. import "./styles/element-variables.scss";
  14. import './styles/index.scss' // global css
  15. import globalComponents from './components/global'
  16. import App from './App'
  17. import store from './store'
  18. import base from './assets/utils/prototype/index'
  19. // import './icons' // icon
  20. // import './utils/error-log' // error log
  21. import * as filters from './filters' // global filters
  22. Array.prototype.remove = function (val) {
  23. var index = this.indexOf(val);
  24. if (index > -1) {
  25. this.splice(index, 1);
  26. }
  27. };
  28. // 兼容
  29. if (typeof String.prototype.startsWith != "function") {
  30. String.prototype.startsWith = function (prefix) {
  31. return this.slice(0, prefix.length) === prefix;
  32. };
  33. }
  34. // 暂无权限
  35. Vue.component('noAuth', noAuth)
  36. Vue.use(globalComponents)
  37. Vue.use(Viewer, {
  38. defaultOptions: {
  39. zIndex: 9999
  40. }
  41. })
  42. Vue.use(base)
  43. import PuzzleVerification from 'vue-puzzle-verification'
  44. Vue.use(PuzzleVerification)
  45. // register global utility filters
  46. Object.keys(filters).forEach(key => {
  47. Vue.filter(key, filters[key])
  48. })
  49. Vue.config.productionTip = false
  50. Vue.use(ElementUI)
  51. window.vm = new Vue({
  52. router,
  53. store,
  54. render: h => h(App)
  55. }).$mount("#app");
  56. if (getToken() === null || getToken() === undefined || getToken() === '') {
  57. removeMenu()
  58. removeBtn()
  59. removeToken()
  60. router.replace({ name: 'login' });
  61. }