From 54f2214a6a0dd9c9b6d2270a04f77deac71f4349 Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Thu, 22 Jan 2026 18:23:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9F=A5=E7=9C=8B=20AI=20=E8=AF=B7=E6=B1=82=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 AI 内容查询页面底部添加管理员可见的历史记录列表 - 显示最近 50 条 AI 文章摘要和垃圾评论检测记录 - 支持点击记录查看详细信息的弹窗 - 记录按时间倒序排列,包含类型、识别码、标题和时间 - 弹窗显示完整的 AI 请求详情,包括生成内容、模型信息等 - 仅管理员可见,普通用户不受影响 --- ai-summary-query.php | 359 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) diff --git a/ai-summary-query.php b/ai-summary-query.php index 3b853e1..8b73879 100644 --- a/ai-summary-query.php +++ b/ai-summary-query.php @@ -605,6 +605,365 @@ html.darkmode .ai-verify-subtitle { color: #aaa; } +get_results(" + SELECT pm.post_id, pm.meta_value as code, pm2.meta_value as time + FROM {$wpdb->postmeta} pm + LEFT JOIN {$wpdb->postmeta} pm2 ON pm.post_id = pm2.post_id AND pm2.meta_key = '_argon_ai_summary_time' + WHERE pm.meta_key = '_argon_ai_summary_code' + ORDER BY pm2.meta_value DESC + LIMIT 50 + "); + + // 获取所有垃圾评论检测记录 + $spam_detections = $wpdb->get_results(" + SELECT cm.comment_id, cm.meta_value as code, cm2.meta_value as time + FROM {$wpdb->commentmeta} cm + LEFT JOIN {$wpdb->commentmeta} cm2 ON cm.comment_id = cm2.comment_id AND cm2.meta_key = '_argon_spam_detection_time' + WHERE cm.meta_key = '_argon_spam_detection_code' + ORDER BY cm2.meta_value DESC + LIMIT 50 + "); + + // 合并并按时间排序 + $all_records = []; + + foreach ($summaries as $summary) { + $post = get_post($summary->post_id); + if ($post) { + $all_records[] = [ + 'type' => 'summary', + 'code' => $summary->code, + 'time' => $summary->time ? intval($summary->time) : 0, + 'title' => get_the_title($summary->post_id), + 'url' => get_permalink($summary->post_id), + 'id' => $summary->post_id, + 'data' => [ + 'post_id' => $summary->post_id, + 'post_title' => get_the_title($summary->post_id), + 'post_url' => get_permalink($summary->post_id), + 'summary' => get_post_meta($summary->post_id, '_argon_ai_summary', true), + 'model' => get_post_meta($summary->post_id, '_argon_ai_summary_model', true), + 'provider' => get_post_meta($summary->post_id, '_argon_ai_summary_provider', true), + 'generated_time' => $summary->time + ] + ]; + } + } + + foreach ($spam_detections as $detection) { + $comment = get_comment($detection->comment_id); + if ($comment) { + $detection_result = get_comment_meta($detection->comment_id, '_argon_spam_detection_result', true); + $all_records[] = [ + 'type' => 'spam_detection', + 'code' => $detection->code, + 'time' => $detection->time ? intval($detection->time) : 0, + 'title' => sprintf(__('评论 #%d - %s', 'argon'), $detection->comment_id, $comment->comment_author), + 'url' => get_comment_link($comment), + 'id' => $detection->comment_id, + 'data' => [ + 'comment_id' => $detection->comment_id, + 'comment_author' => $comment->comment_author, + 'comment_content' => $comment->comment_content, + 'comment_date' => $comment->comment_date, + 'post_title' => get_the_title($comment->comment_post_ID), + 'post_url' => get_permalink($comment->comment_post_ID), + 'is_spam' => isset($detection_result['is_spam']) ? $detection_result['is_spam'] : false, + 'reason' => isset($detection_result['reason']) ? $detection_result['reason'] : '', + 'action' => isset($detection_result['action']) ? $detection_result['action'] : '', + 'detection_time' => $detection->time + ] + ]; + } + } + + // 按时间倒序排序 + usort($all_records, function($a, $b) { + return $b['time'] - $a['time']; + }); + + // 只保留前50条 + $all_records = array_slice($all_records, 0, 50); + + if (!empty($all_records)): +?> + +
+

+ + + () + +

+ +
+ + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+ + +
+
+
+

+ +
+
+ +
+
+
+ + + + + + +