From d4f709762f88df580c9d1c897757832ac0010d81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B5=A9=E5=8A=AB=E8=80=8512345?= <3112611479@qq.com>
Date: Fri, 9 Aug 2024 10:35:05 +0800
Subject: [PATCH] refresh userHome on edit
---
index.css | 3 +++
index.js | 32 ++++++++++++++++++++------------
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/index.css b/index.css
index e451388..c1a36bb 100644
--- a/index.css
+++ b/index.css
@@ -1982,6 +1982,9 @@ p.altLoginOption,
.userHome .useraction ul>li {
padding: 0.625rem 1.5rem;
+ animation-name: enableClickDelayed;
+ animation-duration: 0.1s;
+ animation-fill-mode: forwards;
}
.userHome .useraction ul>li:hover {
diff --git a/index.js b/index.js
index 545dbcd..dd01554 100644
--- a/index.js
+++ b/index.js
@@ -888,6 +888,20 @@ const User = {
methods: {
convertAvatarPath: User.convertAvatarPath,
+ getUser() {
+ XHR.get(this.id ? 'user/find' : 'user/me', {
+ id: this.id
+ }).then(r => {
+ let user = Array.isArray(r) ? r[0] : r
+ if (user) {
+ this.user = user
+ this.getComments()
+ } else {
+ FloatMsgs.show({ type: 'warn', msg: `找不到用户User not found (ID: ${this.id})` })
+ }
+ })
+ },
+
getComments() {
this.scrollPaused = true
@@ -938,18 +952,7 @@ const User = {
name: this.name,
avatar: this.avatar,
}
-
- XHR.get(this.id ? 'user/find' : 'user/me', {
- id: this.id
- }).then(r => {
- let user = Array.isArray(r) ? r[0] : r
- if (user) {
- this.user = user
- this.getComments()
- } else {
- FloatMsgs.show({ type: 'warn', msg: `找不到用户User not found (ID: ${this.id})` })
- }
- })
+ this.getUser()
},
})
},
@@ -1031,6 +1034,11 @@ const User = {
document.getElementById('msgPopupAvatar').src = User.convertAvatarPath(r.avatar)
document.getElementById('senderText').textContent = r.name
} catch (error) { }
+ Popup.VuePopups.$children.forEach(v => {
+ if (v.$options.name == 'userHome') {
+ v.getUser()
+ }
+ })
})
userInfo.onclick = () => this.showMe()
userInfo.classList.remove('nologin')