Commit 03eca4ba authored by 程卓's avatar 程卓

优化子项目注册, 修复mounted只加载一次

parent 2f109bec
......@@ -39,7 +39,7 @@
<!-- 传统子项目在iframe中渲染 -->
<iframe v-if="webviewSrc" :src="webviewSrc" frameborder="0" style="width:100%;height:96%;overflow:hidden;" />
<!-- 本项目的子页面在此渲染 -->
<router-view v-else />
<router-view v-else :key="$route.path" />
</template>
<ChangePassword @on-close='closeChangePwdModal' :resetPwdShow='isShowChangePwd'></ChangePassword>
......
......@@ -14,7 +14,6 @@ const router = new Router({
router.beforeEach((to, from, next) => {
// TODO
// console.log(to.path)
store.commit('setWebviewSrc', to.meta && to.meta.src) // 判断有src的话为需要嵌入iframe的子项目
const token = Cookie.get('token')
......
import micSystemsList from '@/router/micSystemsList.json'
function GetSystemList() {
console.log(window.location.origin, '子项目的 entry 前缀')
/**
*
* 所有新增的子项目需要再此注册
*
* */
const url = window.location.origin
let system = [
{
'name': 'pudong',
'entry': url + '/elvweb',
'activeRule': '/pudong'
},
{
'name': 'danger',
'entry': url + '/dangerweb',
'activeRule': '/danger'
},
{
'name': 'order',
'entry': url + '/order',
'activeRule': '/order'
},
{
'name': 'documents',
'entry': url + '/documents',
'activeRule': '/documents'
let system = [] //子项目列表
let prodSystemList=micSystemsList.prod // 生产环境的子项目
let districtName //区局名称
let env = process.env.NODE_ENV //打包命令
let url = window.location.origin //当前访问的浏览器地址
// 1. 当打生产包的时候,
if ( env.indexOf('-prod')!= -1 ) {
// 2. 获取区局名称
districtName = env.split('-')[0]
// 3. 在生产环境的子项目list
prodSystemList.forEach((item, index) => {
if (item.districtName == districtName || item.districtName == 'common') {
prodSystemList[index].entry = url + item.entry
system.push(item)
}
})
return system
}else {
system = micSystemsList.sit
}
]
return system
}
......
{
"prod":[ {
"districtName": "pudong",
"name": "pudong",
"entry": "http://10.220.105.137:81/elvweb",
"activeRule": "/pudong"
},
{
"districtName": "pudong",
"name": "danger",
"entry": "http://10.220.105.137:81/dangerweb",
"activeRule": "/danger"
},
{
"districtName": "xuhui",
"name": "order",
"entry": "http://31.0.161.39/order",
"activeRule": "/order"
},
{
"districtName": "common",
"name": "documents",
"entry": "http://10.216.118.142/documents",
"activeRule": "/documents"
}
],
"sit":[
{
"districtName": "pudong",
"name": "pudong",
"entry": "http://pudong.hm.omniview.pro/elvweb",
"activeRule": "/pudong"
},
{
"districtName": "pudong",
"name": "danger",
"entry": "http://pudong.hm.omniview.pro/dangerweb",
"activeRule": "/danger"
},
{
"districtName": "xuhui",
"name": "order",
"entry": "http://xuhui.hm.omniview.pro/order",
"activeRule": "/order"
},
{
"districtName": "common",
"name": "documents",
"entry": "http://yangpu-hm.omniview.pro/documents",
"activeRule": "/documents"
}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment