Commit 2f45ac50 authored by 程卓's avatar 程卓

优化子项目注册,优化接口根据地址栏动态获取,优化左侧菜单组装逻辑

parent 9fe5f7b3
......@@ -76,7 +76,7 @@ import MutSelect from '@/views/components/mutSelect' // 多选框(控制表格
import tableAndMut from '@/views/components/tableAndMut' // 多选框(控制表格展示列)
import BatchOperation from '@/views/components/BatchOperation' // 多选框(控制表格展示列)
import micSystemsList from '@/router/micSystemsList.json'
import micSystemsList from '@/router/micSystemsList.js'
// 由于日期组件默认是英文的,需要本地化
import moment from 'moment'
......@@ -192,16 +192,9 @@ const render = ({appContent, loading} = {}) => { // 渲染方法
}
// 动态加载子项目的url
let system //= micSystemsList
let env = process.env.NODE_ENV
console.log(process.env.NODE_ENV, 'NODE_ENV')
if(env.indexOf('prod') != -1 ){
system = micSystemsList.prod
}else{
system = micSystemsList.sit
}
let system
system = micSystemsList
console.log(system, '注册的子项目列表')
let projects = []
for (let i = 0; i < system.length; i++) {
......
......@@ -20,7 +20,7 @@ import Store from '@/store/index'
*/
console.log(routeByFilter)
async function GetRoutes(router) {
function GetRoutes(router) {
let env = process.env.NODE_ENV
// console.log(env)
let MicRouters
......@@ -57,7 +57,7 @@ async function GetRoutes(router) {
yangpu.Layout = yangpu.Layout.concat('yangpu' in routeByFilter ? routeByFilter.yangpu : documents.Layout )
MicRouters = yangpu
break
case 'development': // 本地开发展示对应的子项目路由
case 'development': // 本地开发展示对应的子项目路由 -- 本地调试子项目展示的对应菜单在此切换
xuhui.Layout = xuhui.Layout.concat('xuhui' in routeByFilter ? routeByFilter.xuhui : documents.Layout )
MicRouters = xuhui
break
......@@ -66,22 +66,22 @@ async function GetRoutes(router) {
break
}
await function() {
ajax.get({
url: api.GET_USER_INFO,
}).then(res => {
// 本地存储用户基本信息
if (env.indexOf('xuhui') != -1 && res.data.content.isAllPerm) {
let newArr= []
MicRouters.Layout.forEach((item) => {
if (item.name != 'tousu' && item.name != 'Disposal' ) {
newArr.push(item)
}
})
MicRouters.Layout = newArr
}
})
}()
// await function() {
// ajax.get({
// url: api.GET_USER_INFO,
// }).then(res => {
// // 本地存储用户基本信息
// if (env.indexOf('xuhui') != -1 && res.data.content.isAllPerm) {
// let newArr= []
// MicRouters.Layout.forEach((item) => {
// if (item.name != 'tousu' && item.name != 'Disposal' ) {
// newArr.push(item)
// }
// })
// MicRouters.Layout = newArr
// }
// })
// }()
const micSystemRoutersConfigs = Object.assign({}, MicRouters)
const { routes } = router.options
......
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'
}
]
return system
}
export default GetSystemList()
{
"prod":[ {
"name": "pudong",
"entry": "http://10.220.105.137:81/elvweb",
"activeRule": "/pudong"
},
{
"name": "danger",
"entry": "http://10.220.105.137:81/dangerweb",
"activeRule": "/danger"
},
{
"name": "czd",
"entry": "http://10.220.105.137:81/czd",
"activeRule": "/czd"
},
{
"name": "checkorder",
"entry": "http://10.220.105.137:81/checkorder",
"activeRule": "/checkorder"
},
{
"name": "order",
"entry": "http://31.0.161.39/order",
"activeRule": "/order"
},
{
"name": "question",
"entry": "http://31.0.161.39/question",
"activeRule": "/question"
},
{
"name": "hp_order",
"entry": "http://172.82.26.1/order",
"activeRule": "/hp_order"
},
{
"name": "hp_question",
"entry": "http://172.82.26.1/question",
"activeRule": "/hp_question"
},
{
"name": "documentOne",
"entry": "http://10.216.118.142/documentOne",
"activeRule": "/documentOne"
},
{
"name": "documentTwo",
"entry": "http://10.216.118.142/documentTwo",
"activeRule": "/documentTwo"
},
{
"name": "documents",
"entry": "http://31.0.161.39/documents",
"activeRule": "/documents"
}
],
"sit":[
{
"name": "pudong",
"entry": "http://pudong.hm.omniview.pro/elvweb",
"activeRule": "/pudong"
},
{
"name": "danger",
"entry": "http://pudong.hm.omniview.pro/dangerweb",
"activeRule": "/danger"
},
{
"name": "czd",
"entry": "http://pudong.hm.omniview.pro/czd",
"activeRule": "/czd"
},
{
"name": "checkorder",
"entry": "http://pudong.hm.omniview.pro/checkorder",
"activeRule": "/checkorder"
},
{
"name": "order",
"entry": "http://xuhui.hm.omniview.pro/order",
"activeRule": "/order"
},
{
"name": "question",
"entry": "http://xuhui.hm.omniview.pro/question",
"activeRule": "/question"
},
{
"name": "hp_order",
"entry": "http://huangpu.hm.omniview.pro/order",
"activeRule": "/hp_order"
},
{
"name": "hp_question",
"entry": "http://huangpu.hm.omniview.pro/question",
"activeRule": "/hp_question"
},
{
"name": "documentOne",
"entry": "http://yangpu-hm.omniview.pro/documentOne",
"activeRule": "/documentOne"
},
{
"name": "documentTwo",
"entry": "http://yangpu-hm.omniview.pro/documentTwo",
"activeRule": "/documentTwo"
},
{
"name": "documents",
"entry": "http://huangpu.hm.omniview.pro/documents",
"activeRule": "/documents"
}
]
}
\ No newline at end of file
let BASE_URL = '', MOCK_URL='',
FANGDI_URL = 'http://962121.fgj.sh.gov.cn/wyweb/shanghaiwuye'
/**
*
* 此处配置当前项目在不同环境下的API请求前缀, 根据当前浏览器访问的地址来变更对应的接口地址
* 如果有新增的区局项目 需要将对应的接口地址前缀放入此数组中
*/
const apiList = [
'http://pudong.hm.omniview.pro/api/v2', // 浦东sit
'http://10.220.105.137:81/api', // 浦东prod
'http://xuhui.hm.omniview.pro/api/v2', // 徐汇sit
'http://31.0.161.39/apiv2', // 徐汇prod
'http://yangpu-hm.omniview.pro/api/v2', // 杨浦sit
'http://10.216.118.142/api', // 杨浦prod
'http://huangpu.hm.omniview.pro/api/v2', // 黄浦sit
'http://172.82.26.1/api', // 黄浦prod
]
MOCK_URL = 'https://yapi.omniview.pro/mock/283' // yapi上的mock地址
// 1.根据当前地址栏访问的地址来决定接口访问的前缀 (生产或测试环境)
if (apiList.find(item => item.indexOf(window.location.origin) != -1 )) {
BASE_URL = apiList.find(item => item.indexOf(window.location.origin) != -1 )
}else{ // 2.本地开发环境需要自行调整对应的接口地址前缀
switch (process.env.NODE_ENV) {
case 'pudong-sit':
BASE_URL = '/api/v2'
break
case 'pudong-prod':
BASE_URL = '/api'
break
case 'xuhui-sit':
BASE_URL = '/api/v2'
break
case 'xuhui-prod':
BASE_URL = '/apiv2'
break
case 'yangpu-sit':
BASE_URL = '/api/v2'
break
case 'yangpu-prod':
BASE_URL = '/api'
break
case 'huangpu-sit':
BASE_URL = '/api/v2'
break
case 'huangpu-prod':
BASE_URL = '/api'
break
default: // 默认环境下(开发环境)
// BASE_URL = 'http://31.0.161.39/apiv2'
// BASE_URL = 'http://211.136.105.193/apiv2'
// BASE_URL = 'http://yangpu-hm.omniview.pro/api/v2'
// BASE_URL = 'http://yangpu.hm.omniview.pro/api/v2'
// BASE_URL = 'http://huangpu-hm.omniview.pro/api/v2'
BASE_URL = 'http://xuhui.hm.omniview.pro/api/v2'
// BASE_URL = 'http://pudong.hm.omniview.pro/api/v2'
// BASE_URL = 'http://211.136.105.193/apiv2'
break
}
/**
* 此处配置本项目涉及到的所有
* 要求
......
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