Просмотр исходного кода

feat(dashboard-v6): 讨论列表 AI 代写的话题显示授权人与模型两个头像

- 新增 DiscussionAuthors:有 co_editor 时用 antd Avatar.Group 并排显示授权人与模型,
  Tooltip 标明「授权人」「AI 协作者」;没有则仍是单个作者头像
- SeverityTag 跟随 severity 取值调整

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 4 дней назад
Родитель
Сommit
5921375c8c

+ 47 - 0
dashboard-v6/src/components/discussion/DiscussionAuthors.tsx

@@ -0,0 +1,47 @@
+import { Avatar, Tooltip } from "antd";
+
+import User from "../auth/User";
+import { getAvatarColor } from "../auth/utils";
+import type { IUser } from "../../api/Auth";
+
+interface IActor {
+  user: IUser;
+  role: string;
+}
+
+/** Avatar.Group 的子元素必须直接是 Avatar(Tooltip 不包额外 DOM),重叠样式才生效 */
+const ActorAvatar = ({ user, role }: IActor) => (
+  <Tooltip title={`${user.nickName}(${role})`}>
+    <Avatar
+      src={user.avatar}
+      style={
+        user.avatar
+          ? undefined
+          : { backgroundColor: getAvatarColor(user.nickName) }
+      }
+    >
+      {user.nickName?.slice(0, 2)}
+    </Avatar>
+  </Tooltip>
+);
+
+interface IWidget {
+  user: IUser;
+  coEditor?: IUser;
+}
+
+/**
+ * 讨论的作者头像。AI 凭人类授权代写时(有 co_editor),用 Avatar.Group 并排显示
+ * 授权人与模型两个头像;否则只显示作者一个。
+ */
+const DiscussionAuthors = ({ user, coEditor }: IWidget) =>
+  coEditor ? (
+    <Avatar.Group size="small">
+      <ActorAvatar user={user} role="授权人" />
+      <ActorAvatar user={coEditor} role="AI 协作者" />
+    </Avatar.Group>
+  ) : (
+    <User {...user} showName={false} />
+  );
+
+export default DiscussionAuthors;

+ 5 - 2
dashboard-v6/src/components/discussion/DiscussionListCard.tsx

@@ -6,7 +6,7 @@ import { get } from "../../request";
 
 
 import { type ActionType, ProList } from "@ant-design/pro-components";
 import { type ActionType, ProList } from "@ant-design/pro-components";
 import DiscussionCreate from "./DiscussionCreate";
 import DiscussionCreate from "./DiscussionCreate";
-import User from "../auth/User";
+import DiscussionAuthors from "./DiscussionAuthors";
 import type { IArticleListResponse } from "../../api/article";
 import type { IArticleListResponse } from "../../api/article";
 import { useAppSelector } from "../../hooks";
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { currentUser as _currentUser } from "../../reducers/current-user";
@@ -87,7 +87,10 @@ const DiscussionListCardWidget = ({
             render(_dom, entity, _index, _action, _schema) {
             render(_dom, entity, _index, _action, _schema) {
               return (
               return (
                 <>
                 <>
-                  <User {...entity.user} showName={false} />
+                  <DiscussionAuthors
+                    user={entity.user}
+                    coEditor={entity.coEditor}
+                  />
                 </>
                 </>
               );
               );
             },
             },

+ 1 - 1
dashboard-v6/src/components/discussion/SeverityTag.tsx

@@ -4,7 +4,7 @@ const COLORS: Record<string, string> = {
   error: "red",
   error: "red",
   urgent: "red",
   urgent: "red",
   warning: "orange",
   warning: "orange",
-  info: "blue",
+  suggestion: "blue",
   normal: "default",
   normal: "default",
 };
 };