Jelajahi Sumber

✨ (term): 术语页显示协作者,编辑信息改用头像组与相对时间

v6 术语页(及共用 ArticleLayout 的阅读页)原来那行「<User/> edit at 2026-…Z」
换成 EditorsLine:antd Avatar.Group 叠放编辑者与协作者(co_editor,授权代写的
AI 模型)两个头像,后跟名字与 TimeShow(「编辑于 N 小时前」,悬停看完整时间),
新增文案 labels.edited-at。

library 百科词条页(/library/wiki/*)标题下加同样一行:WikiService::editors()
给出编辑者与协作者的头像、名字,updated_at 用 diffForHumans 显示,
新增文案 library.edited_at(en / zh-Hans / zh-Hant)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 4 jam lalu
induk
melakukan
41105211e6

+ 2 - 0
api-v13/app/Http/Controllers/Library/WikiController.php

@@ -162,6 +162,8 @@ HTML,
                 'edit_url' => config('mint.server.dashboard_base_path')."/workspace/term/{$term->guid}/edit",
                 'zh' => '编辑',
                 'other_versions' => $this->wiki->otherVersions($term),
+                'editors' => $this->wiki->editors($term),
+                'updated_at' => $term->updated_at,
             ]),
             'categories' => $this->categories(),
             'lang' => $lang,

+ 24 - 0
api-v13/app/Services/WikiService.php

@@ -34,6 +34,7 @@ class WikiService
     public function __construct(
         private readonly ChannelAbilityService $channels,
         private readonly MarkupService $markup,
+        private readonly UserService $users,
     ) {}
 
     /**
@@ -218,6 +219,29 @@ class WikiService
             ->all();
     }
 
+    /**
+     * 词条的编辑者与协作者(人类授权代写的 AI 模型),给词条头部的头像组用。
+     *
+     * @return list<array{name: string, username: string, avatar: string|null, initials: string, color: string}>
+     */
+    public function editors(DhammaTerm $term): array
+    {
+        $term->loadMissing([...UserService::eagerLoadActor(), UserService::eagerLoadAssistant('coEditor')]);
+
+        $people = [$this->users->actor($term->user, $term->aiModel)];
+        if ($term->coEditor) {
+            $people[] = $this->users->assistantProfile($term->coEditor);
+        }
+
+        return array_map(fn (array $p) => [
+            'name' => (string) $p['nickName'],
+            'username' => (string) $p['userName'],
+            'avatar' => ($p['avatar'] ?? '') ?: null,
+            'initials' => mb_substr((string) $p['nickName'], 0, 2),
+            'color' => TipitakaCatalogService::channelColor((string) $p['id']),
+        ], $people);
+    }
+
     /**
      * 同一个词的其它公开版本(其它 channel、其它语言),最多 $limit 条。摘要是纯文本。
      *

+ 28 - 0
api-v13/resources/css/components/card.css

@@ -193,6 +193,34 @@
     color: var(--tblr-body-color);
 }
 
+/* 编辑者头像组(编辑者 + 协作者叠放)与编辑时间 */
+.wiki-entry-editors {
+    display: flex;
+    flex-wrap: wrap;
+    align-items: center;
+    gap: 0.5rem;
+    margin-top: 0.5rem;
+    font-size: 0.85rem;
+    color: var(--tblr-secondary-color);
+}
+
+.wiki-avatar-group {
+    display: inline-flex;
+}
+
+.wiki-avatar-group__item + .wiki-avatar-group__item {
+    margin-left: -8px;
+}
+
+.wiki-avatar-group__item .author-avatar__img,
+.wiki-avatar-group__item .author-avatar__initials {
+    border: 2px solid var(--tblr-bg-surface, #fff);
+}
+
+.wiki-entry-editors__names {
+    color: var(--tblr-body-color);
+}
+
 /* ══════════════════════════════════════════
    八、精选卡片网格(tipitaka index / wiki index 共用)
    ══════════════════════════════════════════ */

+ 1 - 0
api-v13/resources/lang/en/library.php

@@ -92,6 +92,7 @@ return [
     'current_channel' => 'Current Channel',
     'created' => 'Created',
     'updated' => 'Updated',
+    'edited_at' => 'edited :time',
     'related_anthology' => 'Related Anthologies',
     'articles_suffix' => 'articles',
 

+ 1 - 0
api-v13/resources/lang/zh-Hans/library.php

@@ -92,6 +92,7 @@ return [
     'current_channel' => '当前频道',
     'created' => '创建',
     'updated' => '更新',
+    'edited_at' => '编辑于 :time',
     'related_anthology' => '相关文集',
     'articles_suffix' => '篇文章',
 

+ 1 - 0
api-v13/resources/lang/zh-Hant/library.php

@@ -92,6 +92,7 @@ return [
     'current_channel' => '目前頻道',
     'created' => '建立時間',
     'updated' => '更新時間',
+    'edited_at' => '編輯於 :time',
     'related_anthology' => '相關文集',
     'articles_suffix' => '篇文章',
 

+ 27 - 0
api-v13/resources/views/components/wiki/entry-header.blade.php

@@ -8,4 +8,31 @@
     <h1 class="wiki-entry-title">{{ $entry['meaning'] }}</h1>
     <div>{{ $entry['word'] }}</div>
 
+    {{-- 编辑者(+ 协作者,即授权代写的 AI 模型)与编辑时间 --}}
+    @if(! empty($entry['editors']) || ! empty($entry['updated_at']))
+    <div class="wiki-entry-editors">
+        @if(! empty($entry['editors']))
+        <span class="wiki-avatar-group">
+            @foreach($entry['editors'] as $person)
+            <span class="wiki-avatar-group__item" title="{{ $person['name'] }}">
+                <x-ui.author-avatar
+                    :avatar="$person['avatar']"
+                    :color="$person['color']"
+                    :initials="$person['initials']"
+                    size="sm" />
+            </span>
+            @endforeach
+        </span>
+        <span class="wiki-entry-editors__names">{{ collect($entry['editors'])->pluck('name')->join(' & ') }}</span>
+        @endif
+        @if(! empty($entry['updated_at']))
+        <time class="wiki-entry-editors__time"
+              datetime="{{ $entry['updated_at']->toIso8601ZuluString() }}"
+              title="{{ $entry['updated_at']->toDateTimeString() }}">
+            {{ __('library.edited_at', ['time' => $entry['updated_at']->locale(app()->getLocale())->diffForHumans()]) }}
+        </time>
+        @endif
+    </div>
+    @endif
+
 </div>

+ 2 - 2
dashboard-v6/src/components/article/TypeTerm.tsx

@@ -16,7 +16,6 @@ import TermShare from "../term/TermShare";
 import { QualityCtl } from "../template/Quality";
 import MarkupView from "../markup/MarkupView";
 import type { MarkupNode } from "../markup/types";
-import type { IUser } from "../../api/Auth";
 
 interface IWidget {
   id?: string;
@@ -113,7 +112,8 @@ const TypeTermWidget = ({
             nodes={term?.body as MarkupNode[] | undefined}
           />,
         ]}
-        editor={(term?.editor ?? undefined) as IUser | undefined}
+        editor={term?.editor}
+        coEditor={term?.co_editor}
         created_at={term?.created_at}
         updated_at={term?.updated_at}
         loading={loading}

+ 12 - 7
dashboard-v6/src/components/article/components/ArticleLayout.tsx

@@ -1,11 +1,11 @@
-import { Typography, Divider, Skeleton, Space, Flex } from "antd";
-import type { IStudio, IUser } from "../../../api/Auth";
+import { Typography, Divider, Skeleton, Flex } from "antd";
+import type { IStudio } from "../../../api/Auth";
 import VisibleObserver from "../../general/VisibleObserver";
 import MdView from "../../general/MdView";
 import type { JSX, ReactNode } from "react";
 import ArticleSkeleton from "./ArticleSkeleton";
 import ErrorResult from "../../general/ErrorResult";
-import User from "../../auth/User";
+import EditorsLine, { type IEditorBrief } from "../../auth/EditorsLine";
 
 const { Paragraph, Title, Text } = Typography;
 
@@ -29,7 +29,9 @@ export interface IArticleLayout {
   resList?: JSX.Element;
   created_at?: string;
   updated_at?: string;
-  editor?: IUser;
+  editor?: IEditorBrief | null;
+  /** 协作者(v3 的 co_editor):人类授权代写的 AI 模型 */
+  coEditor?: IEditorBrief | null;
   owner?: IStudio;
   loading?: boolean;
   errorCode?: number;
@@ -49,6 +51,7 @@ const ArticleLayout = ({
   html = [],
   nodes,
   editor,
+  coEditor,
   updated_at,
   resList,
   loading,
@@ -89,9 +92,11 @@ const ArticleLayout = ({
             <Paragraph ellipsis={{ rows: 2, expandable: true, symbol: "more" }}>
               {summary}
             </Paragraph>
-            <Space>
-              <User {...editor} /> edit at {updated_at}
-            </Space>
+            <EditorsLine
+              editor={editor}
+              coEditor={coEditor}
+              updatedAt={updated_at}
+            />
             <Divider />
           </Flex>
           {html

+ 71 - 0
dashboard-v6/src/components/auth/EditorsLine.tsx

@@ -0,0 +1,71 @@
+import { Avatar, Space, Tooltip, Typography } from "antd";
+import { useIntl } from "react-intl";
+import TimeShow from "../general/TimeShow";
+import { getAvatarColor } from "./utils";
+
+const { Text } = Typography;
+
+/** 只用到头像与名字,v2 的 IUser 与 v3 的 actor 摘要都满足 */
+export interface IEditorBrief {
+  nickName?: string;
+  userName?: string;
+  avatar?: string | null;
+}
+
+interface IWidget {
+  editor?: IEditorBrief | null;
+  /** 协作者:人类授权代写的 AI 模型(v3 的 co_editor) */
+  coEditor?: IEditorBrief | null;
+  updatedAt?: string;
+}
+
+/**
+ * 「编辑者(+ 协作者)· 编辑于 N 天前」一行。
+ * 两个头像用 antd 的头像组叠放,悬停显示名字。
+ */
+const EditorsLine = ({ editor, coEditor, updatedAt }: IWidget) => {
+  const intl = useIntl();
+  const people = [editor, coEditor].filter((p): p is IEditorBrief => !!p);
+  if (people.length === 0 && !updatedAt) {
+    return null;
+  }
+
+  return (
+    <Space size="small" wrap>
+      {people.length > 0 && (
+        <Avatar.Group size="small">
+          {people.map((p, i) => (
+            <Tooltip
+              key={i}
+              title={p.userName ? `${p.nickName}@${p.userName}` : p.nickName}
+            >
+              <Avatar
+                src={p.avatar || undefined}
+                style={
+                  p.avatar
+                    ? undefined
+                    : { backgroundColor: getAvatarColor(p.nickName) }
+                }
+              >
+                {p.nickName?.slice(0, 2)}
+              </Avatar>
+            </Tooltip>
+          ))}
+        </Avatar.Group>
+      )}
+      {people.length > 0 && (
+        <Text>{people.map((p) => p.nickName).join(" & ")}</Text>
+      )}
+      {updatedAt && (
+        <TimeShow
+          type="secondary"
+          showIcon={false}
+          title={intl.formatMessage({ id: "labels.edited-at" })}
+          updatedAt={updatedAt}
+        />
+      )}
+    </Space>
+  );
+};
+
+export default EditorsLine;

+ 1 - 0
dashboard-v6/src/locales/en-US/label.ts

@@ -25,6 +25,7 @@ const items = {
   "labels.first-course": "first course",
   "labels.updated-at": "updated at",
   "labels.created-at": "created at",
+  "labels.edited-at": "edited",
   "labels.recent-scan": "recent scan",
   "labels.icp": "ICP:",
   "labels.no.login": "not login",

+ 1 - 0
dashboard-v6/src/locales/zh-Hans/label.ts

@@ -25,6 +25,7 @@ const items = {
   "labels.first-course": "第一个课程",
   "labels.updated-at": "更新于",
   "labels.created-at": "创建于",
+  "labels.edited-at": "编辑于",
   "labels.recent-scan": "最近打开",
   "labels.icp": "ICP:",
   "labels.no.login": "尚未登录",

+ 1 - 0
dashboard-v6/src/locales/zh-Hant/label.ts

@@ -25,6 +25,7 @@ const items = {
   "labels.first-course": "第一個課程",
   "labels.updated-at": "更新於",
   "labels.created-at": "創建於",
+  "labels.edited-at": "編輯於",
   "labels.recent-scan": "最近開啟",
   "labels.icp": "ICP:",
   "labels.no.login": "尚未登入",