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>
@@ -93,7 +87,7 @@
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch> <l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div> </div>
<div v-else class="comments-container"> <div v-else class="comments-container">
<BaseTimeline :items="comments"> <BaseTimeline :items="comments">
<template #item="{ item }"> <template #item="{ item }">
<CommentItem :key="item.id" :comment="item" :level="0" :default-show-replies="item.openReplies" <CommentItem :key="item.id" :comment="item" :level="0" :default-show-replies="item.openReplies"
@deleted="onCommentDeleted" /> @deleted="onCommentDeleted" />
@@ -197,7 +191,7 @@ export default {
window.removeEventListener('scroll', updateCurrentIndex) window.removeEventListener('scroll', updateCurrentIndex)
}) })
} }
const lightboxVisible = ref(false) const lightboxVisible = ref(false)
const lightboxIndex = ref(0) const lightboxIndex = ref(0)
const lightboxImgs = ref([]) const lightboxImgs = ref([])
@@ -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
@@ -498,7 +491,7 @@ export default {
toast.error('操作失败') toast.error('操作失败')
} }
} }
const editPost = () => { const editPost = () => {
router.push(`/posts/${postId}/edit`) router.push(`/posts/${postId}/edit`)
} }
@@ -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() {