Skip to content

Commit f6295d8

Browse files
committed
🐛 Fixed user loading error
Signed-off-by: Ayaka Neko <neko@ayaka.moe>
1 parent e0c981f commit f6295d8

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

src/components/User/UserInfo.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default {
3838
introduction () {
3939
return this.user.introduction
4040
}
41+
},
42+
created () {
43+
console.log(this.user)
4144
}
4245
}
4346
</script>

src/pages/User/_id.vue

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,33 +147,42 @@ export default {
147147
...mapState(['wallet', 'isMe', 'username', 'userAvatar', 'userIntroduction', 'userType', 'userPage']),
148148
user () {
149149
let introduction = ''
150-
if (this.isMe) {
151-
if (this.userIntroduction === '') {
152-
introduction = 'No Introduction Yet'
153-
} else {
154-
introduction = this.userIntroduction
155-
}
156-
return { nickname: this.username, avatar: this.userAvatar, introduction: introduction, type: this.userType }
150+
if (this.userPage.introduction === '') {
151+
introduction = 'No Introduction Yet'
157152
} else {
158-
if (this.userPage.introduction === '') {
159-
introduction = 'No Introduction Yet'
160-
} else {
161-
introduction = this.userPage.introduction
162-
}
163-
return { nickname: this.userPage.nickname, avatar: this.userPage.avatar, introduction: introduction, type: this.userPage.type }
153+
introduction = this.userPage.introduction
164154
}
155+
return { nickname: this.userPage.nickname, avatar: this.userPage.avatar, introduction: introduction, type: this.userPage.type }
156+
}
157+
},
158+
watch: {
159+
async $route (val) {
160+
window.location.reload()
161+
await this.setUserPage({ wallet: val.params.id })
162+
let introduction = ''
163+
if (this.userPage.introduction === '') {
164+
introduction = 'No Introduction Yet'
165+
} else {
166+
introduction = this.userPage.introduction
167+
}
168+
this.user = { nickname: this.userPage.nickname, avatar: this.userPage.avatar, introduction: introduction, type: this.userPage.type }
169+
},
170+
username (val) {
171+
if (this.wallet === this.$route.params.id) {
172+
console.log('isMe')
173+
this.setIsMe(true)
174+
document.title = val + '\'s Profile - ArcLight'
175+
} else {
176+
document.title = this.userPage.nickname + '\'s Profile - ArcLight'
177+
}
178+
},
179+
userPage (val) {
180+
document.title = val.nickname + '\'s Profile - ArcLight'
165181
}
166182
},
167183
mounted () {
168184
this.setUserPage({ wallet: this.$route.params.id })
169-
if (this.wallet === this.$route.params.id) {
170-
console.log('isMe')
171-
this.setIsMe(true)
172-
document.title = this.username + '\'s Profile - ArcLight'
173-
} else {
174-
document.title = this.userPage.nickname + '\'s Profile - ArcLight'
175-
}
176-
185+
document.title = 'Profile - ArcLight'
177186
// 假数据 循环 变多
178187
// const followers = []
179188
// for (let i = 0; i < 3; i++) {

0 commit comments

Comments
 (0)