qiankun.js
3.74 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-09-14 15:04:56
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-16 10:35:09
* @FilePath: \scrm-micro-tools\src\setup\qiankun.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import Vue from 'vue'
import { message, messageBox } from '@/plugins/element.js'
import { fetchConfig } from '@/config'
import { GLButton, GLTable, GLFooter, GLCombiForm, GLTableButton, GLDialog } from 'glsx-components' //权限按钮 (根据权限动态创建)
import { GLEditor } from 'word-edit'
import { getRoutes } from '@/router'
import ElementUI from 'element-ui'
import render from './render'
import 'glsx-components/dist/glsx-components.css'
import 'word-edit/dist/glsx-components.css'
// http://scrm.dev.glsx.com.cn
let routes = []
let router = null
let instance = null
Vue.use(ElementUI)
Vue.use(GLTable)
Vue.use(GLFooter)
Vue.use(GLCombiForm)
Vue.use(GLTableButton)
Vue.use(GLEditor)
Vue.use(GLDialog)
export async function bootstrap({ history, common, messenger, globalState, routerBase }) {
const { response, request, request2, sign, secret, sign_common, request_common, request_merchant, merchantId, request_gpt } = await fetchConfig(common)
Vue.prototype.$history = history
Vue.prototype.$messenger = messenger
Vue.prototype.$globalState = globalState
Vue.prototype.$common = common
Vue.prototype.$message = message
Vue.prototype.$messageBox = messageBox
Vue.prototype.$hmdMerchantId = merchantId
Vue.prototype.$tracker = common.tracker || { tracker: () => {} }
// 集团版集团账号
Vue.prototype.$isGroupUp = globalState.session.accountLevel != 4
Vue.prototype.$http = new common.Http({ response, request, sign, secret, alert: message.error, headers: { token: globalState.session.token } })
Vue.prototype.$http_gpt = new common.Http({ response, request: request_gpt, sign, secret, alert: ElementUI.Message.error })
Vue.prototype.$http_upload = new common.Http({
response: { ...response, data_key: 'result', code_success_value: true, code_key: 'success' },
request,
sign,
secret,
alert: message.error,
headers: { token: globalState.session.token, 'Content-Type': 'multipart/form-data' }
})
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.$http_tag = new common.Http({ response, request, sign, secret, alert: ElementUI.Message.error, headers: { token: globalState.session.token } })
Vue.prototype.$http_merchant = new common.Http({ response, request: request_merchant, sign, secret, alert: ElementUI.Message.error, headers: { token: globalState.session.token } })
// Vue.prototype.$setGlobalState = globalState.actions.setGlobalState
// Vue.use(GLButton, { permissions: globalState.permissions || ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
Vue.prototype.$http2 = new common.Http({
response,
request: request2,
sign,
secret,
alert: message.error,
headers: { token: globalState.session.token }
})
const routesData = common.utils.deepClone(globalState.routers)
routes = getRoutes(routesData)
subscribe({ messenger })
Vue.use(GLButton, { routes, routerBase })
}
export async function mount(props) {
const insts = render(props.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)
})
}