import Vue from 'vue'
|
import App from './App.vue'
|
import router from './router'
|
import store from './store'
|
import './plugin/element'
|
import './assets/styles/theme/index.css'
|
import '@/assets/styles/common.css'
|
import './assets/styles/public.scss'
|
import uploadImg from './components/uploadFile/uploadImg.vue'
|
import commonForm from './components/formTemplate/commonForm.vue'
|
import customUploadImg from '@/components/uploadFile/customUploadImg.vue'
|
import listConditionTemplate from '@/components/listTemplate/listConditionTemplate.vue'
|
import Loading from './directives/Loading'
|
import action from '@/utils/qkAction.js'
|
import wlyBtn from '@/components/wlyBtn/index.vue'
|
|
Vue.config.devtools = true
|
Vue.config.productionTip = false
|
Vue.component('wlyBtn', wlyBtn)
|
Vue.component('common-form', commonForm)
|
Vue.component('list-condition-template', listConditionTemplate)
|
Vue.component('upload-img', uploadImg)
|
Vue.component('custom-upload-img', customUploadImg)
|
Vue.use(Loading)
|
let instance = null
|
const render = (baseRouter = '') => {
|
instance = new Vue({
|
router: router(baseRouter),
|
store,
|
render: h => h(App)
|
}).$mount('#app')
|
}
|
|
/**
|
* 子应用静态资源一定要支持跨域
|
* qiankun 将会在子应用 bootstrap 之前注入一个运行时的 publicPath 变量
|
* runtime publicPath 主要解决的是子应用动态载入的 脚本、样式、图片 等地址不正确的问题。
|
*/
|
|
/* eslint-disable */
|
if (window.__POWERED_BY_QIANKUN__) {
|
__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__
|
/* eslint-enable */
|
} else {
|
render()
|
}
|
|
/**
|
* bootstrap 只会在子应用初始化的时候调用一次,下次子应用重新进入时会直接调用 mount 钩子,不会再重复触发 bootstrap。
|
* 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
|
*/
|
export async function bootstrap (props) {
|
// console.log('-- child-vue bootstrap --', props.baseApi)
|
window.API_BASE_URL = props.baseApi
|
}
|
|
/**
|
* 应用每次进入都会调用 mount 方法,通常我们在这里触发应用的渲染方法
|
*/
|
export async function mount (props) {
|
store.replaceState(Object.assign(store.state, props.store.state))
|
Vue.prototype.$mainStore = props.store
|
Vue.prototype.$mainRouter = props.mainRouter
|
Vue.prototype.$baseRouter = props.baseRouter
|
action.setActions(props)
|
render(props.baseRouter)
|
}
|
|
/**
|
* 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载子应用的应用实例
|
*/
|
export async function unmount () {
|
instance.$destroy()
|
instance = null
|
}
|
|
/**
|
* 可选生命周期钩子,仅使用 loadMicroApp(手动加载) 方式加载子应用时生效
|
*/
|
export async function update (props) {
|
// console.log('update props', props)
|
}
|