App.vue
3.89 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
<div id="glsx-sub-system" :class="isFullsize?'full-size':''">
<div id="wrap" class="wrap" :class="isCollapse?'full-width':''">
<!-- 主体 -->
<main>
<!-- <el-row class="topbar">
<el-button type="primary" size="small" @click="toggle" class="toggle-btn"><i class="fa fa-bars"></i></el-button>
<img :src="logo" class="logo">
<a class="pull-right right-link" href="logout">
<i class="fa fa-sign-out"></i> 登 出
</a>
<a class="pull-right right-link" href="javascript(0)" @click.prevent="navigate">
<i class="fa fa-bell-o"></i> 系统公告
</a>
</el-row> -->
<router-view></router-view>
</main>
<!-- 主体 /-->
<!-- 左边导航栏 -->
<!-- <v-side-bar class="sidebar"></v-side-bar> -->
<!-- 左边导航栏 /-->
</div>
</div>
</template>
<script>
import store from './vuex/store.js'
import { mapGetters, mapActions } from 'vuex'
import vSideBar from 'components/SideBar.vue'
export default {
name: 'app',
data() {
return {
isQiankun: window.__POWERED_BY_QIANKUN__,
logo: require('images/logo.png')
}
},
watch: {
$route(to, from) {
if(this.isQiankun) {
this.getBreadcrumb();
}
}
},
mounted(){
// store.dispatch('getDeviceResources')
// store.dispatch('getLoginUser').then((res)=>{
// if(store.state.common.username === 'gqgdcx'){
// this.$router.push({path:"business/gqOrder"})
// }
// if(store.state.common.isCheckbook){
// // console.log(this.$route)
// // this.$router.push({path:"accounts/accountsList"})
// }
// })
// window.onresize = ()=>{
// const w = window,
// d = document,
// e = d.documentElement,
// g = d.getElementsByTagName('body')[0],
// x = w.innerWidth || e.clientWidth || g.clientWidth,
// y = w.innerHeight|| e.clientHeight|| g.clientHeight;
// d.getElementsByTagName('main')[0].style['minHeight'] = y+'px'
// }
// window.onresize()
this.$onGlobalStateChange((state, prev) => {
if(state.isCollapsed != this.isCollapse) {
this.toggleCollapse()
}
})
},
computed: {
...mapGetters([
'isCollapse',
'isFullsize'
])
},
methods: {
getBreadcrumb() {
const { getters: {curBreadCrumb}} = this.$root.parentVuex;
let matched = this.$route.matched.filter(item => item.name); // this.$route.matched 可以获取到一个数组,包含当前路由的所有嵌套路径片段的路由记录
const first = matched[0];
const { meta, path } = first;
const basePath = '/oEshield#';
let breadcrumb = [];
if(meta) {
const { title, pushState } = meta;
if(pushState && title) {
breadcrumb.push({
name: title,
path: basePath + path
})
history.state.pushState = pushState;
history.state.breadcrumb = [...curBreadCrumb, breadcrumb[0]];
// this.$root.parentVuex.dispatch('menu/setBreadCrumb', [...curBreadCrumb, breadcrumb]);
}
}
},
toggle(){
this.toggleCollapse()
},
...mapActions([
'toggleCollapse'
]),
navigate(){
let routeData = this.$router.resolve({
path: '/notice',
query: {
}
});
window.open(routeData.href, '_blank');
}
},
components: {
vSideBar
},
store
}
</script>
<style scoped>
.topbar {
min-height: 50px;
padding: 15px 10px;
}
.toggle-btn, .logo{
vertical-align: middle;
}
.logo{
margin-left: 10px;
}
a.right-link{
color: #999;
font-size: 14px;
margin-right: 20px;
line-height: 30px;
text-decoration: none;
}
.full-size main{
margin: 0;
}
.full-size .sidebar, .full-size .topbar{
display: none;
}
</style>