qiankun.js
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* @Author: your name
* @Date: 2022-02-10 19:00:41
* @LastEditTime: 2022-07-11 18:35:19
* @LastEditors: huyue
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \scrm-micro-pay\src\setup\qiankun.js
*/
import Vue from 'vue'
import { message } from '@/plugins/element.js'
import { fetchConfig } from '@/config'
import { GLButton, GLTable, GLCombiForm, GLFooter, GLTableButton, GLDialog } from 'glsx-components' //权限按钮 (根据权限动态创建)
import { getRoutes } from '@/router'
import ElementUI from 'element-ui'
import 'glsx-components/dist/glsx-components.css'
import '@/assets/css/public.scss'
import render from './render'
let routes = []
let router = null
let instance = null
Vue.use(ElementUI)
Vue.use(GLTable)
Vue.use(GLCombiForm)
Vue.use(GLFooter)
Vue.use(GLTableButton)
Vue.use(GLDialog)
export async function bootstrap({ history, common, messenger, globalState, routerBase }) {
const { response, request, sign, sign_common, secret, request_common } = await fetchConfig(true) //globalState.configSwitch
Vue.prototype.$history = history
Vue.prototype.$messenger = messenger
Vue.prototype.$globalState = globalState
Vue.prototype.$common = common
Vue.prototype.$http = new common.Http({ response, request, sign, secret, alert: message.error, headers: { token: globalState.session.token } })
Vue.prototype.$http_common = new common.Http({ response, signWay: 'md5', request: request_common, sign: sign_common, secret, alert: ElementUI.Message.error, headers: { TGT: globalState.session.token } })
// Vue.prototype.$setGlobalState = globalState.actions.setGlobalState
const routesData = common.utils.deepClone(globalState.routers)
routes = getRoutes(routesData)
subscribe({ messenger })
Vue.use(GLButton, { routes, routerBase })
}
export async function mount({ routerBase }) {
const insts = render(routerBase, routes)
router = insts.router
instance = insts.vm
}
export async function unmount() {
instance.$destroy()
instance.$el.innerHTML = ''
instance = null
router = null
}
function subscribe({ messenger }) {
messenger.subscribe(v => {
console.log(`监听到子应用${v.from}发来消息:`, v)
})
}