feat: 5级情感分析、日志UI优化、页面链接支持、v1.0.0-b26cea

This commit is contained in:
sunny-335
2026-06-18 19:58:46 +08:00
parent 77e3bd36c5
commit a9dd1c14bc
14 changed files with 441 additions and 110 deletions
+2 -60
View File
@@ -7,7 +7,7 @@
- **多 AI 角色** — 支持创建多个 AI 角色,每个角色有独立的昵称、人格提示词和 Gravatar 头像,可为不同文章指定不同角色 - **多 AI 角色** — 支持创建多个 AI 角色,每个角色有独立的昵称、人格提示词和 Gravatar 头像,可为不同文章指定不同角色
- **自动回复** — 监听新评论,自动调用 AI 生成回复,支持多轮对话上下文 - **自动回复** — 监听新评论,自动调用 AI 生成回复,支持多轮对话上下文
- **多语言适配** — 根据评论语言自动用对应语言回复 - **多语言适配** — 根据评论语言自动用对应语言回复
- **情感分析** — 分析评论情感倾向(正面/中性/负面),根据情感调整回复语气 - **情感分析** — 分析评论情感倾向(非常正面/正面/中性/负面/非常负面),根据情感调整回复语气
- **草稿模式** — AI 回复先存为草稿,管理员审核后再发布,支持批量操作 - **草稿模式** — AI 回复先存为草稿,管理员审核后再发布,支持批量操作
- **失败重试** — AI 生成失败时自动重试,指数退避策略 - **失败重试** — AI 生成失败时自动重试,指数退避策略
- **对话轮次限制** — 同一评论线程中限制 AI 最多回复轮次,防止无限对话 - **对话轮次限制** — 同一评论线程中限制 AI 最多回复轮次,防止无限对话
@@ -67,65 +67,7 @@ pnpm dev
## 文档 ## 文档
完整文档请访问 [AI回评文档站](https://nxxy335.top/comment-ai-autopilot) 完整文档及更新日志请访问 [AI回评文档站](https://nxxy335.top/comment-ai-autopilot)
## 更新日志
### v1.0.0-beta.2
**改进**
- 通过 Halo 官方推荐的 `ExtensionGetter` 获取 AI Foundation 的 `AiModelService`,替换原先的跨 ClassLoader 反射调用方式
-`plugin.yaml` 中声明可选插件依赖 `ai-foundation?: "*"`,建立正确的插件依赖关系
- 新增 `store.halo.run/recommended-apps` 注解,安装后可在应用市场推荐安装 AI Foundation 插件
- 情感分析和内容审核改用 AI Foundation 结构化输出(`OutputSpec.choice`),分类更可靠
- AI 调用改用 `GenerateTextRequest` 并设置 `maxRetries=2`,由 SDK 自动重试瞬时错误
- AI 对话续接时自动获取之前的回复历史并注入到 Prompt 中,AI 能更好地理解对话上下文
- 优化 AI 自审核评分机制:改为两阶段评估(安全检查 + 质量评分 1-5 分),评分映射到 0-100 分,替代原先的二值评分
- 精简仪表盘:移除情感分布、近7日回复趋势、平均审核评分三个卡片,快捷操作精简为回复日志、插件设置、刷新数据
- 重做设置页面:基本设置、AI角色设置、模型设置、Prompt设置、数据清理各为独立页面,通过标签栏切换
- 优化设置页面布局:按钮统一排版并添加图标,侧边栏新增"未保存"状态指示器
- 优化日志页面:评分增加等级标签(优秀/良好/一般/较差),筛选下拉框修复文本与箭头重叠
- 优化 AI Foundation 状态提示宽度,与内容区宽度一致
- 优化插件文档:修复版本要求、变量名、链接等错误
**Bug 修复**
- 修复 RateLimitService 清理线程在插件停止时未关闭导致线程泄漏
- 修复内容审核提示词要求"重新生成"但代码未使用重新生成内容的问题
- 修复设置页面按钮图标和文字未在同一行显示的问题
- 修复设置页面标签栏无法点击切换的问题
- 修复设置页面配置区域布局错误的问题
### v1.0.0-beta.1
**新功能**
- 草稿模式:关闭"自动发布"后,AI 回复将保存为草稿,需站长审核后才发布
- 多 AI 角色支持:支持配置多个 AI 虚拟角色,每个角色有独立的提示词、头像和模型
- 提示词预设:内置多种回复风格预设(专业型、幽默型、简洁型等),可自由组合
- 对话历史查看:支持查看 AI 回复的完整对话上下文
**Bug 修复**
- 修复草稿模式下审批失败("AI回复已存在,无法重复发布")的问题
- 修复批量审批时同样的去重检查冲突问题
- 修复 AI Foundation 不可用的问题(`PluginManager` 无法通过 Spring 依赖注入获取)
- 修复 `DefaultSpringPlugin` 包级私有类反射访问权限问题
- 修复 CI 构建失败(`gradlew` 缺少执行权限)
**改进**
- 审批逻辑优化:先查找已有 Reply 扩展再决定创建或更新
- 移除不必要的 `AiFoundationConfiguration` 配置类
- 前端 UI 优化:移除编辑功能、简化角色排序逻辑、清理无用代码
### v0.0.3
- 增强插件可靠性与可用性
- 多 AI 角色支持
- 草稿模式初步实现
- 文档全面更新
## 许可证 ## 许可证
+1 -1
View File
@@ -5,7 +5,7 @@ plugins {
} }
group 'top.nxxy335.commentaiautopilot' group 'top.nxxy335.commentaiautopilot'
version '1.0.0-beta.3' version '1.0.0-b26cea'
repositories { repositories {
mavenCentral() mavenCentral()
+2 -1
View File
@@ -41,13 +41,14 @@ export default defineConfig({
text: "其他", text: "其他",
items: [ items: [
{ text: "常见问题", link: "/guide/faq" }, { text: "常见问题", link: "/guide/faq" },
{ text: "更新日志", link: "/CHANGELOG" },
], ],
}, },
], ],
socialLinks: [ socialLinks: [
{ {
icon: "github", icon: "github",
link: "https://github.com/nxxy335/plugin-comment-ai-autopilot", link: "https://github.com/sunny-335/plugin-comment-ai-autopilot",
}, },
], ],
search: { search: {
+19
View File
@@ -1,5 +1,24 @@
# 更新日志 # 更新日志
## v1.0.0-b26cea
> 2026-06-18
### 改进
- **优化情感分析系统**:从 3 级分类(正面/中性/负面)升级为 5 级分类(非常正面/正面/中性/负面/非常负面),情感判断更精细
- **优化日志页面 UI**:批量操作按钮重写样式,确保底色和白色文字清晰可见;搜索框添加搜索图标;重置按钮添加图标和底色
- **优化评分显示**:评分数字与等级标签之间添加间距,等级标签增加底色背景(优秀/良好/一般/较差)
- **优化状态标签**:通过状态、发布状态、情感标签统一使用带底色的标签样式
- **支持页面链接显示**:日志中新增独立页面(SinglePage)链接显示,之前仅支持文章链接
- **ObjectMapper 统一注入**FilterService 和 PromptBuilder 中的 `new ObjectMapper()` 改为 Spring 构造函数注入
- **服务端过滤优化**:日志列表查询改用 `Queries.equal()` 服务端过滤 status/sentiment,减少内存过滤开销
- **新增索引**:为 AiCommentReply 扩展添加 `spec.sentiment``spec.published``spec.postKind` 索引
- **新增 postKind 字段**:区分关联内容类型(Post/SinglePage),支持页面评论的链接生成
- **PromptBuilder 情感提示**:适配 5 级情感分类,新增 VERY_POSITIVE 和 VERY_NEGATIVE 的语气提示
---
## v1.0.0-beta.2 ## v1.0.0-beta.2
> 2026-06-17 > 2026-06-17
+1 -1
View File
@@ -7,7 +7,7 @@ AI回评(Comment AI Autopilot)是一个 Halo 博客系统的插件,能够
- **自动回复** — 监听新评论,自动调用AI生成回复,支持多轮对话上下文 - **自动回复** — 监听新评论,自动调用AI生成回复,支持多轮对话上下文
- **多 AI 角色** — 支持创建多个 AI 角色,每个角色有独立的昵称、人格提示词和 Gravatar 头像,可为不同文章指定不同角色 - **多 AI 角色** — 支持创建多个 AI 角色,每个角色有独立的昵称、人格提示词和 Gravatar 头像,可为不同文章指定不同角色
- **多语言适配** — 根据评论语言自动用对应语言回复 - **多语言适配** — 根据评论语言自动用对应语言回复
- **情感分析** — 分析评论情感倾向(正面/中性/负面),根据情感调整回复语气 - **情感分析** — 分析评论情感倾向(非常正面/正面/中性/负面/非常负面),根据情感调整回复语气
- **草稿模式** — AI回复先存为草稿,管理员审核后再发布 - **草稿模式** — AI回复先存为草稿,管理员审核后再发布
- **失败重试** — AI生成失败时自动重试,指数退避策略 - **失败重试** — AI生成失败时自动重试,指数退避策略
- **批量操作** — 草稿模式下支持批量通过/拒绝/删除 - **批量操作** — 草稿模式下支持批量通过/拒绝/删除
+10 -6
View File
@@ -6,14 +6,16 @@
| 分类 | 说明 | AI回复语气 | | 分类 | 说明 | AI回复语气 |
|------|------|-----------| |------|------|-----------|
| 正面 | 评论情绪积极、友好、感谢 | 热情友好,表达感谢和共鸣 | | 非常正面 | 强烈的感谢、赞美、认同(如"太棒了"、"非常感谢" | 热情洋溢,表达真诚的感谢和共鸣 |
| 中性 | 评论情绪平淡、普通提问 | 正常语气回复,不加额外提示 | | 正面 | 友好、肯定、支持(如"不错"、"学习了") | 热情友好,表达感谢和共鸣 |
| 负面 | 评论情绪偏消极、不满、批评 | 理性温和,避免激化矛盾 | | 中性 | 提问、讨论、陈述事实(如"请问..."、"这个怎么用") | 正常语气回复,不加额外提示 |
| 负面 | 不满、质疑、批评(如"不好用"、"有问题" | 理性温和,避免激化矛盾 |
| 非常负面 | 攻击、辱骂、极端情绪(如"垃圾"、"骗子") | 非常温和理性,避免激化矛盾,展现理解和耐心 |
## 工作原理 ## 工作原理
1. 评论通过过滤检查后,调用AI对评论内容进行情感分析 1. 评论通过过滤检查后,调用AI对评论内容进行情感分析
2. AI 使用结构化输出(`OutputSpec.choice`)返回情感分类结果(POSITIVE / NEUTRAL / NEGATIVE 2. AI 使用结构化输出(`OutputSpec.choice`)返回情感分类结果(VERY_POSITIVE / POSITIVE / NEUTRAL / NEGATIVE / VERY_NEGATIVE
3. 如果情感分析失败(如AI不可用),默认降级为 NEUTRAL 3. 如果情感分析失败(如AI不可用),默认降级为 NEUTRAL
4. 情感结果传入 PromptBuilder,在生成Prompt时追加对应的语气提示 4. 情感结果传入 PromptBuilder,在生成Prompt时追加对应的语气提示
5. 情感结果同时记录在 `AiCommentReply``sentiment` 字段中 5. 情感结果同时记录在 `AiCommentReply``sentiment` 字段中
@@ -22,9 +24,11 @@
在AI回复日志页面,每条记录会显示情感标签: 在AI回复日志页面,每条记录会显示情感标签:
- 🟢 **正面** — 绿色标签 - 🟢 **非常正面**绿色标签
- 🟩 **正面** — 浅绿色标签
-**中性** — 灰色标签 -**中性** — 灰色标签
- 🔴 **负面** — 红色标签 - 🟥 **负面**红色标签
- 🔴 **非常负面** — 深红色标签
## 性能影响 ## 性能影响
@@ -47,6 +47,8 @@ public class CommentAiAutopilotPlugin extends BasePlugin {
.indexFunc(ext -> ext.getSpec().getSentiment())); .indexFunc(ext -> ext.getSpec().getSentiment()));
indexSpecs.add(IndexSpecs.<AiCommentReply, String>single("spec.published", String.class) indexSpecs.add(IndexSpecs.<AiCommentReply, String>single("spec.published", String.class)
.indexFunc(ext -> String.valueOf(ext.getSpec().getPublished()))); .indexFunc(ext -> String.valueOf(ext.getSpec().getPublished())));
indexSpecs.add(IndexSpecs.<AiCommentReply, String>single("spec.postKind", String.class)
.indexFunc(ext -> ext.getSpec().getPostKind()));
}); });
schemeManager.register(AiPersona.class); schemeManager.register(AiPersona.class);
@@ -33,6 +33,9 @@ public class AiCommentReply extends AbstractExtension {
@Schema(description = "关联文章Slug,用于生成文章链接") @Schema(description = "关联文章Slug,用于生成文章链接")
private String postSlug; private String postSlug;
@Schema(description = "关联内容类型: Post/SinglePage")
private String postKind;
@Schema(description = "AI回复内容") @Schema(description = "AI回复内容")
private String reply; private String reply;
@@ -525,6 +525,7 @@ public class AiReplyOrchestrator {
record.getSpec().setCommentId(context.commentId()); record.getSpec().setCommentId(context.commentId());
record.getSpec().setPostId(context.postId()); record.getSpec().setPostId(context.postId());
record.getSpec().setPostSlug(context.postSlug()); record.getSpec().setPostSlug(context.postSlug());
record.getSpec().setPostKind(context.postKind());
record.getSpec().setReply(""); record.getSpec().setReply("");
record.getSpec().setScore(0); record.getSpec().setScore(0);
record.getSpec().setStatus("PENDING"); record.getSpec().setStatus("PENDING");
@@ -10,6 +10,7 @@ import run.halo.app.content.ContentWrapper;
import run.halo.app.content.PostContentService; import run.halo.app.content.PostContentService;
import run.halo.app.core.extension.content.Comment; import run.halo.app.core.extension.content.Comment;
import run.halo.app.core.extension.content.Post; import run.halo.app.core.extension.content.Post;
import run.halo.app.core.extension.content.SinglePage;
import run.halo.app.core.extension.content.Reply; import run.halo.app.core.extension.content.Reply;
import run.halo.app.extension.ReactiveExtensionClient; import run.halo.app.extension.ReactiveExtensionClient;
@@ -113,7 +114,8 @@ public class ContextExtractor {
isAiConversation, isAiConversation,
formatPostDate(post), formatPostDate(post),
commentCount, commentCount,
"" "",
"Post"
)) ))
) )
) )
@@ -129,7 +131,47 @@ public class ContextExtractor {
isAiConversation, isAiConversation,
"", "",
0, 0,
"" "",
"Post"
));
}
if (subjectRef != null && "SinglePage".equals(subjectRef.getKind())) {
String postName = subjectRef.getName();
return client.fetch(SinglePage.class, postName)
.flatMap(singlePage -> getPostContent(postName)
.flatMap(content -> getCommentCount(comment.getMetadata().getName())
.map(commentCount -> new CommentContext(
comment.getMetadata().getName(),
postName,
singlePage.getSpec().getSlug(),
commentContent,
commentOwner,
singlePage.getSpec().getTitle(),
content,
null,
isAiConversation,
formatSinglePageDate(singlePage),
commentCount,
"",
"SinglePage"
))
)
)
.defaultIfEmpty(new CommentContext(
comment.getMetadata().getName(),
postName,
"",
commentContent,
commentOwner,
"",
"",
null,
isAiConversation,
"",
0,
"",
"SinglePage"
)); ));
} }
@@ -145,6 +187,7 @@ public class ContextExtractor {
isAiConversation, isAiConversation,
"", "",
0, 0,
"",
"" ""
)); ));
} }
@@ -179,7 +222,8 @@ public class ContextExtractor {
isAiConversation, isAiConversation,
formatPostDate(post), formatPostDate(post),
commentCount, commentCount,
history history,
"Post"
)) ))
) )
) )
@@ -196,7 +240,49 @@ public class ContextExtractor {
isAiConversation, isAiConversation,
"", "",
0, 0,
"" "",
"Post"
));
}
if (subjectRef != null && "SinglePage".equals(subjectRef.getKind())) {
String postName = subjectRef.getName();
return client.fetch(SinglePage.class, postName)
.flatMap(singlePage -> getPostContent(postName)
.flatMap(content -> getCommentCount(commentName)
.flatMap(commentCount -> historyMono
.map(history -> new CommentContext(
commentName,
postName,
singlePage.getSpec().getSlug(),
replyContent,
replyOwner,
singlePage.getSpec().getTitle(),
content,
replyName,
isAiConversation,
formatSinglePageDate(singlePage),
commentCount,
history,
"SinglePage"
))
)
)
)
.defaultIfEmpty(new CommentContext(
commentName,
postName,
"",
replyContent,
replyOwner,
"",
"",
replyName,
isAiConversation,
"",
0,
"",
"SinglePage"
)); ));
} }
@@ -213,7 +299,8 @@ public class ContextExtractor {
isAiConversation, isAiConversation,
"", "",
0, 0,
history history,
""
)); ));
} }
@@ -290,6 +377,18 @@ public class ContextExtractor {
return ""; return "";
} }
private String formatSinglePageDate(SinglePage singlePage) {
var publishTime = singlePage.getSpec().getPublishTime();
if (publishTime != null) {
return publishTime.toString().substring(0, 10);
}
var creationTimestamp = singlePage.getMetadata().getCreationTimestamp();
if (creationTimestamp != null) {
return creationTimestamp.toString().substring(0, 10);
}
return "";
}
private Mono<Integer> getCommentCount(String commentName) { private Mono<Integer> getCommentCount(String commentName) {
return client.list(Reply.class, return client.list(Reply.class,
reply -> commentName.equals(reply.getSpec().getCommentName()), reply -> commentName.equals(reply.getSpec().getCommentName()),
@@ -311,6 +410,7 @@ public class ContextExtractor {
boolean isAiConversation, boolean isAiConversation,
String postDate, String postDate,
int commentCount, int commentCount,
String conversationHistory String conversationHistory,
String postKind
) {} ) {}
} }
@@ -142,8 +142,10 @@ public class PromptBuilder {
return prompt; return prompt;
} }
String sentimentHint = switch (sentiment) { String sentimentHint = switch (sentiment) {
case "VERY_POSITIVE" -> "\n\n【情感提示】评论者情绪非常正面积极,请用热情洋溢的语气回复,表达真诚的感谢和共鸣。";
case "POSITIVE" -> "\n\n【情感提示】评论者情绪正面积极,请用热情友好的语气回复,可以表达感谢和共鸣。"; case "POSITIVE" -> "\n\n【情感提示】评论者情绪正面积极,请用热情友好的语气回复,可以表达感谢和共鸣。";
case "NEGATIVE" -> "\n\n【情感提示】评论者情绪偏负面,请用理性温和的语气回复,避免激化矛盾,展现理解和包容。"; case "NEGATIVE" -> "\n\n【情感提示】评论者情绪偏负面,请用理性温和的语气回复,避免激化矛盾,展现理解和包容。";
case "VERY_NEGATIVE" -> "\n\n【情感提示】评论者情绪非常负面,请用非常温和、理性的语气回复,避免任何可能激化矛盾的表达,展现充分的理解和耐心。";
default -> ""; default -> "";
}; };
return prompt + sentimentHint; return prompt + sentimentHint;
@@ -17,13 +17,17 @@ public class SentimentService {
} }
public record SentimentResult(String sentiment, double confidence) { public record SentimentResult(String sentiment, double confidence) {
public static final String VERY_POSITIVE = "VERY_POSITIVE";
public static final String POSITIVE = "POSITIVE"; public static final String POSITIVE = "POSITIVE";
public static final String NEUTRAL = "NEUTRAL"; public static final String NEUTRAL = "NEUTRAL";
public static final String NEGATIVE = "NEGATIVE"; public static final String NEGATIVE = "NEGATIVE";
public static final String VERY_NEGATIVE = "VERY_NEGATIVE";
} }
private static final List<String> CHOICES = List.of( private static final List<String> CHOICES = List.of(
SentimentResult.POSITIVE, SentimentResult.NEUTRAL, SentimentResult.NEGATIVE SentimentResult.VERY_POSITIVE, SentimentResult.POSITIVE,
SentimentResult.NEUTRAL, SentimentResult.NEGATIVE,
SentimentResult.VERY_NEGATIVE
); );
/** /**
@@ -31,7 +35,15 @@ public class SentimentService {
* ({@code OutputSpec.choice}) for reliable classification. * ({@code OutputSpec.choice}) for reliable classification.
*/ */
public Mono<SentimentResult> analyzeSentiment(String commentContent, String modelName) { public Mono<SentimentResult> analyzeSentiment(String commentContent, String modelName) {
String systemPrompt = "你是一个情感分析助手。请分析评论的情感倾向,只返回 POSITIVE、NEUTRAL 或 NEGATIVE 之一。"; String systemPrompt = "你是一个专业的情感分析助手。请根据以下标准分析评论的情感倾向\n"
+ "\n"
+ "- VERY_POSITIVE:非常正面,包含强烈的感谢、赞美或认同(如\"太棒了\"\"非常感谢\"\"写得太好了\"\n"
+ "- POSITIVE:正面,友好、肯定或支持的态度(如\"不错\"\"学习了\"\"支持\"\n"
+ "- NEUTRAL:中性,提问、讨论、陈述事实,无明显情感倾向(如\"请问...\"\"这个怎么用\"\"我觉得\"\n"
+ "- NEGATIVE:负面,不满、质疑或批评(如\"不好用\"\"有问题\"\"不太行\"\n"
+ "- VERY_NEGATIVE:非常负面,攻击、辱骂或极端负面情绪(如\"垃圾\"\"骗子\"\"太差了\"\n"
+ "\n"
+ "只返回 VERY_POSITIVE、POSITIVE、NEUTRAL、NEGATIVE 或 VERY_NEGATIVE 之一。";
String userPrompt = "分析以下评论的情感倾向:\n\n" + commentContent; String userPrompt = "分析以下评论的情感倾向:\n\n" + commentContent;
return aiFoundationClient.classify(systemPrompt, userPrompt, CHOICES, modelName) return aiFoundationClient.classify(systemPrompt, userPrompt, CHOICES, modelName)
+1 -1
View File
@@ -30,4 +30,4 @@ spec:
url: "https://github.com/sunny-335/plugin-comment-ai-autopilot/blob/main/LICENSE" url: "https://github.com/sunny-335/plugin-comment-ai-autopilot/blob/main/LICENSE"
settingName: "comment-ai-autopilot-settings" settingName: "comment-ai-autopilot-settings"
configMapName: "comment-ai-autopilot-configmap" configMapName: "comment-ai-autopilot-configmap"
version: "1.0.0-beta.3" version: "1.0.0-b26cea"
+277 -32
View File
@@ -11,27 +11,27 @@
<!-- Batch Operation Toolbar --> <!-- Batch Operation Toolbar -->
<div v-if="selectedNames.size > 0" class="m-4 mb-0 flex items-center gap-3 bg-blue-50 border border-blue-200 rounded-lg px-4 py-2.5"> <div v-if="selectedNames.size > 0" class="m-4 mb-0 flex items-center gap-3 bg-blue-50 border border-blue-200 rounded-lg px-4 py-2.5">
<span class="text-sm text-blue-700">已选择 {{ selectedNames.size }} </span> <span class="text-sm text-blue-700 font-medium">已选择 {{ selectedNames.size }} </span>
<button <button
class="text-xs px-3 py-1 rounded bg-green-600 text-white hover:bg-green-700 transition-colors" class="batch-btn batch-btn--approve"
@click="batchApprove" @click="batchApprove"
> >
批量通过 批量通过
</button> </button>
<button <button
class="text-xs px-3 py-1 rounded bg-orange-500 text-white hover:bg-orange-600 transition-colors" class="batch-btn batch-btn--reject"
@click="batchReject" @click="batchReject"
> >
批量拒绝 批量拒绝
</button> </button>
<button <button
class="text-xs px-3 py-1 rounded bg-red-600 text-white hover:bg-red-700 transition-colors" class="batch-btn batch-btn--delete"
@click="batchDelete" @click="batchDelete"
> >
批量删除 批量删除
</button> </button>
<button <button
class="text-xs text-gray-500 hover:text-gray-700 ml-auto" class="batch-btn batch-btn--cancel"
@click="selectedNames.clear(); selectAll = false" @click="selectedNames.clear(); selectAll = false"
> >
取消选择 取消选择
@@ -42,7 +42,7 @@
<div class="m-4 mb-0 flex items-center gap-3"> <div class="m-4 mb-0 flex items-center gap-3">
<select <select
v-model="filterStatus" v-model="filterStatus"
class="rounded-md border border-gray-300 pl-3 pr-8 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500" class="filter-select"
> >
<option value="">全部状态</option> <option value="">全部状态</option>
<option value="PASS">通过</option> <option value="PASS">通过</option>
@@ -52,23 +52,33 @@
</select> </select>
<select <select
v-model="filterSentiment" v-model="filterSentiment"
class="rounded-md border border-gray-300 pl-3 pr-8 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500" class="filter-select"
> >
<option value="">全部情感</option> <option value="">全部情感</option>
<option value="VERY_POSITIVE">非常正面</option>
<option value="POSITIVE">正面</option> <option value="POSITIVE">正面</option>
<option value="NEUTRAL">中性</option> <option value="NEUTRAL">中性</option>
<option value="NEGATIVE">负面</option> <option value="NEGATIVE">负面</option>
<option value="VERY_NEGATIVE">非常负面</option>
</select> </select>
<input <div class="relative flex-1 max-w-xs">
v-model="filterKeyword" <svg class="filter-search-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
type="text" <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
placeholder="搜索回复内容..." </svg>
class="rounded-md border border-gray-300 px-3 py-1.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500" <input
/> v-model="filterKeyword"
type="text"
placeholder="搜索回复内容..."
class="filter-input"
/>
</div>
<button <button
class="text-xs text-gray-500 hover:text-gray-700" class="filter-reset-btn"
@click="resetFilters" @click="resetFilters"
> >
<svg style="width:14px;height:14px" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
</svg>
重置 重置
</button> </button>
</div> </div>
@@ -112,26 +122,26 @@
<div class="flex items-center justify-between mb-3"> <div class="flex items-center justify-between mb-3">
<div class="flex items-center gap-1.5 flex-wrap"> <div class="flex items-center gap-1.5 flex-wrap">
<span <span
class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium" class="status-tag"
:class="getStatusClass(reply.spec.status)" :class="getStatusClass(reply.spec.status)"
> >
{{ getStatusLabel(reply.spec.status) }} {{ getStatusLabel(reply.spec.status) }}
</span> </span>
<span <span
class="inline-flex items-center px-2 py-0.5 rounded text-xs" class="status-tag"
:class="reply.spec.published ? 'bg-green-50 text-green-600' : 'bg-gray-50 text-gray-400'" :class="reply.spec.published ? 'status-tag--published' : 'status-tag--unpublished'"
> >
{{ reply.spec.published ? '已发布' : '未发布' }} {{ reply.spec.published ? '已发布' : '未发布' }}
</span> </span>
<span <span
v-if="reply.spec.isAiConversation" v-if="reply.spec.isAiConversation"
class="inline-flex items-center px-2 py-0.5 rounded text-xs bg-blue-50 text-blue-600" class="status-tag status-tag--conversation"
> >
对话 对话
</span> </span>
<span <span
v-if="reply.spec.sentiment" v-if="reply.spec.sentiment"
class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium" class="status-tag"
:class="getSentimentClass(reply.spec.sentiment)" :class="getSentimentClass(reply.spec.sentiment)"
> >
{{ getSentimentLabel(reply.spec.sentiment) }} {{ getSentimentLabel(reply.spec.sentiment) }}
@@ -151,11 +161,11 @@
<!-- Card footer: meta info + actions --> <!-- Card footer: meta info + actions -->
<div class="px-4 py-2.5 bg-gray-50 border-t border-gray-100 flex items-center justify-between"> <div class="px-4 py-2.5 bg-gray-50 border-t border-gray-100 flex items-center justify-between">
<div class="flex items-center gap-4 text-xs text-gray-400"> <div class="flex items-center gap-4 text-xs text-gray-400">
<span> <span class="flex items-center gap-1.5">
评分 <span :class="getScoreClass(reply.spec.score)" class="font-medium">{{ reply.spec.score }}</span> 评分 <span :class="getScoreClass(reply.spec.score)" class="font-semibold">{{ reply.spec.score }}</span>
<span class="text-gray-300 ml-0.5">{{ getScoreLabel(reply.spec.score) }}</span> <span class="score-label" :class="getScoreLabelClass(reply.spec.score)">{{ getScoreLabel(reply.spec.score) }}</span>
</span> </span>
<span v-if="reply.spec.postSlug" class="flex items-center gap-1"> <span v-if="reply.spec.postSlug && reply.spec.postKind === 'Post'" class="flex items-center gap-1">
文章 文章
<a <a
:href="getPostUrl(reply.spec.postSlug)" :href="getPostUrl(reply.spec.postSlug)"
@@ -167,6 +177,18 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg> </svg>
</span> </span>
<span v-else-if="reply.spec.postSlug && reply.spec.postKind === 'SinglePage'" class="flex items-center gap-1">
页面
<a
:href="getPageUrl(reply.spec.postSlug)"
target="_blank"
rel="noopener noreferrer"
class="text-blue-500 hover:text-blue-700 hover:underline"
>{{ reply.spec.postSlug }}</a>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</span>
<span v-if="reply.spec.retryCount > 0"> <span v-if="reply.spec.retryCount > 0">
重试 <span class="text-gray-600">{{ reply.spec.retryCount }}</span> 重试 <span class="text-gray-600">{{ reply.spec.retryCount }}</span>
</span> </span>
@@ -318,6 +340,7 @@ interface AiCommentReplyItem {
commentId: string commentId: string
postId: string postId: string
postSlug: string postSlug: string
postKind: string
reply: string reply: string
score: number score: number
status: string status: string
@@ -509,6 +532,14 @@ const getScoreClass = (score: number) => {
return "text-red-600" return "text-red-600"
} }
const getScoreLabelClass = (score: number) => {
if (score >= 85) return "score-label--excellent"
if (score >= 70) return "score-label--good"
if (score >= 50) return "score-label--average"
if (score > 0) return "score-label--poor"
return ""
}
const getScoreLabel = (score: number) => { const getScoreLabel = (score: number) => {
if (score >= 85) return "优秀" if (score >= 85) return "优秀"
if (score >= 70) return "良好" if (score >= 70) return "良好"
@@ -520,15 +551,15 @@ const getScoreLabel = (score: number) => {
const getStatusClass = (status: string) => { const getStatusClass = (status: string) => {
switch (status) { switch (status) {
case "PASS": case "PASS":
return "bg-green-100 text-green-700" return "status-tag--pass"
case "FAIL": case "FAIL":
return "bg-red-100 text-red-700" return "status-tag--fail"
case "PENDING": case "PENDING":
return "bg-gray-100 text-gray-700" return "status-tag--pending"
case "REJECTED": case "REJECTED":
return "bg-red-100 text-red-700" return "status-tag--rejected"
default: default:
return "bg-gray-100 text-gray-700" return "status-tag--pending"
} }
} }
@@ -549,23 +580,31 @@ const getStatusLabel = (status: string) => {
const getSentimentClass = (sentiment: string) => { const getSentimentClass = (sentiment: string) => {
switch (sentiment) { switch (sentiment) {
case "VERY_POSITIVE":
return "status-tag--very-positive"
case "POSITIVE": case "POSITIVE":
return "bg-green-50 text-green-600" return "status-tag--positive"
case "NEGATIVE": case "NEGATIVE":
return "bg-red-50 text-red-600" return "status-tag--negative"
case "VERY_NEGATIVE":
return "status-tag--very-negative"
case "NEUTRAL": case "NEUTRAL":
return "bg-gray-100 text-gray-600" return "status-tag--neutral-sentiment"
default: default:
return "bg-gray-100 text-gray-600" return "status-tag--neutral-sentiment"
} }
} }
const getSentimentLabel = (sentiment: string) => { const getSentimentLabel = (sentiment: string) => {
switch (sentiment) { switch (sentiment) {
case "VERY_POSITIVE":
return "非常正面"
case "POSITIVE": case "POSITIVE":
return "正面" return "正面"
case "NEGATIVE": case "NEGATIVE":
return "负面" return "负面"
case "VERY_NEGATIVE":
return "非常负面"
case "NEUTRAL": case "NEUTRAL":
return "中性" return "中性"
default: default:
@@ -582,6 +621,10 @@ const getPostUrl = (slug: string) => {
return `${window.location.origin}/archives/${slug}` return `${window.location.origin}/archives/${slug}`
} }
const getPageUrl = (slug: string) => {
return `${window.location.origin}/pages/${slug}`
}
/** /**
* Strip HTML tags for plain text display (card preview) * Strip HTML tags for plain text display (card preview)
*/ */
@@ -649,4 +692,206 @@ onMounted(fetchReplies)
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
overflow: hidden; overflow: hidden;
} }
/* ===== Batch Operation Buttons ===== */
.batch-btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 4px 12px;
font-size: 12px;
font-weight: 500;
border-radius: 6px;
border: none;
cursor: pointer;
transition: all 0.15s ease;
line-height: 1.5;
}
.batch-btn--approve {
background-color: #16a34a;
color: #fff;
}
.batch-btn--approve:hover {
background-color: #15803d;
}
.batch-btn--reject {
background-color: #f97316;
color: #fff;
}
.batch-btn--reject:hover {
background-color: #ea580c;
}
.batch-btn--delete {
background-color: #dc2626;
color: #fff;
}
.batch-btn--delete:hover {
background-color: #b91c1c;
}
.batch-btn--cancel {
background: none;
color: #6b7280;
margin-left: auto;
}
.batch-btn--cancel:hover {
color: #374151;
background: #f3f4f6;
}
/* ===== Filter Bar ===== */
.filter-select {
padding: 6px 32px 6px 12px;
font-size: 13px;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #f9fafb;
color: #374151;
outline: none;
cursor: pointer;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 8px center;
background-size: 16px;
transition: all 0.15s ease;
}
.filter-select:focus {
border-color: #3b82f6;
background-color: #fff;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.filter-search-icon {
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
color: #9ca3af;
pointer-events: none;
}
.filter-input {
width: 100%;
padding: 6px 12px 6px 34px;
font-size: 13px;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #f9fafb;
color: #374151;
outline: none;
transition: all 0.15s ease;
}
.filter-input:focus {
border-color: #3b82f6;
background-color: #fff;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.filter-input::placeholder {
color: #9ca3af;
}
.filter-reset-btn {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 6px 12px;
font-size: 13px;
color: #6b7280;
background: #f3f4f6;
border: 1px solid #e5e7eb;
border-radius: 8px;
cursor: pointer;
transition: all 0.15s ease;
}
.filter-reset-btn:hover {
color: #374151;
background: #e5e7eb;
}
/* ===== Status Tags ===== */
.status-tag {
display: inline-flex;
align-items: center;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 500;
line-height: 1.5;
}
.status-tag--pass {
background: #dcfce7;
color: #166534;
}
.status-tag--fail {
background: #fee2e2;
color: #991b1b;
}
.status-tag--pending {
background: #f3f4f6;
color: #374151;
}
.status-tag--rejected {
background: #fee2e2;
color: #991b1b;
}
.status-tag--published {
background: #dbeafe;
color: #1e40af;
}
.status-tag--unpublished {
background: #f3f4f6;
color: #9ca3af;
}
.status-tag--conversation {
background: #ede9fe;
color: #5b21b6;
}
/* Sentiment tags */
.status-tag--very-positive {
background: #dcfce7;
color: #166534;
}
.status-tag--positive {
background: #bbf7d0;
color: #15803d;
}
.status-tag--neutral-sentiment {
background: #f3f4f6;
color: #4b5563;
}
.status-tag--negative {
background: #fecaca;
color: #b91c1c;
}
.status-tag--very-negative {
background: #fee2e2;
color: #991b1b;
}
/* ===== Score Label ===== */
.score-label {
display: inline-flex;
align-items: center;
padding: 1px 6px;
border-radius: 4px;
font-size: 11px;
font-weight: 500;
margin-left: 4px;
}
.score-label--excellent {
background: #dcfce7;
color: #166534;
}
.score-label--good {
background: #dbeafe;
color: #1e40af;
}
.score-label--average {
background: #fef3c7;
color: #92400e;
}
.score-label--poor {
background: #fee2e2;
color: #991b1b;
}
</style> </style>