feat: fix 注册失败和登录失败

This commit is contained in:
tim
2025-08-10 11:50:21 +08:00
parent 1a8e216aa9
commit 1177a778ee
3 changed files with 15 additions and 20 deletions

View File

@@ -82,7 +82,6 @@ export default {
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: this.username, password: this.password }) body: JSON.stringify({ username: this.username, password: this.password })
}) })
this.isWaitingForLogin = false
const data = await res.json() const data = await res.json()
if (res.ok && data.token) { if (res.ok && data.token) {
setToken(data.token) setToken(data.token)
@@ -103,6 +102,8 @@ export default {
} }
} catch (e) { } catch (e) {
toast.error('登录失败') toast.error('登录失败')
} finally {
this.isWaitingForLogin = false
} }
}, },

View File

@@ -44,11 +44,8 @@
<div class="user-name"> <div class="user-name">
{{ author.username }} {{ author.username }}
<i class="fas fa-medal medal-icon"></i> <i class="fas fa-medal medal-icon"></i>
<router-link <router-link v-if="author.displayMedal" class="user-medal" :to="`/users/${author.id}?tab=achievements`">{{
v-if="author.displayMedal" getMedalTitle(author.displayMedal) }}</router-link>
class="user-medal"
:to="`/users/${author.id}?tab=achievements`"
>{{ getMedalTitle(author.displayMedal) }}</router-link>
</div> </div>
<div class="post-time">{{ postTime }}</div> <div class="post-time">{{ postTime }}</div>
</div> </div>
@@ -59,11 +56,8 @@
<div class="user-name"> <div class="user-name">
{{ author.username }} {{ author.username }}
<i class="fas fa-medal medal-icon"></i> <i class="fas fa-medal medal-icon"></i>
<router-link <router-link v-if="author.displayMedal" class="user-medal" :to="`/users/${author.id}?tab=achievements`">{{
v-if="author.displayMedal" getMedalTitle(author.displayMedal) }}</router-link>
class="user-medal"
:to="`/users/${author.id}?tab=achievements`"
>{{ getMedalTitle(author.displayMedal) }}</router-link>
</div> </div>
<div class="post-time">{{ postTime }}</div> <div class="post-time">{{ postTime }}</div>
</div> </div>
@@ -334,7 +328,6 @@ export default {
category.value = data.category category.value = data.category
tags.value = data.tags || [] tags.value = data.tags || []
postReactions.value = data.reactions || [] postReactions.value = data.reactions || []
await fetchComments()
subscribed.value = !!data.subscribed subscribed.value = !!data.subscribed
status.value = data.status status.value = data.status
pinnedAt.value = data.pinnedAt pinnedAt.value = data.pinnedAt
@@ -593,7 +586,6 @@ export default {
const hash = location.hash const hash = location.hash
if (hash.startsWith('#comment-')) { if (hash.startsWith('#comment-')) {
const id = hash.substring('#comment-'.length) const id = hash.substring('#comment-'.length)
// 不清楚啥原因先wait一下子不然会定不准 😅
await new Promise(resolve => setTimeout(resolve, 500)) await new Promise(resolve => setTimeout(resolve, 500))
const el = document.getElementById('comment-' + id) const el = document.getElementById('comment-' + id)
if (el) { if (el) {
@@ -609,17 +601,18 @@ export default {
router.push(`/users/${author.value.id}`) router.push(`/users/${author.value.id}`)
} }
await fetchPost()
onMounted(async () => { onMounted(async () => {
await fetchComments()
const hash = location.hash const hash = location.hash
const id = hash.startsWith('#comment-') ? hash.substring('#comment-'.length) : null const id = hash.startsWith('#comment-') ? hash.substring('#comment-'.length) : null
if (id) expandCommentPath(id) if (id) expandCommentPath(id)
updateCurrentIndex() updateCurrentIndex()
window.addEventListener('scroll', updateCurrentIndex) window.addEventListener('scroll', updateCurrentIndex)
await jumpToHashComment() jumpToHashComment()
}) })
await fetchPost()
return { return {
postContent, postContent,
author, author,

View File

@@ -187,7 +187,6 @@ export default {
username: this.username username: this.username
}) })
}) })
this.isWaitingForEmailVerified = false
const data = await res.json() const data = await res.json()
if (res.ok) { if (res.ok) {
if (this.registerMode === 'WHITELIST') { if (this.registerMode === 'WHITELIST') {
@@ -201,6 +200,8 @@ export default {
} }
} catch (e) { } catch (e) {
toast.error('注册失败') toast.error('注册失败')
} finally {
this.isWaitingForEmailVerified = false
} }
}, },
signupWithGithub() { signupWithGithub() {