From c0e21840f155845622003f60425c788c67e0edb5 Mon Sep 17 00:00:00 2001
From: nanhaoluo <3075912108@qq.com>
Date: Fri, 23 Jan 2026 16:41:02 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AF=84=E8=AE=BA?=
=?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=90=8E=E8=A1=A8=E5=8D=95=E7=8A=B6=E6=80=81?=
=?UTF-8?q?=E6=9C=AA=E6=B8=85=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 将表单重置代码移到 success 回调的最前面,确保优先执行
- 将表单重置与 UI 更新(插入评论、滚动)分离,避免异常影响表单重置
- 确保评论内容、验证码、Geetest 状态都能正确清除
- 修复需要刷新页面才能再次发送评论的问题
---
argontheme.js | 105 +++++++++++++++++++++++++++-----------------------
1 file changed, 57 insertions(+), 48 deletions(-)
diff --git a/argontheme.js b/argontheme.js
index 066fbb6..0d64034 100644
--- a/argontheme.js
+++ b/argontheme.js
@@ -1635,54 +1635,14 @@ if (argonConfig.waterflow_columns != "1") {
}
//发送成功
- // 使用 setTimeout 确保 iziToast 操作在下一个事件循环中执行
- setTimeout(function() {
- try {
- iziToast.destroy();
- iziToast.show({
- title: __("发送成功"),
- message: __("您的评论已发送"),
- class: 'shadow-sm',
- position: 'topRight',
- backgroundColor: '#2dce89',
- titleColor: '#ffffff',
- messageColor: '#ffffff',
- iconColor: '#ffffff',
- progressBarColor: '#ffffff',
- icon: 'fa fa-check',
- timeout: 5000
- });
- //插入新评论
- result.html = result.html.replace(/<(\/).noscript>/g, "");
- let parentID = result.parentID;
- if (parentID == "" || parentID == null){
- parentID = 0;
- }
- parentID = parseInt(parentID);
- if (parentID == 0){
- if ($("#comments > .card-body > ol.comment-list").length == 0){
- $("#comments > .card-body").html("
");
- }
- if (result.commentOrder == "asc"){
- $("#comments > .card-body > ol.comment-list").append(result.html);
- }else{
- $("#comments > .card-body > ol.comment-list").prepend(result.html);
- }
- }else{
- if ($("#comment-" + parentID + " + .comment-divider + li > ul.children").length > 0){
- $("#comment-" + parentID + " + .comment-divider + li > ul.children").append(result.html);
- }else{
- $("#comment-" + parentID + " + .comment-divider").after("");
- }
- }
- calcHumanTimesOnPage();
- //复位评论表单
+ // 先复位评论表单(确保无论后续操作是否成功都能重置表单)
cancelReply();
$("#post_comment_content").val("");
+
// 重置数学验证码
$("#post_comment_captcha_seed").val(result.newCaptchaSeed);
$("#post_comment_captcha + style").html(".post-comment-captcha-container:before{content: '" + result.newCaptcha + "';}");
- $("#post_comment_captcha").val(""); // 清空验证码输入框
+ $("#post_comment_captcha").val("");
// 清空Geetest验证码隐藏字段并重置验证码实例
if ($("#geetest-captcha").length > 0) {
@@ -1703,13 +1663,62 @@ if (argonConfig.waterflow_columns != "1") {
}
}
}
- $("body,html").animate({
- scrollTop: $("#comment-" + result.id).offset().top - 100
- }, 500, 'easeOutExpo');
+
+ // 显示成功提示
+ setTimeout(function() {
+ try {
+ iziToast.destroy();
+ iziToast.show({
+ title: __("发送成功"),
+ message: __("您的评论已发送"),
+ class: 'shadow-sm',
+ position: 'topRight',
+ backgroundColor: '#2dce89',
+ titleColor: '#ffffff',
+ messageColor: '#ffffff',
+ iconColor: '#ffffff',
+ progressBarColor: '#ffffff',
+ icon: 'fa fa-check',
+ timeout: 5000
+ });
} catch (e) {
- ArgonDebug.warn('Comment insertion error:', e);
+ ArgonDebug.warn('iziToast error:', e);
}
- }, 0);
+ }, 0);
+
+ // 插入新评论
+ try {
+ result.html = result.html.replace(/<(\/).noscript>/g, "");
+ let parentID = result.parentID;
+ if (parentID == "" || parentID == null){
+ parentID = 0;
+ }
+ parentID = parseInt(parentID);
+ if (parentID == 0){
+ if ($("#comments > .card-body > ol.comment-list").length == 0){
+ $("#comments > .card-body").html("");
+ }
+ if (result.commentOrder == "asc"){
+ $("#comments > .card-body > ol.comment-list").append(result.html);
+ }else{
+ $("#comments > .card-body > ol.comment-list").prepend(result.html);
+ }
+ }else{
+ if ($("#comment-" + parentID + " + .comment-divider + li > ul.children").length > 0){
+ $("#comment-" + parentID + " + .comment-divider + li > ul.children").append(result.html);
+ }else{
+ $("#comment-" + parentID + " + .comment-divider").after("");
+ }
+ }
+ calcHumanTimesOnPage();
+
+ // 滚动到新评论
+ $("body,html").animate({
+ scrollTop: $("#comment-" + result.id).offset().top - 100
+ }, 500, 'easeOutExpo');
+ } catch (e) {
+ ArgonDebug.warn('Comment insertion error:', e);
+ }
},
error: function(result){
$("#post_comment").removeClass("sending");