Skip to content

Commit 11aa09c

Browse files
committed
修复因为切换实例代码页面导致数据错乱bug
1 parent 2cb23e6 commit 11aa09c

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

src/components/headerAccount.vue

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="is-login pointer" v-if="loginState">
44
<v-menu transition="slide-y-transition" bottom offset-y right>
55
<template v-slot:activator="{ on, attrs }">
6-
<v-avatar :size="dense?30:40" class="avatar" v-bind="attrs" v-on="on" color="primary">
6+
<v-avatar :size="dense?30:40" class="avatar" v-bind="attrs" v-on="on" :color="loginInfo.avatar?'':'primary'">
77
<v-img :src="qiNiuImgLink+loginInfo.avatar" v-if="loginInfo.avatar"></v-img>
88
<span class="white--text text-h7" v-else>{{loginInfo.nickname|preNickname}}</span>
99
</v-avatar>
@@ -35,13 +35,15 @@ import { mapState, mapMutations } from 'vuex'
3535
import localStore from '@utils/local-storage'
3636
import { qiNiuImgLink } from '@utils/publicData'
3737
import cookie from '@utils/cookie'
38+
import IframeHandler from '@utils/editor/handleInstanceView'
3839
export default {
3940
props: {
4041
dense: {
4142
type: Boolean,
4243
default: false,
4344
},
4445
},
46+
inject: ['changeRouterKey'],
4547
data() {
4648
return {
4749
qiNiuImgLink,
@@ -73,24 +75,42 @@ export default {
7375
...mapState(['loginState', 'loginInfo']),
7476
},
7577
methods: {
76-
...mapMutations(['setLoginInfo', 'setLoginState']),
78+
...mapMutations(['setLoginInfo', 'setLoginState', 'resetInstanceState']),
7779
handleMenu(val) {
7880
switch (val) {
7981
case 'user': {
8082
this.$router
81-
.push({
82-
name: 'User',
83-
params: {
84-
id: this.loginInfo.username,
85-
},
86-
})
83+
.push(`/user/${this.loginInfo.username}`)
8784
.catch((err) => {})
8885
break
8986
}
9087
case 'newWork': {
91-
this.$router.push({
92-
name: 'NewWork',
93-
})
88+
/**
89+
* 在新建实例或实例详情页面点击新建实例
90+
* 需要触发App的changeRouterKey方法改变key强制刷新路由
91+
* 并且需要清除iframe的绑定和实例部分配置
92+
*/
93+
switch (this.$route.name) {
94+
case 'NewWork': {
95+
this.$router.push({ name: 'NewWork' }).catch((err) => {
96+
this.changeRouterKey()
97+
IframeHandler.clearIframe()
98+
this.resetInstanceState()
99+
})
100+
break
101+
}
102+
case 'Work': {
103+
this.$router.push({ name: 'NewWork' }).then(() => {
104+
this.changeRouterKey()
105+
IframeHandler.clearIframe()
106+
this.resetInstanceState()
107+
})
108+
break
109+
}
110+
default: {
111+
this.$router.push({ name: 'NewWork' }).catch((err) => {})
112+
}
113+
}
94114
break
95115
}
96116
case 'settings': {
@@ -124,7 +144,6 @@ export default {
124144
}
125145
},
126146
},
127-
components: {},
128147
}
129148
</script>
130149

@@ -133,13 +152,13 @@ export default {
133152
.user-menu-list {
134153
color: $light-5 !important;
135154
@include setTransition(color, 0.3s, ease);
155+
&:hover {
156+
color: $light-1 !important;
157+
}
136158
.icon {
137159
color: inherit;
138160
margin-right: 15px;
139161
}
140-
&:hover {
141-
color: $light-1 !important;
142-
}
143162
}
144163
}
145164
</style>

0 commit comments

Comments
 (0)