AppMain.vue
3.12 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<template>
<!-- <el-scrollbar class="page-scrollbar"> -->
<div class="app-main">
<transition name="fade-transform" mode="out-in" v-if="!isActiveMicroApp">
<router-view class="page container" :key="key" />
<!-- <keep-alive :include="cachedViews">
</keep-alive> -->
</transition>
<div v-loading="loading" class="height100 micro-app-wrap container">
<div id="micro-app" class="height100" v-show="isActiveMicroApp">
<!-- <div id="app" class="mask" style="position: absolute">
<i class="el-icon-loading cc"></i>
</div> -->
</div>
</div>
</div>
<!-- </el-scrollbar> -->
</template>
<script>
import { registerMicroApps, start, initGlobalState } from 'qiankun'
export default {
name: 'AppMain',
data() {
return {
loading: false,
}
},
computed: {
cachedViews() {
return this.$store.state.tagsView.cachedViews
},
key() {
return this.$route.path
},
isActiveMicroApp() {
let microApp = window.lwConfig.MICRO_APPS
return (
microApp && Object.values(microApp).some((item) => this.$route.path.startsWith(item.activeRule.match('/.*')[0]))
)
},
},
mounted() {
if (window.lwConfig.MICRO_APPS && window.lwConfig.MICRO_APPS.store) {
window.Vue2 = window.Vue
delete window.Vue
window.lwConfig.MICRO_APPS.store.loader = (loading) => (this.loading = loading)
registerMicroApps([window.lwConfig.MICRO_APPS.store])
start({
sandbox: { experimentalStyleIsolation: true },
})
// 挂在window供下面微服务使用
window.lwConfig.$store = this.$store
// 初始化 state
// const actions = initGlobalState({ token: getToken() })
// actions.onGlobalStateChange((state, prev) => {
// // state: 变更后的状态; prev 变更前的状态
// });
// actions.setGlobalState(state)
}
// if (window.lwConfig.MICRO_APPS) {
// import('qiankun').then(({ registerMicroApps, start }) => {
// registerMicroApps(window.lwConfig.MICRO_APPS)
// start({
// sandbox: { experimentalStyleIsolation: true },
// })
// })
// }
},
}
</script>
<style lang="scss" scoped>
// ::v-deep .el-scrollbar__wrap {
// margin: 20px 0;
// padding: 0 20px;
// }
.app-main {
position: relative;
overflow: hidden;
flex: auto;
margin-top: 20px;
}
.container {
position: relative;
max-height: 100%;
overflow-y: auto;
overflow-x: hidden;
&::-webkit-scrollbar-thumb {
visibility: hidden;
}
&:hover::-webkit-scrollbar-thumb {
visibility: visible;
}
}
.page {
padding: 0 20px;
// background: #fff;
// border-radius: var(--border-radius-big);
}
.micro-app-wrap {
margin: 0 20px;
}
.fixed-header + .app-main {
padding-top: 50px;
}
.hasTagsView {
.app-main {
/* 84 = navbar + tags-view = 50 + 34 */
height: calc(100vh - 84px);
}
.fixed-header + .app-main {
padding-top: 84px;
}
}
</style>
<style lang="scss">
// fix css style bug in open el-dialog
.el-popup-parent--hidden {
.fixed-header {
padding-right: 15px;
}
}
#micro-app > div {
height: 100%;
}
</style>