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
import Vue from 'vue'
// import routes from './routes'
import asyncComponents from './asyncCompontents/index'
// const sharePool = (Vue.__share_pool__ = Vue.__share_pool__ || {})
// const routesPool = (sharePool.routes = sharePool.routes || {})
// // 挂载子项目的 route-list
// routesPool[process.env.VUE_APP_NAME] = routes
// const comPathMap = {}
// const serviceFiles = require.context(
// './services/', // 在当前目录下查找
// true, // 遍历子文件夹
// /\.js$/ // 正则匹配 以 .js结尾的文件
// )
// serviceFiles.keys().forEach(path => {
// const service = serviceFiles(path)
// service.default.install()
// })
const sharePool = (Vue.__share_pool__ = Vue.__share_pool__ || {})
const store = (sharePool.store = sharePool.store || {})
function loadView(component) {
return (resolve) => require([`@/views/${component}`], resolve)
}
function formatRoutes(routes) {
const formatRoutesArr = []
if (!routes) {
return []
}
routes.forEach(el => {
const router = {
meta: {}
}
const {
path,
route,
remark,
serverName,
name,
isCached
} = el
router['component'] = loadView(path)
if (name !== null) {
router['name'] = name
}
router['meta']['title'] = remark
router['meta']['serverName'] = serverName
router['meta']['keepAlive'] = isCached
router['path'] = route
// router['meta']['noCache'] = !keep_alive
formatRoutesArr.push(router)
})
return formatRoutesArr
}
function loadComponent(comName, type) {
let c
if (!type) {
c = resolve => { require([`@/asyncCompontents${comName}`], resolve) }
} else if (type === 'customComponent') {
c = resolve => { require([`@/customComponent${comName}`], resolve) }
}
return c
}
require('./business-components/tabCom/index.js')
export default {
name: 'dee-es',
routes: formatRoutes(store.state.routes.routesObj[process.env.VUE_APP_NAME]),
asyncComponents,
loadComponent,
beforeEach(from, to, next) {
next()
},
init() {}
}