From 955c50597b53c3df7ed972dee5edf6d2276464e6 Mon Sep 17 00:00:00 2001
From: Tim <135014430+nagisa77@users.noreply.github.com>
Date: Sun, 6 Jul 2025 21:33:10 +0800
Subject: [PATCH] feat: disable comment submit and add loading
---
.../src/components/CommentEditor.vue | 45 +++++++++++++++----
open-isle-cli/src/components/CommentItem.vue | 9 +++-
open-isle-cli/src/views/PostPageView.vue | 10 ++++-
3 files changed, 52 insertions(+), 12 deletions(-)
diff --git a/open-isle-cli/src/components/CommentEditor.vue b/open-isle-cli/src/components/CommentEditor.vue
index c0a9cb669..f47d3b67a 100644
--- a/open-isle-cli/src/components/CommentEditor.vue
+++ b/open-isle-cli/src/components/CommentEditor.vue
@@ -2,13 +2,24 @@
@@ -89,6 +110,14 @@ export default {
font-size: 14px;
cursor: pointer;
}
+.comment-submit.disabled {
+ background-color: var(--primary-color-disabled);
+ opacity: 0.5;
+ cursor: not-allowed;
+}
+.comment-submit.disabled:hover {
+ background-color: var(--primary-color-disabled);
+}
.comment-submit:hover {
background-color: var(--primary-color-hover);
}
diff --git a/open-isle-cli/src/components/CommentItem.vue b/open-isle-cli/src/components/CommentItem.vue
index 248b1dfd5..95642b9a9 100644
--- a/open-isle-cli/src/components/CommentItem.vue
+++ b/open-isle-cli/src/components/CommentItem.vue
@@ -40,7 +40,7 @@
-
+
{{ comment.reply.length }}条回复
@@ -77,6 +77,7 @@ const CommentItem = {
setup(props) {
const showReplies = ref(false)
const showEditor = ref(false)
+ const isWaitingForReply = ref(false)
const toggleReplies = () => {
showReplies.value = !showReplies.value
}
@@ -85,9 +86,11 @@ const CommentItem = {
}
const submitReply = async (text) => {
if (!text.trim()) return
+ isWaitingForReply.value = true
const token = getToken()
if (!token) {
toast.error('请先登录')
+ isWaitingForReply.value = false
return
}
try {
@@ -120,13 +123,15 @@ const CommentItem = {
}
} catch (e) {
toast.error('回复失败')
+ } finally {
+ isWaitingForReply.value = false
}
}
const copyCommentLink = () => {
const link = `${location.origin}${location.pathname}#comment-${props.comment.id}`
navigator.clipboard.writeText(link)
}
- return { showReplies, toggleReplies, showEditor, toggleEditor, submitReply, copyCommentLink, renderMarkdown }
+ return { showReplies, toggleReplies, showEditor, toggleEditor, submitReply, copyCommentLink, renderMarkdown, isWaitingForReply }
}
}
CommentItem.components = { CommentItem, CommentEditor }
diff --git a/open-isle-cli/src/views/PostPageView.vue b/open-isle-cli/src/views/PostPageView.vue
index f3188a79a..f4a502cf5 100644
--- a/open-isle-cli/src/views/PostPageView.vue
+++ b/open-isle-cli/src/views/PostPageView.vue
@@ -65,7 +65,7 @@
-
+