main.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // import 'babel-polyfill'
  2. import './public-path'
  3. import Vue from 'vue'
  4. import Cookies from 'js-cookie'
  5. import 'normalize.css/normalize.css' // a modern alternative to CSS resets
  6. import Element from 'element-ui'
  7. import './styles/element-variables.scss'
  8. import '@/styles/admin-lte/adminlte.min.css' // global css
  9. import 'font-awesome/css/font-awesome.min.css'
  10. import '@/styles/index.scss' // global css
  11. import App from './App'
  12. import store from './store'
  13. import router from './router'
  14. import './icons' // icon
  15. import './permission' // permission control
  16. import './utils/error-log' // error log
  17. import * as filters from './filters' // global filters
  18. import echarts from 'echarts'
  19. /**
  20. * If you don't want to use mock-server
  21. * you want to use MockJs for mock api
  22. * you can execute: mockXHR()
  23. *
  24. * Currently MockJs will be used in the production environment,
  25. * please remove it before going online ! ! !
  26. */
  27. // if (process.env.NODE_ENV === 'production') {
  28. // const { mockXHR } = require('../mock')
  29. // mockXHR()
  30. // }
  31. Vue.prototype.$echarts = echarts
  32. import VueKonva from 'vue-konva'
  33. Vue.use(VueKonva)
  34. Vue.use(Element, {
  35. size: Cookies.get('size') || 'medium' // set element-ui default size
  36. })
  37. import PermissionPlugin from './plugins/PermissionPlugin'
  38. Vue.use(PermissionPlugin)
  39. // register global utility filters
  40. Object.keys(filters).forEach(key => {
  41. Vue.filter(key, filters[key])
  42. })
  43. Vue.config.productionTip = false
  44. // new Vue({
  45. // el: '#app',
  46. // router,
  47. // store,
  48. // render: h => h(App)
  49. // })
  50. // let router = null;
  51. let instance = null
  52. function render(props = {}) {
  53. // const { container } = props
  54. // const router = new VueRouter({
  55. // // histroy模式的路由需要设置base,app-history-vue根据项目名称来定
  56. // base: window.__POWERED_BY_QIANKUN__ ? '/core' : '/',
  57. // mode: 'history',
  58. // // hash模式不需要上面两行
  59. // routes: []
  60. // })
  61. instance = new Vue({
  62. router,
  63. store,
  64. data() {
  65. return {
  66. parentRouter: props.router,
  67. parentVuex: props.store
  68. }
  69. },
  70. render: h => h(App)
  71. }).$mount('#gridererectionApp')
  72. }
  73. // 全局变量来判断环境,独立运行时
  74. if (!window.__POWERED_BY_QIANKUN__) {
  75. render()
  76. }
  77. export async function bootstrap() {
  78. console.log('emp-grider-erection模块启动')
  79. store.dispatch('app/enableLayout', false)
  80. }
  81. export async function mount(props) {
  82. console.log('props from main framework', props)
  83. render(props.data)
  84. }
  85. export async function unmount() {
  86. instance.$destroy()
  87. instance.$el.innerHTML = ''
  88. instance = null
  89. // router = null;
  90. }