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

✨ (dashboard-v6): 新增管理后台 /admin(管理功能迁移 + 阅读统计、AI 对话统计)

- 管理后台布局与路由:只有 root / administrator 能进
- 从 v4 迁来:API 状态、relation、nissaya 词尾、词典与偏好、用户、邀请、AI 模型
- 新增阅读统计、AI 对话统计(提问记录、评价、研究路径分布,路由枚举取自 OpenAPI 生成的类型)
- 中文简体、繁体、英文翻译;schema.d.ts 按当前规格重新生成

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 4 дней назад
Родитель
Сommit
0f65edcafc
53 измененных файлов с 5038 добавлено и 75 удалено
  1. 63 0
      dashboard-v6/documents/development/admin-stats.md
  2. 12 0
      dashboard-v6/documents/development/v6-todo-list.md
  3. 9 0
      dashboard-v6/src/Router.tsx
  4. 148 0
      dashboard-v6/src/api/admin.ts
  5. 43 0
      dashboard-v6/src/api/adminStats.ts
  6. 1376 75
      dashboard-v6/src/api/schema.d.ts
  7. 29 0
      dashboard-v6/src/components/admin/ApiGaugeCard.tsx
  8. 28 0
      dashboard-v6/src/components/admin/ApiStatCard.tsx
  9. 35 0
      dashboard-v6/src/components/admin/GrammarSelect.tsx
  10. 20 0
      dashboard-v6/src/components/admin/GrammarTags.tsx
  11. 44 0
      dashboard-v6/src/components/admin/TermCell.tsx
  12. 80 0
      dashboard-v6/src/components/stats/KpiCard.tsx
  13. 132 0
      dashboard-v6/src/features/admin-stats/AgentFeedbackTable.tsx
  14. 132 0
      dashboard-v6/src/features/admin-stats/AgentRunDrawer.tsx
  15. 158 0
      dashboard-v6/src/features/admin-stats/AgentRunTable.tsx
  16. 320 0
      dashboard-v6/src/features/admin-stats/AgentStats.tsx
  17. 350 0
      dashboard-v6/src/features/admin-stats/ReadingStats.tsx
  18. 54 0
      dashboard-v6/src/features/admin-stats/helpers.ts
  19. 52 0
      dashboard-v6/src/features/admin-stats/shared.tsx
  20. 32 0
      dashboard-v6/src/features/admin/ApiDashboard.tsx
  21. 48 0
      dashboard-v6/src/features/admin/DictStatistics.tsx
  22. 86 0
      dashboard-v6/src/features/admin/NissayaEndingEdit.tsx
  23. 117 0
      dashboard-v6/src/features/admin/NissayaEndingList.tsx
  24. 97 0
      dashboard-v6/src/features/admin/RelationEdit.tsx
  25. 103 0
      dashboard-v6/src/features/admin/RelationList.tsx
  26. 57 0
      dashboard-v6/src/features/admin/SystemModels.tsx
  27. 91 0
      dashboard-v6/src/features/admin/UserList.tsx
  28. 103 0
      dashboard-v6/src/features/admin/nissayaEndingColumns.tsx
  29. 130 0
      dashboard-v6/src/features/admin/relationColumns.tsx
  30. 73 0
      dashboard-v6/src/hooks/useAdmin.ts
  31. 87 0
      dashboard-v6/src/hooks/useAdminStats.ts
  32. 149 0
      dashboard-v6/src/layouts/admin/index.tsx
  33. 4 0
      dashboard-v6/src/locales/en-US.ts
  34. 139 0
      dashboard-v6/src/locales/en-US/admin-stats.ts
  35. 37 0
      dashboard-v6/src/locales/en-US/admin.ts
  36. 4 0
      dashboard-v6/src/locales/zh-Hans.ts
  37. 139 0
      dashboard-v6/src/locales/zh-Hans/admin-stats.ts
  38. 37 0
      dashboard-v6/src/locales/zh-Hans/admin.ts
  39. 4 0
      dashboard-v6/src/locales/zh-Hant.ts
  40. 139 0
      dashboard-v6/src/locales/zh-Hant/admin-stats.ts
  41. 37 0
      dashboard-v6/src/locales/zh-Hant/admin.ts
  42. 14 0
      dashboard-v6/src/pages/admin/ai-models.tsx
  43. 14 0
      dashboard-v6/src/pages/admin/api.tsx
  44. 14 0
      dashboard-v6/src/pages/admin/dictionary/index.tsx
  45. 14 0
      dashboard-v6/src/pages/admin/dictionary/preference.tsx
  46. 15 0
      dashboard-v6/src/pages/admin/invite.tsx
  47. 17 0
      dashboard-v6/src/pages/admin/nissaya-ending.tsx
  48. 14 0
      dashboard-v6/src/pages/admin/relation.tsx
  49. 14 0
      dashboard-v6/src/pages/admin/stats/ai.tsx
  50. 14 0
      dashboard-v6/src/pages/admin/stats/reading.tsx
  51. 14 0
      dashboard-v6/src/pages/admin/users/index.tsx
  52. 35 0
      dashboard-v6/src/pages/admin/users/show.tsx
  53. 61 0
      dashboard-v6/src/routes/adminRoutes.ts

+ 63 - 0
dashboard-v6/documents/development/admin-stats.md

@@ -0,0 +1,63 @@
+# 管理后台统计:口径与实现
+
+> `/admin/stats/reading`(阅读统计)与 `/admin/stats/ai`(AI 对话统计),仅 root / administrator 可见。
+> 后端:api-v13 `GET /api/v3/admin/reading-stats`、`/agent-stats`、`/agent-runs`、`/agent-runs/{run}`
+> (`App\Services\V3\ReadingStatsService`、`AgentStatsService`,中间件 `auth.v3` + `auth.v3.admin`)。
+> 前端:`src/api/adminStats.ts` → `src/hooks/useAdminStats.ts` → `src/features/admin-stats/*` → `src/pages/admin/stats/*`。
+
+## 共同约定
+
+- 时间范围是 **UTC 日** 的闭区间 `[from, to]`,缺省近 30 天,最长 366 天。
+- 每个指标都带「上一同长区间」的值(`previous`),前端算环比;上一区间是 0 时不显示环比。
+- 统计结果在后端缓存 10 分钟;提问列表与研究过程不缓存。
+- 每张卡片下方写数据来源表名,改口径时同步改卡片。
+
+## 阅读统计
+
+| 指标 | 口径 | 来源 |
+|---|---|---|
+| 活跃读者 | 区间内阅读记录有更新的去重**登录**用户。游客的阅读服务器看不到 | `recents` |
+| 日活 / 月活 | 区间最后一天的活跃读者 / 截至那天的 30 天活跃读者 | `recents` |
+| 打开章节 | 区间内有更新的阅读记录数。recents 按(用户, 章节)upsert,只记最后一次,所以不是逐次打开数 | `recents` |
+| 读经时长 | App 阅读器在前台、且 3 分钟内有翻读动作才计时;**Web 没有计时** | `reading_dailies` |
+| 章节浏览 | `views` 在区间内有更新的行(访客 × 章节),**含游客与搜索引擎爬虫**,只看趋势 | `views` |
+| 查词 | 登录用户经 v2 接口的 dict_lookup 请求 | `user_operation_logs` |
+| 热门章节 | 按去重读者数排序的前 10 个章节 | `recents` + `pali_texts` |
+| 三藏 / 根本·义注·复注分布 | 阅读记录按书归类;书的类别取挂在 `pali_texts` 章节行上的标签(sutta / vinaya / abhidhamma / añña,mūla / aṭṭhakathā / ṭīkā) | `recents` + `tag_maps` |
+| 读经时长分布 | 每人每天的读经秒数分桶 | `reading_dailies` |
+| 读经积分 | 发放总额、获积分人数、达每日上限的人·天、服务端按墙钟核减掉的比例 | `credit_ledger`、`reading_dailies` |
+
+**客户端区分**:`recents.param` 里 `client = mobile`(mobile 从 2026-10 起写)或 `mode = reading`(mobile 的老写法)算 App,其余算 Web
+(v4 网页写 `read` / `edit` / `wbw`)。
+
+## AI 对话统计
+
+| 指标 | 口径 | 来源 |
+|---|---|---|
+| 提问数 | 区间内开始的提问(`started_at`) | `agent_runs` |
+| 提问的人 | 登录用户按账号、游客按设备匿名 id 去重 | `agent_threads.account` |
+| 响应耗时 | 成功(status=ok)提问的 `latency_ms` P50 / P95 | `agent_runs` |
+| 拦截 / 出错 | status = denied(额度不足)与 error(已退积分);另列「未查额度放行」次数(2026-11 起 agent 不再放行,mint 不可用时回网络错误并记 denied;这一项只剩历史数据) | `agent_runs`、`agent_run_steps`(event · quota) |
+| 每日提问 | 按研究路径(question / term / passage / chat)堆叠 | `agent_runs.route` |
+| 工具调用 Top | 次数、出错数、平均耗时 | `agent_run_steps`(kind = tool) |
+| 积分流水 | 赠送 / 积分消耗、出错退回、读经 / 编辑发放、手工调整 | `credit_ledger` |
+| token / 可用于改进 | token 合计;`improve = true` 的提问占比 | `agent_runs` |
+| 用户评价 | 点赞 / 点踩数(按评价的 `created_at`),评价覆盖率=评价数 ÷ 提问数;点踩原因分布 | `agent_feedback` |
+
+**提问记录**:列表与研究过程(回答、证据全文、计划、全部步骤)对 root / administrator 都可见;游客只显示设备匿名 id 与 IP。
+回答与证据按纯文本显示,不渲染 HTML。
+
+**用户评价审阅**(与提问记录同一张卡片的第二个页签):最新的在前,可按赞 / 踩、标签或原因筛;每条带对应提问和
+路由,点一行打开那次提问的研究过程。`run_id` 为空表示评价先到、提问还没入库。不显示账号身份。
+
+后台不做回答质量评估:要评估就用 wikipali-plugins 的 `wikipali admin digest --full` 把回答与证据拉给 agent 评(agent-poc `improve-answers` 技能)。
+
+## 索引
+
+`2026_10_24_*_add_admin_stats_indexes`:已有表 `user_operation_logs (op_type, created_at)`、`views (updated_at)`,
+普通的事务内建索引。`agent_runs` 是新表,`started_at`、`assistant_message_id` 的索引直接写在它的 create 迁移里。
+
+## 以后可以加
+
+- Web 端读经计时(目前只有 App)。
+- 阅读的次日 / 7 日留存(需要逐次阅读事件,recents 只记最后一次,做不了)。

+ 12 - 0
dashboard-v6/documents/development/v6-todo-list.md

@@ -56,3 +56,15 @@
 - [x] "para"
 - [ ] "series"
 - [ ] "cs-para"
+
+### 5️⃣ Admin 模块(`/admin`,仅 root / administrator)
+
+- [x] `/admin/api/dashboard`=>`admin/api`
+- [x] `/admin/relation/list`=>`admin/relation`
+- [x] `/admin/nissaya-ending/list`(含 `/list/:relation`)=>`admin/nissaya-ending`(`/:relation`)
+- [x] `/admin/dictionary/list`=>`admin/dictionary`
+- [x] `/admin/dictionary/preference`=>`admin/dictionary/preference`
+- [x] `/admin/users/list`、`/admin/users/show/:id`=>`admin/users`、`admin/users/:id`
+- [x] `/admin/invite/list`=>`admin/invite`
+- [x] `/admin/ai/list`=>`admin/ai-models`
+- [x] 新增:`admin/stats/reading` 阅读统计、`admin/stats/ai` AI 对话统计

+ 9 - 0
dashboard-v6/src/Router.tsx

@@ -21,10 +21,12 @@ import dictionaryRoutes from "./routes/dictionaryRoutes";
 import courseRoutes from "./routes/courseRoutes";
 import nissayaRoutes from "./routes/nissayaRoutes";
 import discussionRoutes from "./routes/discussionRoutes";
+import adminRoutes from "./routes/adminRoutes";
 
 const RootLayout = lazy(() => import("./layouts/Root"));
 const AnonymousLayout = lazy(() => import("./layouts/anonymous"));
 const DashboardLayout = lazy(() => import("./layouts/dashboard"));
+const AdminLayout = lazy(() => import("./layouts/admin"));
 const WorkspaceLayout = lazy(() => import("./layouts/workspace"));
 const TestLayout = lazy(() => import("./layouts/test"));
 
@@ -83,6 +85,13 @@ const router = createBrowserRouter(
           Component: DashboardLayout,
           children: [{ index: true, Component: DashboardIndex }],
         },
+        {
+          // 管理后台:只有 root / administrator(layouts/admin 里判断)
+          path: "admin",
+          Component: AdminLayout,
+          handle: { id: "admin.home", crumb: "admin" },
+          children: adminRoutes,
+        },
         {
           path: "workspace",
           Component: WorkspaceLayout,

+ 148 - 0
dashboard-v6/src/api/admin.ts

@@ -0,0 +1,148 @@
+// src/api/admin.ts
+//
+// 管理后台(/admin)用到的 v2 接口。自 dashboard-v4 的 pages/admin 迁来,
+// 接口与 v4 完全一致,v2 一律走 request.ts(见 mint 根目录 CLAUDE.md「前端 dashboard-v6」)。
+
+import { delete_, get, post, put } from "../request";
+import type { IDeleteResponse } from "./group";
+import type { IFrom, IRelationRequest, IRelationListResponse, IRelationResponse } from "./relation";
+import type { IUserListResponse2 } from "./Auth";
+import type { IAiModelListResponse, IAiModelResponse, IAiModelSystem } from "./ai";
+import type { IUser } from "./Auth";
+
+/* ---------------------------------------------------------------- relation */
+
+export const fetchRelationList = (query: string) =>
+  get<IRelationListResponse>(`/api/v2/relation?view=a${query}`);
+
+export const fetchRelation = (id: string) => get<IRelationResponse>(`/api/v2/relation/${id}`);
+
+export const saveRelation = (data: IRelationRequest, id?: string) =>
+  id
+    ? put<IRelationRequest, IRelationResponse>(`/api/v2/relation/${id}`, data)
+    : post<IRelationRequest, IRelationResponse>(`/api/v2/relation`, data);
+
+export const deleteRelation = (id: string) => delete_<IDeleteResponse>(`/api/v2/relation/${id}`);
+
+export const RELATION_IMPORT_URL = "/api/v2/relation-import";
+export const RELATION_EXPORT_URL = "/api/v2/relation-export";
+
+/* ---------------------------------------------------------- nissaya ending */
+
+export interface INissayaEndingRequest {
+  id?: string;
+  ending?: string;
+  lang?: string;
+  relation?: string;
+  case?: string;
+  from?: IFrom | null;
+  editor?: IUser;
+  count?: number;
+  term_id?: string;
+  term_channel?: string;
+  updated_at?: string;
+  created_at?: string;
+}
+export interface INissayaEndingListResponse {
+  ok: boolean;
+  message: string;
+  data: {
+    rows: INissayaEndingRequest[];
+    count: number;
+  };
+}
+export interface INissayaEndingResponse {
+  ok: boolean;
+  message: string;
+  data: INissayaEndingRequest;
+}
+/** 表格 / 表单里的一行(from 拆成 fromCase、fromSpell 两个表单项)。 */
+export interface INissayaEnding {
+  sn?: number;
+  id?: string;
+  ending?: string;
+  lang?: string;
+  relation?: string;
+  case?: string;
+  from?: IFrom | null;
+  fromCase?: string[];
+  fromSpell?: string;
+  count?: number;
+  termId?: string;
+  termChannel?: string;
+  updated_at?: string;
+}
+
+export const fetchNissayaEndingList = (query: string) =>
+  get<INissayaEndingListResponse>(`/api/v2/nissaya-ending?view=a${query}`);
+
+export const fetchNissayaEnding = (id: string) =>
+  get<INissayaEndingResponse>(`/api/v2/nissaya-ending/${id}`);
+
+export const saveNissayaEnding = (data: INissayaEndingRequest, id?: string) =>
+  id
+    ? put<INissayaEndingRequest, INissayaEndingResponse>(`/api/v2/nissaya-ending/${id}`, data)
+    : post<INissayaEndingRequest, INissayaEndingResponse>(`/api/v2/nissaya-ending`, data);
+
+export const deleteNissayaEnding = (id: string) =>
+  delete_<IDeleteResponse>(`/api/v2/nissaya-ending/${id}`);
+
+export const NISSAYA_ENDING_IMPORT_URL = "/api/v2/nissaya-ending-import";
+export const NISSAYA_ENDING_EXPORT_URL = "/api/v2/nissaya-ending-export";
+
+/* -------------------------------------------------------------------- users */
+
+/** 全站用户列表(管理员视图)。query 以 & 开头。 */
+export const fetchUserList = (query: string) =>
+  get<IUserListResponse2>(`/api/v2/user?view=all&order=created_at&dir=desc${query}`);
+
+/* --------------------------------------------------------------- dictionary */
+
+export interface IDictStatistic {
+  key: string;
+  title: string;
+  count: number;
+  vocabulary: number;
+  parent: number;
+}
+interface IDictStatisticResponse {
+  ok: boolean;
+  message: string;
+  data: IDictStatistic[];
+}
+
+export const fetchDictStatistic = () => get<IDictStatisticResponse>("/api/v2/dict-statistic");
+
+/* -------------------------------------------------------------- AI 系统模型 */
+
+/** 可选模型(chat 视图下全站可用的模型)。 */
+export const fetchChatModels = () => get<IAiModelListResponse>("/api/v2/ai-model?view=chat");
+
+/** 保存某一类用途(wbw / chat / summarize)的系统模型列表。 */
+export const saveSystemModels = (view: string, models: string[]) =>
+  post<IAiModelSystem, IAiModelResponse>("/api/v2/system-model", { view, models });
+
+/* -------------------------------------------------------------- API 监控 */
+
+export interface IApiStatPoint {
+  date: string;
+  value: number;
+}
+interface IApiStatResponse {
+  ok: boolean;
+  message: string;
+  data: IApiStatPoint[];
+}
+interface IApiAverageResponse {
+  ok: boolean;
+  message: string;
+  data: number;
+}
+export type TApiStatItem = "average" | "count" | "delay";
+
+/** 近 10 分钟 / 小时的接口统计序列(v4 原样:PUT /v2/api/10)。 */
+export const fetchApiStat = (item: TApiStatItem, api = "all") =>
+  put<{ api: string; item: string }, IApiStatResponse>("/api/v2/api/10", { api, item });
+
+/** 当前平均响应时间(毫秒)。 */
+export const fetchApiAverage = () => get<IApiAverageResponse>("/api/v2/api/10?item=average");

+ 43 - 0
dashboard-v6/src/api/adminStats.ts

@@ -0,0 +1,43 @@
+// src/api/adminStats.ts
+//
+// 管理后台统计(v3,仅 root / administrator):阅读统计、AI 对话统计、提问与研究过程。
+// 类型全部从 OpenAPI 规格生成(schema.d.ts),这里不手写字段。
+import { api, unwrap } from "./client";
+import type { paths } from "./schema";
+
+type Json<P extends keyof paths, M extends "get"> = paths[P][M] extends {
+  responses: { 200: { content: { "application/json": infer B } } };
+}
+  ? B
+  : never;
+
+export type ReadingStats = NonNullable<Json<"/v3/admin/reading-stats", "get">["data"]>;
+export type AgentStats = NonNullable<Json<"/v3/admin/agent-stats", "get">["data"]>;
+export type AgentRunList = Json<"/v3/admin/agent-runs", "get">;
+export type AgentRun = NonNullable<AgentRunList["data"]>[number];
+/** 研究路径枚举,来自 OpenAPI(mint AgentRun::ROUTES)。 */
+export type AgentRoute = NonNullable<AgentRun["route"]>;
+export type AgentRunDetail = NonNullable<Json<"/v3/admin/agent-runs/{run}", "get">["data"]>;
+
+export type AgentFeedbackList = Json<"/v3/admin/agent-feedback", "get">;
+export type AgentFeedbackItem = NonNullable<AgentFeedbackList["data"]>[number];
+export type AgentFeedbackQuery = NonNullable<paths["/v3/admin/agent-feedback"]["get"]["parameters"]["query"]>;
+
+export type ReadingStatsQuery = NonNullable<paths["/v3/admin/reading-stats"]["get"]["parameters"]["query"]>;
+export type AgentStatsQuery = NonNullable<paths["/v3/admin/agent-stats"]["get"]["parameters"]["query"]>;
+export type AgentRunQuery = NonNullable<paths["/v3/admin/agent-runs"]["get"]["parameters"]["query"]>;
+
+export const getReadingStats = async (query: ReadingStatsQuery): Promise<ReadingStats> =>
+  unwrap(await api.GET("/v3/admin/reading-stats", { params: { query } })).data as ReadingStats;
+
+export const getAgentStats = async (query: AgentStatsQuery): Promise<AgentStats> =>
+  unwrap(await api.GET("/v3/admin/agent-stats", { params: { query } })).data as AgentStats;
+
+export const getAgentRuns = async (query: AgentRunQuery): Promise<AgentRunList> =>
+  unwrap(await api.GET("/v3/admin/agent-runs", { params: { query } }));
+
+export const getAgentRun = async (run: string): Promise<AgentRunDetail> =>
+  unwrap(await api.GET("/v3/admin/agent-runs/{run}", { params: { path: { run } } })).data as AgentRunDetail;
+
+export const getAgentFeedback = async (query: AgentFeedbackQuery): Promise<AgentFeedbackList> =>
+  unwrap(await api.GET("/v3/admin/agent-feedback", { params: { query } }));

Разница между файлами не показана из-за своего большого размера
+ 1376 - 75
dashboard-v6/src/api/schema.d.ts


+ 29 - 0
dashboard-v6/src/components/admin/ApiGaugeCard.tsx

@@ -0,0 +1,29 @@
+import { Gauge } from "@ant-design/plots";
+import { StatisticCard } from "@ant-design/pro-components";
+import type { ReactNode } from "react";
+
+interface IWidget {
+  title?: ReactNode;
+  /** 当前平均响应时间(毫秒) */
+  delay: number;
+  /** 量程上限(毫秒) */
+  max?: number;
+}
+
+/** 平均响应时间仪表盘:绿 → 黄 → 红。 */
+const ApiGaugeCard = ({ title, delay, max = 5000 }: IWidget) => (
+  <StatisticCard
+    style={{ maxWidth: 400 }}
+    statistic={{ title, value: delay, suffix: "/ ms" }}
+    chart={
+      <Gauge
+        height={260}
+        data={{ target: Math.min(delay, max), total: max, thresholds: [max * 0.3, max * 0.6, max] }}
+        scale={{ color: { range: ["#30BF78", "#FAAD14", "#F4664A"] } }}
+        legend={false}
+      />
+    }
+  />
+);
+
+export default ApiGaugeCard;

+ 28 - 0
dashboard-v6/src/components/admin/ApiStatCard.tsx

@@ -0,0 +1,28 @@
+import { Column } from "@ant-design/plots";
+import { StatisticCard } from "@ant-design/pro-components";
+import type { ReactNode } from "react";
+import type { IApiStatPoint } from "../../api/admin";
+
+interface IWidget {
+  title?: ReactNode;
+  data: IApiStatPoint[];
+  suffix?: string;
+}
+
+/** 接口统计序列:标题 + 柱状图(API 监控页)。 */
+const ApiStatCard = ({ title, data, suffix = "/ ms" }: IWidget) => (
+  <StatisticCard
+    statistic={{ title, value: "", suffix }}
+    chart={
+      <Column
+        data={data}
+        xField="date"
+        yField="value"
+        height={300}
+        axis={{ x: { labelAutoHide: true, labelAutoRotate: false } }}
+      />
+    }
+  />
+);
+
+export default ApiStatCard;

+ 35 - 0
dashboard-v6/src/components/admin/GrammarSelect.tsx

@@ -0,0 +1,35 @@
+import { ProFormSelect } from "@ant-design/pro-components";
+import { useIntl } from "react-intl";
+
+/** 语法关系、Nissaya 语尾表单里可选的语法标记。 */
+const GRAMMAR_TAGS = [
+  "n", "ti", "v", "v:ind", "ind", "sg", "pl", "nom", "acc", "gen", "dat", "inst", "voc", "abl", "loc",
+  "base", "imp", "opt", "pres", "aor", "fut", "1p", "2p", "3p", "prp", "pp", "grd", "fpp", "vdn", "ger",
+  "inf", "adj", "pron", "caus", "num", "adv", "conj", "pre", "suf", "ti:base", "n:base", "v:base",
+];
+
+interface IWidget {
+  name: string;
+  hidden?: boolean;
+}
+
+/** 多选语法标记(可输入自定义值)。 */
+const GrammarSelect = ({ name, hidden = false }: IWidget) => {
+  const intl = useIntl();
+  return (
+    <ProFormSelect
+      hidden={hidden}
+      options={GRAMMAR_TAGS.map((item) => ({
+        value: item,
+        label: intl.formatMessage({ id: `dict.fields.type.${item}.label`, defaultMessage: item }),
+      }))}
+      fieldProps={{ mode: "tags" }}
+      width="md"
+      name={name}
+      allowClear={false}
+      label={intl.formatMessage({ id: "forms.fields.case.label" })}
+    />
+  );
+};
+
+export default GrammarSelect;

+ 20 - 0
dashboard-v6/src/components/admin/GrammarTags.tsx

@@ -0,0 +1,20 @@
+import { Tag, Tooltip } from "antd";
+import { useIntl } from "react-intl";
+import type { IFrom } from "../../api/relation";
+
+/** 「拼写 + 语法标记」的只读展示(关系表、语尾表的 from / to 列)。 */
+const GrammarTags = ({ value }: { value?: IFrom | null }) => {
+  const intl = useIntl();
+  return (
+    <>
+      {value?.spell}
+      {value?.case?.map((item) => (
+        <Tooltip title={item} key={item}>
+          <Tag>{intl.formatMessage({ id: `dict.fields.type.${item}.label`, defaultMessage: item })}</Tag>
+        </Tooltip>
+      ))}
+    </>
+  );
+};
+
+export default GrammarTags;

+ 44 - 0
dashboard-v6/src/components/admin/TermCell.tsx

@@ -0,0 +1,44 @@
+import { Button } from "antd";
+import { PlusOutlined, TranslationOutlined } from "@ant-design/icons";
+import type { ITerm } from "../../api/Term";
+import TermModal from "../term/TermModal";
+
+/** 术语译名:已有术语点开编辑,没有就「新建」。 */
+const TermCell = ({
+  term,
+  word,
+  channelId,
+  reload,
+  createLabel,
+}: {
+  term?: ITerm;
+  word?: string;
+  channelId?: string;
+  reload: () => void;
+  createLabel: string;
+}) =>
+  term ? (
+    <TermModal
+      trigger={
+        <Button type="link" icon={<TranslationOutlined />}>
+          {term.meaning}
+        </Button>
+      }
+      id={term.id}
+      channelId={channelId}
+      onUpdate={reload}
+    />
+  ) : channelId && word ? (
+    <TermModal
+      trigger={
+        <Button type="link" icon={<PlusOutlined />}>
+          {createLabel}
+        </Button>
+      }
+      word={word}
+      channelId={channelId}
+      onUpdate={reload}
+    />
+  ) : null;
+
+export default TermCell;

+ 80 - 0
dashboard-v6/src/components/stats/KpiCard.tsx

@@ -0,0 +1,80 @@
+// src/components/stats/KpiCard.tsx
+/**
+ * 统计看板的指标卡:标题(可带说明)、主数字、迷你图、与上一同长区间的对比、底部补充、数据来源。
+ *
+ * 纯 UI:只吃 props,不知道是什么业务。基于 pro-components 的 StatisticCard。
+ * `change` 是相对上一区间的变化比例(0.084 = +8.4%),null 表示没有可比数据;
+ * `inverse` 为 true 时下降算好事(耗时、出错率),颜色反过来。
+ */
+import type { ReactNode } from "react";
+import { StatisticCard } from "@ant-design/pro-components";
+import { Typography } from "antd";
+import { CaretDownOutlined, CaretUpOutlined } from "@ant-design/icons";
+
+export interface KpiCardProps {
+  title: ReactNode;
+  tip?: string;
+  value: number | string | null;
+  suffix?: ReactNode;
+  precision?: number;
+  change?: number | null;
+  inverse?: boolean;
+  changeLabel?: ReactNode;
+  chart?: ReactNode;
+  footer?: ReactNode;
+  source?: ReactNode;
+  loading?: boolean;
+}
+
+const KpiCard = ({
+  title,
+  tip,
+  value,
+  suffix,
+  precision,
+  change,
+  inverse,
+  changeLabel,
+  chart,
+  footer,
+  source,
+  loading,
+}: KpiCardProps) => {
+  const good = change == null ? undefined : inverse ? change <= 0 : change >= 0;
+  return (
+    <StatisticCard
+      loading={loading}
+      title={title}
+      tooltip={tip}
+      statistic={{
+        value: value ?? "—",
+        suffix: value == null ? undefined : suffix,
+        precision,
+        description:
+          change == null ? undefined : (
+            <span style={{ fontSize: 12 }}>
+              {changeLabel}{" "}
+              <span style={{ color: good ? "#52c41a" : "#ff4d4f", fontVariantNumeric: "tabular-nums" }}>
+                {change >= 0 ? <CaretUpOutlined /> : <CaretDownOutlined />} {Math.abs(change * 100).toFixed(1)}%
+              </span>
+            </span>
+          ),
+      }}
+      chart={chart ? <div style={{ height: 46 }}>{chart}</div> : undefined}
+      footer={
+        <div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
+          {footer ? (
+            <div style={{ display: "flex", flexWrap: "wrap", gap: 12, fontSize: 12 }}>{footer}</div>
+          ) : null}
+          {source ? (
+            <Typography.Text type="secondary" style={{ fontSize: 12 }}>
+              {source}
+            </Typography.Text>
+          ) : null}
+        </div>
+      }
+    />
+  );
+};
+
+export default KpiCard;

+ 132 - 0
dashboard-v6/src/features/admin-stats/AgentFeedbackTable.tsx

@@ -0,0 +1,132 @@
+// src/features/admin-stats/AgentFeedbackTable.tsx
+/**
+ * 用户评价审阅:最新的在前,可按赞 / 踩、标签或原因、有无文字说明筛选。
+ * 每条带对应提问的摘要,点一行看研究过程。
+ * 数据来自 GET /v3/admin/agent-feedback(不含账号身份)。
+ */
+import { useState } from "react";
+import { Space, Table, Tag, Tooltip, Typography } from "antd";
+import type { ColumnsType } from "antd/es/table";
+import { DislikeFilled, LikeFilled } from "@ant-design/icons";
+import dayjs from "dayjs";
+import type { AgentFeedbackItem } from "../../api/adminStats";
+import { useAgentFeedback } from "../../hooks/useAdminStats";
+import AgentRunDrawer from "./AgentRunDrawer";
+import { useT } from "./helpers";
+
+const UP_TAGS = ["accurate", "useful_citations", "clear", "inspiring"];
+const DOWN_REASONS = ["citation_wrong", "missed", "off_topic", "incorrect", "too_long", "too_academic", "slow", "other"];
+
+type Filters = { rating?: 1 | -1; tag?: string };
+
+const AgentFeedbackTable = () => {
+  const t = useT();
+  const [page, setPage] = useState(1);
+  const [filters, setFilters] = useState<Filters>({});
+  const [runId, setRunId] = useState<string | null>(null);
+  const { data, loading } = useAgentFeedback({
+    page,
+    per_page: 20,
+    ...(filters.rating ? { "filter[rating]": String(filters.rating) as "1" | "-1" } : {}),
+    ...(filters.tag ? { "filter[tag]": filters.tag } : {}),
+  });
+
+  const columns: ColumnsType<AgentFeedbackItem> = [
+    {
+      title: t("admin.stats.runs.time"),
+      dataIndex: "updated_at",
+      width: 120,
+      render: (v?: string) => (v ? dayjs(v).format("MM-DD HH:mm") : "—"),
+    },
+    {
+      title: t("admin.stats.feedback.rating"),
+      dataIndex: "rating",
+      width: 80,
+      filters: [
+        { value: 1, text: t("admin.stats.feedback.up") },
+        { value: -1, text: t("admin.stats.feedback.down") },
+      ],
+      filterMultiple: false,
+      render: (v: number, r) => (
+        <Space size={4}>
+          {v > 0 ? <LikeFilled style={{ color: "#52c41a" }} /> : <DislikeFilled style={{ color: "#ff4d4f" }} />}
+          {r.asked ? (
+            <Tooltip title={t("admin.stats.feedback.asked.tip")}>
+              <Tag>{t("admin.stats.feedback.asked")}</Tag>
+            </Tooltip>
+          ) : null}
+        </Space>
+      ),
+    },
+    {
+      title: t("admin.stats.feedback.tags"),
+      dataIndex: "tags",
+      width: 260,
+      filters: [...UP_TAGS, ...DOWN_REASONS].map((v) => ({ value: v, text: t(`admin.stats.feedback.tag.${v}`) })),
+      filterMultiple: false,
+      render: (tags: string[] | undefined, r) => (
+        <div>
+          <Space size={4} wrap>
+            {(tags ?? []).map((tag) => (
+              <Tag key={tag} color={r.rating && r.rating > 0 ? "green" : "volcano"}>
+                {t(`admin.stats.feedback.tag.${tag}`)}
+              </Tag>
+            ))}
+          </Space>
+          {r.comment ? (
+            <Typography.Paragraph style={{ margin: "4px 0 0", fontSize: 12 }} ellipsis={{ rows: 2, tooltip: r.comment }}>
+              {r.comment}
+            </Typography.Paragraph>
+          ) : null}
+        </div>
+      ),
+    },
+    {
+      title: t("admin.stats.runs.question"),
+      dataIndex: "question",
+      ellipsis: true,
+      render: (v?: string | null) => v ?? <Typography.Text type="secondary">{t("admin.stats.feedback.no_run")}</Typography.Text>,
+    },
+    {
+      title: t("admin.stats.runs.route"),
+      dataIndex: "route",
+      width: 110,
+      render: (v?: string | null, r?: AgentFeedbackItem) => (r?.run_id ? t(`admin.stats.route.${v ?? "none"}`) : null),
+    },
+    { title: t("admin.stats.runs.account"), dataIndex: "account_type", width: 80, render: (v: string) => t(`admin.stats.account.${v}`) },
+    { title: t("admin.stats.runs.client"), dataIndex: "client", width: 80 },
+  ];
+
+  return (
+    <>
+      <Table<AgentFeedbackItem>
+        size="small"
+        rowKey="id"
+        columns={columns}
+        dataSource={data?.data ?? []}
+        loading={loading}
+        scroll={{ x: 1000 }}
+        pagination={{ current: page, pageSize: 20, total: data?.meta?.total ?? 0, showSizeChanger: false, onChange: setPage }}
+        onChange={(_, f, __, extra) => {
+          // 翻页也会触发 onChange:只在筛选时重置筛选条件与页码
+          if (extra.action !== "filter") return;
+          setFilters({
+            rating: (f.rating?.[0] as 1 | -1 | undefined) ?? undefined,
+            tag: (f.tags?.[0] as string | undefined) ?? undefined,
+          });
+          setPage(1);
+        }}
+        onRow={(r) => ({
+          onClick: () => r.run_id && setRunId(r.run_id),
+          style: { cursor: r.run_id ? "pointer" : "default" },
+        })}
+      />
+      <Typography.Text type="secondary" style={{ fontSize: 12 }}>
+        agent_feedback · agent_runs
+      </Typography.Text>
+      <AgentRunDrawer runId={runId} onClose={() => setRunId(null)} />
+    </>
+  );
+};
+
+export default AgentFeedbackTable;

+ 132 - 0
dashboard-v6/src/features/admin-stats/AgentRunDrawer.tsx

@@ -0,0 +1,132 @@
+// src/features/admin-stats/AgentRunDrawer.tsx
+/**
+ * 一次提问的研究过程:账号、路由、耗时,回答,研究计划,给作答模型的证据,全部步骤。
+ * 数据来自 GET /v3/admin/agent-runs/{run}。回答与证据都按纯文本显示(来自 LLM 与用户可写的语料,不渲染 HTML)。
+ */
+import { Collapse, Descriptions, Drawer, Empty, Tag, Timeline, Typography } from "antd";
+import { useAgentRun } from "../../hooks/useAdminStats";
+import { useT } from "./helpers";
+
+const STEP_COLOR: Record<string, string> = { tool: "green", llm: "blue", route: "purple", plan: "purple", event: "gray" };
+
+const pre: React.CSSProperties = {
+  whiteSpace: "pre-wrap",
+  wordBreak: "break-word",
+  maxHeight: 320,
+  overflow: "auto",
+  margin: 0,
+  fontSize: 12,
+};
+
+const AgentRunDrawer = ({ runId, onClose }: { runId: string | null; onClose: () => void }) => {
+  const t = useT();
+  const { data: run, loading } = useAgentRun(runId);
+
+  return (
+    <Drawer title={t("admin.stats.run.title")} open={!!runId} onClose={onClose} size="large" loading={loading}>
+      {run ? (
+        <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
+          <Typography.Paragraph strong style={{ fontSize: 16, margin: 0 }}>
+            {run.question}
+          </Typography.Paragraph>
+          <Descriptions
+            size="small"
+            column={2}
+            bordered
+            items={[
+              {
+                key: "account",
+                label: t("admin.stats.runs.account"),
+                children: run.user
+                  ? run.user.nickName
+                  : `${t("admin.stats.runs.guest")} · ${t("admin.stats.run.device", { device: run.device_id?.slice(0, 8) ?? "?" })} · ${run.client_ip ?? ""}`,
+              },
+              { key: "client", label: t("admin.stats.runs.client"), children: `${run.client ?? "?"} ${run.app_version ?? ""}` },
+              {
+                key: "route",
+                label: t("admin.stats.runs.route"),
+                children: (
+                  <>
+                    {t(`admin.stats.route.${run.route ?? "none"}`)}
+                    {run.deep ? <Tag style={{ marginLeft: 8 }}>{t("admin.stats.runs.deep")}</Tag> : null}
+                  </>
+                ),
+              },
+              { key: "status", label: t("admin.stats.runs.status"), children: t(`admin.stats.status.${run.status}`) },
+              {
+                key: "latency",
+                label: t("admin.stats.runs.latency"),
+                children: run.latency_ms != null ? `${(run.latency_ms / 1000).toFixed(1)} ${t("admin.stats.ai.seconds")}` : "—",
+              },
+              { key: "tokens", label: t("admin.stats.run.tokens"), children: `${run.tokens_in ?? 0} → ${run.tokens_out ?? 0}` },
+              { key: "model", label: t("admin.stats.run.model"), children: `${run.model ?? "?"} · ${run.prompt_version ?? ""}` },
+              { key: "thread", label: t("admin.stats.run.thread"), children: run.thread_title ?? run.thread_id },
+            ]}
+          />
+          {run.error ? (
+            <Typography.Paragraph type="danger" style={pre}>
+              {t("admin.stats.run.error")}: {run.error}
+            </Typography.Paragraph>
+          ) : null}
+          <Collapse
+            defaultActiveKey={["answer", "steps"]}
+            items={[
+              {
+                key: "answer",
+                label: t("admin.stats.run.answer"),
+                children: <pre style={pre}>{run.answer ?? "—"}</pre>,
+              },
+              {
+                key: "plan",
+                label: t("admin.stats.run.plan"),
+                children: <pre style={pre}>{run.plan ? JSON.stringify(run.plan, null, 2) : "—"}</pre>,
+              },
+              {
+                key: "evidence",
+                label: `${t("admin.stats.run.evidence")} · ${t("admin.stats.run.chars", { chars: run.evidence?.length ?? 0 })}`,
+                children: <pre style={pre}>{run.evidence ?? "—"}</pre>,
+              },
+              {
+                key: "steps",
+                label: `${t("admin.stats.run.steps")} · ${run.steps?.length ?? 0}`,
+                children: run.steps?.length ? (
+                  <Timeline
+                    items={run.steps.map((s) => ({
+                      key: s.seq,
+                      color: s.error ? "red" : (STEP_COLOR[s.kind ?? ""] ?? "gray"),
+                      content: (
+                        <div>
+                          <Typography.Text strong>{s.kind}</Typography.Text>
+                          {s.name ? <Typography.Text code>{s.name}</Typography.Text> : null}
+                          {s.ms != null ? <Typography.Text type="secondary"> · {s.ms} ms</Typography.Text> : null}
+                          {s.tokens_in != null ? (
+                            <Typography.Text type="secondary">
+                              {" "}
+                              · {s.tokens_in} → {s.tokens_out ?? 0} tok
+                            </Typography.Text>
+                          ) : null}
+                          {s.result_chars != null ? (
+                            <Typography.Text type="secondary">
+                              {" "}
+                              · {t("admin.stats.run.chars", { chars: s.result_chars })}
+                            </Typography.Text>
+                          ) : null}
+                          {s.args ? <pre style={{ ...pre, maxHeight: 120 }}>{JSON.stringify(s.args)}</pre> : null}
+                          {s.error ? <Typography.Text type="danger">{s.error}</Typography.Text> : null}
+                        </div>
+                      ),
+                    }))}
+                  />
+                ) : (
+                  <Empty />
+                ),
+              },
+            ]}
+          />
+        </div>
+      ) : null}
+    </Drawer>
+  );
+};
+
+export default AgentRunDrawer;

+ 158 - 0
dashboard-v6/src/features/admin-stats/AgentRunTable.tsx

@@ -0,0 +1,158 @@
+// src/features/admin-stats/AgentRunTable.tsx
+/**
+ * 提问记录:最新的在前,可按状态 / 路由 / 账号类型筛选、按提问原文搜索,点一行看研究过程。
+ * 数据来自 GET /v3/admin/agent-runs(提问原文对 root / administrator 可见)。
+ */
+import { useState } from "react";
+import { Badge, Card, Input, Table, Tag, Tooltip, Typography } from "antd";
+import type { ColumnsType } from "antd/es/table";
+import { BulbFilled, CheckOutlined, MinusOutlined } from "@ant-design/icons";
+import dayjs from "dayjs";
+import type { AgentRoute, AgentRun } from "../../api/adminStats";
+import { useAgentRuns } from "../../hooks/useAdminStats";
+import AgentRunDrawer from "./AgentRunDrawer";
+import { ROUTES, useT } from "./helpers";
+
+const STATUS_BADGE: Record<string, "success" | "warning" | "error" | "default"> = {
+  ok: "success",
+  denied: "warning",
+  error: "error",
+  cancelled: "default",
+};
+const ROUTE_COLOR: Record<string, string> = { question: "blue", term: "purple", passage: "cyan", chat: "default" };
+
+type Filters = { status?: AgentRun["status"]; route?: AgentRoute; account_type?: "user" | "guest" };
+
+const AgentRunTable = () => {
+  const t = useT();
+  const [page, setPage] = useState(1);
+  const [q, setQ] = useState("");
+  const [filters, setFilters] = useState<Filters>({});
+  const [runId, setRunId] = useState<string | null>(null);
+  const { data, loading } = useAgentRuns({
+    page,
+    per_page: 20,
+    ...(q ? { "filter[q]": q } : {}),
+    ...(filters.status ? { "filter[status]": filters.status as "ok" } : {}),
+    ...(filters.route ? { "filter[route]": filters.route } : {}),
+    ...(filters.account_type ? { "filter[account_type]": filters.account_type } : {}),
+  });
+
+  const columns: ColumnsType<AgentRun> = [
+    {
+      title: t("admin.stats.runs.time"),
+      dataIndex: "started_at",
+      width: 120,
+      render: (v?: string | null) => (v ? dayjs(v).format("MM-DD HH:mm") : "—"),
+    },
+    {
+      title: t("admin.stats.runs.question"),
+      dataIndex: "question",
+      ellipsis: true,
+      render: (v: string) => <Tooltip title={v}>{v}</Tooltip>,
+    },
+    {
+      title: t("admin.stats.runs.account"),
+      dataIndex: "account_type",
+      width: 130,
+      filters: (["user", "guest"] as const).map((v) => ({ value: v, text: t(`admin.stats.account.${v}`) })),
+      filterMultiple: false,
+      render: (_: string, r) =>
+        r.user ? (
+          <Tag color="blue">{r.user.nickName}</Tag>
+        ) : (
+          <Tooltip title={`${r.device_id ?? ""} · ${r.client_ip ?? ""}`}>
+            <Tag>{t("admin.stats.runs.guest")}</Tag>
+          </Tooltip>
+        ),
+    },
+    { title: t("admin.stats.runs.client"), dataIndex: "client", width: 80 },
+    {
+      title: t("admin.stats.runs.route"),
+      dataIndex: "route",
+      width: 120,
+      filters: ROUTES.map((v) => ({ value: v, text: t(`admin.stats.route.${v}`) })),
+      filterMultiple: false,
+      render: (v?: string | null) => <Tag color={ROUTE_COLOR[v ?? ""]}>{t(`admin.stats.route.${v ?? "none"}`)}</Tag>,
+    },
+    {
+      title: t("admin.stats.runs.deep"),
+      dataIndex: "deep",
+      width: 60,
+      render: (v: boolean) => (v ? <BulbFilled style={{ color: "#faad14" }} /> : null),
+    },
+    {
+      title: t("admin.stats.runs.latency"),
+      dataIndex: "latency_ms",
+      width: 90,
+      align: "right",
+      render: (v?: number | null) => (v != null ? `${(v / 1000).toFixed(1)} ${t("admin.stats.ai.seconds")}` : "—"),
+    },
+    {
+      title: t("admin.stats.runs.status"),
+      dataIndex: "status",
+      width: 110,
+      filters: ["ok", "denied", "error", "cancelled"].map((v) => ({ value: v, text: t(`admin.stats.status.${v}`) })),
+      filterMultiple: false,
+      render: (v: string) => <Badge status={STATUS_BADGE[v] ?? "default"} text={t(`admin.stats.status.${v}`)} />,
+    },
+    {
+      title: <Tooltip title={t("admin.stats.ai.improve.tip")}>{t("admin.stats.runs.improve")}</Tooltip>,
+      dataIndex: "improve",
+      width: 70,
+      render: (v: boolean) => (v ? <CheckOutlined /> : <MinusOutlined style={{ opacity: 0.4 }} />),
+    },
+  ];
+
+  return (
+    <Card
+      size="small"
+      variant="borderless"
+      styles={{ header: { paddingInline: 0 }, body: { paddingInline: 0 } }}
+      extra={
+        <Input.Search
+          allowClear
+          placeholder={t("admin.stats.runs.search")}
+          onSearch={(v) => {
+            setQ(v.trim());
+            setPage(1);
+          }}
+          style={{ width: 240, maxWidth: "100%" }}
+        />
+      }
+    >
+      <Table<AgentRun>
+        size="small"
+        rowKey="run_id"
+        columns={columns}
+        dataSource={data?.data ?? []}
+        loading={loading}
+        scroll={{ x: 900 }}
+        pagination={{
+          current: page,
+          pageSize: 20,
+          total: data?.meta?.total ?? 0,
+          showSizeChanger: false,
+          onChange: setPage,
+        }}
+        onChange={(_, f, __, extra) => {
+          // 翻页也会触发 onChange:只在筛选时重置筛选条件与页码
+          if (extra.action !== "filter") return;
+          setFilters({
+            account_type: (f.account_type?.[0] as Filters["account_type"]) ?? undefined,
+            route: (f.route?.[0] as AgentRoute | undefined) ?? undefined,
+            status: (f.status?.[0] as Filters["status"]) ?? undefined,
+          });
+          setPage(1);
+        }}
+        onRow={(r) => ({ onClick: () => setRunId(r.run_id ?? null), style: { cursor: "pointer" } })}
+      />
+      <Typography.Text type="secondary" style={{ fontSize: 12 }}>
+        agent_runs · agent_threads
+      </Typography.Text>
+      <AgentRunDrawer runId={runId} onClose={() => setRunId(null)} />
+    </Card>
+  );
+};
+
+export default AgentRunTable;

+ 320 - 0
dashboard-v6/src/features/admin-stats/AgentStats.tsx

@@ -0,0 +1,320 @@
+// src/features/admin-stats/AgentStats.tsx
+/**
+ * 管理后台「AI 对话统计」:指标卡 → 每日提问(按研究路径)+ 耗时分位数 → 工具 / 积分 / token → 提问记录。
+ * 数据来自 GET /v3/admin/agent-stats 与 /v3/admin/agent-runs。
+ */
+import { useState } from "react";
+import { Button, Card, Col, Empty, Progress, Result, Row, Statistic, Tabs, Tooltip, Typography } from "antd";
+import { InfoCircleOutlined } from "@ant-design/icons";
+import { Bar, Column, Line, Tiny } from "@ant-design/plots";
+import KpiCard from "../../components/stats/KpiCard";
+import { useAgentStats } from "../../hooks/useAdminStats";
+import AgentRunTable from "./AgentRunTable";
+import AgentFeedbackTable from "./AgentFeedbackTable";
+import { ROUTES, change, pct, tiny, useChartTheme, useStatsRange, useT } from "./helpers";
+import { Source, StatsToolbar } from "./shared";
+
+type Account = "all" | "user" | "guest";
+const CREDIT_KINDS = ["spent_free", "spent_earned", "refunded", "earned_reading", "earned_editing", "adjusted"] as const;
+
+const AgentStats = () => {
+  const t = useT();
+  const chartTheme = useChartTheme();
+  const { range, setRange, query } = useStatsRange();
+  const [account, setAccount] = useState<Account>("all");
+  const { data, loading, error, refresh } = useAgentStats({ ...query, account_type: account });
+
+  const base = { theme: chartTheme, autoFit: true } as const;
+  const s = data?.summary;
+  const p = data?.previous;
+  const daily = data?.daily ?? [];
+  const runs = s?.runs ?? 0;
+  const seconds = (ms?: number | null) => (ms == null ? null : Number((ms / 1000).toFixed(1)));
+
+  const toolbar = (
+    <StatsToolbar<Account>
+      title={t("admin.stats.ai.title")}
+      segments={(["all", "user", "guest"] as const).map((v) => ({ value: v, label: t(`admin.stats.account.${v}`) }))}
+      segment={account}
+      onSegment={setAccount}
+      range={range}
+      onRange={setRange}
+    />
+  );
+
+  if (error && !data) {
+    return (
+      <>
+        {toolbar}
+        <Result
+          status="warning"
+          title={String((error as Error).message ?? error)}
+          extra={<Button onClick={refresh}>{t("buttons.refresh")}</Button>}
+        />
+      </>
+    );
+  }
+
+  const perDay = daily.map((d) => ROUTES.reduce((n, r) => n + (d[r] ?? 0), 0) + (d.none ?? 0));
+  const stacked = daily.flatMap((d) =>
+    [...ROUTES, "none" as const].map((r) => ({ date: d.date?.slice(5), route: t(`admin.stats.route.${r}`), value: d[r] ?? 0 })),
+  );
+  const latency = daily.flatMap((d) => [
+    { date: d.date?.slice(5), value: seconds(d.latency_p50_ms), series: "P50" },
+    { date: d.date?.slice(5), value: seconds(d.latency_p95_ms), series: "P95" },
+  ]).filter((r) => r.value != null);
+  const failed = (s?.denied ?? 0) + (s?.errors ?? 0);
+  const prevFailedRatio = p?.runs ? ((p.denied ?? 0) + (p.errors ?? 0)) / p.runs : null;
+
+  return (
+    <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
+      {toolbar}
+
+      <Row gutter={[16, 16]}>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.ai.runs")}
+            value={runs}
+            change={change(s?.runs, p?.runs)}
+            changeLabel={t("admin.stats.compare")}
+            chart={<Tiny.Area {...base} height={46} data={tiny(perDay)} xField="index" yField="value" shapeField="smooth" style={{ fillOpacity: 0.3 }} />}
+            footer={
+              <>
+                <span>{t("admin.stats.ai.runs.deep", { ratio: pct(s?.deep ?? 0, runs) })}</span>
+                <span>{t("admin.stats.ai.runs.passage", { ratio: pct(s?.passage ?? 0, runs) })}</span>
+              </>
+            }
+            source="agent_runs"
+          />
+        </Col>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.ai.askers")}
+            tip={t("admin.stats.ai.askers.tip")}
+            value={s?.askers ?? 0}
+            change={change(s?.askers, p?.askers)}
+            changeLabel={t("admin.stats.compare")}
+            chart={
+              <Progress
+                percent={Number(pct(s?.askers_user ?? 0, s?.askers ?? 0))}
+                success={{ percent: Number(pct(s?.askers_user ?? 0, s?.askers ?? 0)) }}
+                size="small"
+                style={{ marginTop: 12 }}
+              />
+            }
+            footer={<span>{t("admin.stats.ai.askers.split", { user: s?.askers_user ?? 0, guest: s?.askers_guest ?? 0 })}</span>}
+            source="agent_threads.account"
+          />
+        </Col>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.ai.latency")}
+            value={seconds(s?.latency_p50_ms)}
+            suffix={t("admin.stats.ai.seconds")}
+            change={change(s?.latency_p50_ms, p?.latency_p50_ms)}
+            inverse
+            changeLabel={t("admin.stats.compare")}
+            chart={
+              <Tiny.Line
+                {...base}
+                height={46}
+                data={tiny(daily.map((d) => seconds(d.latency_p50_ms) ?? 0))}
+                xField="index"
+                yField="value"
+              />
+            }
+            footer={<span>{t("admin.stats.ai.latency.p95", { seconds: seconds(s?.latency_p95_ms) ?? "—" })}</span>}
+            source="agent_runs.latency_ms"
+          />
+        </Col>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.ai.failed")}
+            tip={t("admin.stats.ai.failed.tip")}
+            value={pct(failed, runs)}
+            suffix="%"
+            change={change(runs ? failed / runs : null, prevFailedRatio)}
+            inverse
+            changeLabel={t("admin.stats.compare")}
+            chart={
+              <Tiny.Column
+                {...base}
+                height={46}
+                data={tiny(daily.map((d) => (d.denied ?? 0) + (d.errors ?? 0)))}
+                xField="index"
+                yField="value"
+                style={{ fill: "#faad14" }}
+              />
+            }
+            footer={
+              <span>
+                {t("admin.stats.ai.failed.split", { denied: s?.denied ?? 0, errors: s?.errors ?? 0, unchecked: s?.unchecked ?? 0 })}
+              </span>
+            }
+            source="agent_runs.status"
+          />
+        </Col>
+      </Row>
+
+      <Row gutter={[16, 16]}>
+        <Col xs={24} xl={16}>
+          <Card size="small" title={t("admin.stats.ai.daily")} loading={loading && !data}>
+            <Column
+              {...base}
+              height={300}
+              data={stacked}
+              xField="date"
+              yField="value"
+              colorField="route"
+              stack
+              axis={{ x: { labelAutoHide: true } }}
+            />
+            <Source>agent_runs.route</Source>
+          </Card>
+        </Col>
+        <Col xs={24} xl={8}>
+          <Card size="small" title={t("admin.stats.ai.latency.daily")} loading={loading && !data}>
+            {latency.length ? (
+              <Line {...base} height={300} data={latency} xField="date" yField="value" colorField="series" axis={{ x: { labelAutoHide: true } }} />
+            ) : (
+              <Empty description={t("admin.stats.empty")} />
+            )}
+            <Source>agent_runs.latency_ms</Source>
+          </Card>
+        </Col>
+      </Row>
+
+      <Row gutter={[16, 16]}>
+        <Col xs={24} md={12} xl={8}>
+          <Card size="small" title={t("admin.stats.ai.tools")} loading={loading && !data}>
+            {data?.tools?.length ? (
+              <Bar
+                {...base}
+                height={260}
+                data={data.tools}
+                xField="name"
+                yField="calls"
+                label={{ text: "calls", position: "right", dx: 4 }}
+                axis={{ x: { title: false }, y: false }}
+                tooltip={{ items: [{ channel: "y", name: "calls" }, { field: "avg_ms", name: "avg ms" }, { field: "errors", name: "errors" }] }}
+              />
+            ) : (
+              <Empty description={t("admin.stats.empty")} />
+            )}
+            <Source>agent_run_steps</Source>
+          </Card>
+        </Col>
+        <Col xs={24} md={12} xl={8}>
+          <Card size="small" title={t("admin.stats.ai.credits")} loading={loading && !data}>
+            <Bar
+              {...base}
+              height={260}
+              data={CREDIT_KINDS.map((k) => ({ kind: t(`admin.stats.ai.credits.${k}`), value: data?.credits?.[k] ?? 0 }))}
+              xField="kind"
+              yField="value"
+              colorField="kind"
+              legend={false}
+              label={{ text: "value", position: "right", dx: 4 }}
+              axis={{ x: { title: false }, y: false }}
+            />
+            <Source>credit_ledger</Source>
+          </Card>
+        </Col>
+        <Col xs={24} xl={8}>
+          <Card size="small" title={t("admin.stats.ai.tokens")} loading={loading && !data}>
+            <Row gutter={[12, 12]}>
+              <Col span={12}>
+                <Statistic title={t("admin.stats.ai.tokens.in")} value={s?.tokens_in ?? 0} />
+              </Col>
+              <Col span={12}>
+                <Statistic title={t("admin.stats.ai.tokens.out")} value={s?.tokens_out ?? 0} />
+              </Col>
+              <Col span={12}>
+                <Statistic
+                  title={t("admin.stats.ai.tokens.per_run")}
+                  value={runs ? Math.round(((s?.tokens_in ?? 0) + (s?.tokens_out ?? 0)) / runs) : 0}
+                />
+              </Col>
+              <Col span={12}>
+                <Statistic
+                  title={
+                    <span>
+                      {t("admin.stats.ai.improve")}{" "}
+                      <Tooltip title={t("admin.stats.ai.improve.tip")}>
+                        <InfoCircleOutlined />
+                      </Tooltip>
+                    </span>
+                  }
+                  value={pct(s?.improve ?? 0, runs)}
+                  suffix="%"
+                />
+              </Col>
+            </Row>
+            <Typography.Title level={5} style={{ marginTop: 16 }}>
+              {t("admin.stats.ai.clients")}
+            </Typography.Title>
+            {(data?.clients ?? []).map((c) => (
+              <div key={c.client} style={{ display: "flex", gap: 8, alignItems: "center" }}>
+                <span style={{ width: 64 }}>{c.client}</span>
+                <Progress percent={Number(pct(c.runs ?? 0, runs))} size="small" style={{ flex: 1, margin: 0 }} />
+              </div>
+            ))}
+            <Source>agent_runs</Source>
+          </Card>
+        </Col>
+      </Row>
+
+      <Row gutter={[16, 16]}>
+        <Col xs={24}>
+          <Card size="small" title={t("admin.stats.feedback.title")} loading={loading && !data}>
+            <Row gutter={[12, 12]}>
+              <Col span={8}>
+                <Statistic title={t("admin.stats.feedback.up")} value={s?.feedback_up ?? 0} />
+              </Col>
+              <Col span={8}>
+                <Statistic title={t("admin.stats.feedback.down")} value={s?.feedback_down ?? 0} />
+              </Col>
+              <Col span={8}>
+                <Statistic
+                  title={t("admin.stats.feedback.coverage")}
+                  value={pct((s?.feedback_up ?? 0) + (s?.feedback_down ?? 0), runs)}
+                  suffix="%"
+                />
+              </Col>
+            </Row>
+            {data?.feedback_reasons?.length ? (
+              <Bar
+                {...base}
+                height={200}
+                data={data.feedback_reasons.map((r) => ({ reason: t(`admin.stats.feedback.tag.${r.reason}`), count: r.count ?? 0 }))}
+                xField="reason"
+                yField="count"
+                label={{ text: "count", position: "right", dx: 4 }}
+                axis={{ x: { title: false }, y: false }}
+                style={{ fill: "#ff7875", maxWidth: 24 }}
+              />
+            ) : (
+              <Empty description={t("admin.stats.empty")} image={Empty.PRESENTED_IMAGE_SIMPLE} />
+            )}
+            <Source>agent_feedback</Source>
+          </Card>
+        </Col>
+      </Row>
+
+      <Card size="small">
+        <Tabs
+          items={[
+            { key: "runs", label: t("admin.stats.runs.title"), children: <AgentRunTable /> },
+            { key: "feedback", label: t("admin.stats.feedback.review"), children: <AgentFeedbackTable /> },
+          ]}
+        />
+      </Card>
+    </div>
+  );
+};
+
+export default AgentStats;

+ 350 - 0
dashboard-v6/src/features/admin-stats/ReadingStats.tsx

@@ -0,0 +1,350 @@
+// src/features/admin-stats/ReadingStats.tsx
+/**
+ * 管理后台「阅读统计」:指标卡 → 趋势 + 热门章节 → 分布与读经积分。
+ * 数据来自 GET /v3/admin/reading-stats,口径写在每张卡片的来源脚注里。
+ */
+import { useState } from "react";
+import { Button, Card, Col, Empty, Result, Row, Statistic, Tooltip, Typography } from "antd";
+import { InfoCircleOutlined } from "@ant-design/icons";
+import { Column, Line, Pie, Tiny } from "@ant-design/plots";
+import KpiCard from "../../components/stats/KpiCard";
+import { useReadingStats } from "../../hooks/useAdminStats";
+import { change, pct, tiny, useChartTheme, useStatsRange, useT } from "./helpers";
+import { Source, StatsToolbar } from "./shared";
+
+type Client = "all" | "web" | "mobile";
+type TrendTab = "readers" | "minutes" | "lookups";
+
+const ReadingStats = () => {
+  const t = useT();
+  const chartTheme = useChartTheme();
+  const { range, setRange, query } = useStatsRange();
+  const [client, setClient] = useState<Client>("all");
+  const [tab, setTab] = useState<TrendTab>("readers");
+  const { data, loading, error, refresh } = useReadingStats({ ...query, client });
+
+  const base = { theme: chartTheme, autoFit: true } as const;
+  const s = data?.summary;
+  const p = data?.previous;
+  const daily = data?.daily ?? [];
+  const tagLabel = (tag?: string) => t(`admin.stats.tag.${tag ?? "other"}`);
+
+  const toolbar = (
+    <StatsToolbar<Client>
+      title={t("admin.stats.reading.title")}
+      segments={(["all", "web", "mobile"] as const).map((v) => ({ value: v, label: t(`admin.stats.client.${v}`) }))}
+      segment={client}
+      onSegment={setClient}
+      range={range}
+      onRange={setRange}
+    />
+  );
+
+  if (error && !data) {
+    return (
+      <>
+        {toolbar}
+        <Result
+          status="warning"
+          title={String((error as Error).message ?? error)}
+          extra={<Button onClick={refresh}>{t("buttons.refresh")}</Button>}
+        />
+      </>
+    );
+  }
+
+  const readers = s?.active_readers ?? 0;
+  const readingUsers = s?.reading_users ?? 0;
+  const trendRows =
+    tab === "readers"
+      ? daily.flatMap((d) => [
+          { date: d.date?.slice(5), value: d.readers_web ?? 0, series: t("admin.stats.client.web") },
+          { date: d.date?.slice(5), value: d.readers_mobile ?? 0, series: t("admin.stats.client.mobile") },
+        ])
+      : daily.map((d) => ({
+          date: d.date?.slice(5),
+          value: tab === "minutes" ? (d.reading_minutes ?? 0) : (d.dict_lookups ?? 0),
+          series: t(`admin.stats.reading.trend.${tab}`),
+        }));
+
+  return (
+    <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
+      {toolbar}
+
+      <Row gutter={[16, 16]}>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.reading.readers")}
+            tip={t("admin.stats.reading.readers.tip")}
+            value={readers}
+            change={change(s?.active_readers, p?.active_readers)}
+            changeLabel={t("admin.stats.compare")}
+            chart={
+              <Tiny.Area
+                {...base}
+                height={46}
+                data={tiny(daily.map((d) => (d.readers_web ?? 0) + (d.readers_mobile ?? 0)))}
+                xField="index"
+                yField="value"
+                shapeField="smooth"
+                style={{ fillOpacity: 0.3 }}
+              />
+            }
+            footer={
+              <>
+                <span>{t("admin.stats.reading.dau", { dau: data?.sticky?.dau ?? 0 })}</span>
+                <span>
+                  {t("admin.stats.reading.sticky", {
+                    ratio: pct(data?.sticky?.dau ?? 0, data?.sticky?.mau ?? 0),
+                  })}
+                </span>
+              </>
+            }
+            source="recents"
+          />
+        </Col>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.reading.time")}
+            tip={t("admin.stats.reading.time.tip")}
+            value={s?.reading_seconds == null ? null : s.reading_seconds / 3600}
+            precision={1}
+            suffix={t("admin.stats.reading.time.unit")}
+            change={change(s?.reading_seconds, p?.reading_seconds)}
+            changeLabel={t("admin.stats.compare")}
+            chart={
+              s?.reading_seconds == null ? undefined : (
+                <Tiny.Column
+                  {...base}
+                  height={46}
+                  data={tiny(daily.map((d) => d.reading_minutes ?? 0))}
+                  xField="index"
+                  yField="value"
+                />
+              )
+            }
+            footer={
+              s?.reading_seconds == null ? (
+                <span>{t("admin.stats.na")}</span>
+              ) : (
+                <span>
+                  {t("admin.stats.reading.time.avg", {
+                    users: readingUsers,
+                    minutes: readingUsers ? Math.round(s.reading_seconds / 60 / readingUsers) : 0,
+                  })}
+                </span>
+              )
+            }
+            source="reading_dailies"
+          />
+        </Col>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.reading.chapters")}
+            tip={t("admin.stats.reading.chapters.tip")}
+            value={s?.chapters_opened ?? 0}
+            change={change(s?.chapters_opened, p?.chapters_opened)}
+            changeLabel={t("admin.stats.compare")}
+            footer={
+              <>
+                <span>
+                  {t("admin.stats.reading.chapters.avg", {
+                    avg: readers ? ((s?.chapters_opened ?? 0) / readers).toFixed(1) : "0",
+                  })}
+                </span>
+                {s?.page_views != null ? (
+                  <span>{t("admin.stats.reading.views", { views: s.page_views.toLocaleString() })}</span>
+                ) : null}
+              </>
+            }
+            source="recents · views"
+          />
+        </Col>
+        <Col xs={24} sm={12} xl={6}>
+          <KpiCard
+            loading={loading && !data}
+            title={t("admin.stats.reading.lookups")}
+            tip={t("admin.stats.reading.lookups.tip")}
+            value={s?.dict_lookups ?? 0}
+            change={change(s?.dict_lookups, p?.dict_lookups)}
+            changeLabel={t("admin.stats.compare")}
+            chart={
+              <Tiny.Line
+                {...base}
+                height={46}
+                data={tiny(daily.map((d) => d.dict_lookups ?? 0))}
+                xField="index"
+                yField="value"
+                shapeField="smooth"
+              />
+            }
+            source="user_operation_logs"
+          />
+        </Col>
+      </Row>
+
+      <Row gutter={[16, 16]}>
+        <Col xs={24} xl={16}>
+          <Card
+            size="small"
+            loading={loading && !data}
+            tabList={(["readers", "minutes", "lookups"] as const).map((k) => ({
+              key: k,
+              label: t(`admin.stats.reading.trend.${k}`),
+            }))}
+            activeTabKey={tab}
+            onTabChange={(k) => setTab(k as TrendTab)}
+          >
+            {tab === "minutes" ? (
+              <Column {...base} height={300} data={trendRows} xField="date" yField="value" axis={{ x: { labelAutoHide: true } }} />
+            ) : (
+              <Line
+                {...base}
+                height={300}
+                data={trendRows}
+                xField="date"
+                yField="value"
+                colorField="series"
+                shapeField="smooth"
+                axis={{ x: { labelAutoHide: true } }}
+              />
+            )}
+            <Source>
+              {tab === "readers" ? "recents" : tab === "minutes" ? "reading_dailies" : "user_operation_logs"}
+            </Source>
+          </Card>
+        </Col>
+        <Col xs={24} xl={8}>
+          <Card size="small" title={t("admin.stats.reading.top")} loading={loading && !data}>
+            {data?.top_chapters?.length ? (
+              data.top_chapters.map((c, i) => (
+                <div
+                  key={c.article_id}
+                  style={{ display: "flex", alignItems: "center", gap: 10, padding: "6px 0", minWidth: 0 }}
+                >
+                  <span
+                    style={{
+                      width: 20,
+                      height: 20,
+                      borderRadius: 10,
+                      flex: "none",
+                      fontSize: 12,
+                      display: "inline-flex",
+                      alignItems: "center",
+                      justifyContent: "center",
+                      background: i < 3 ? "#1677ff" : "rgba(127,127,127,.15)",
+                      color: i < 3 ? "#fff" : undefined,
+                    }}
+                  >
+                    {i + 1}
+                  </span>
+                  <div style={{ flex: 1, minWidth: 0 }}>
+                    <Typography.Text ellipsis style={{ display: "block" }}>
+                      {c.title}
+                    </Typography.Text>
+                    <Typography.Text type="secondary" ellipsis style={{ display: "block", fontSize: 12 }}>
+                      {c.collection ?? c.article_id}
+                    </Typography.Text>
+                  </div>
+                  <span style={{ fontVariantNumeric: "tabular-nums" }}>
+                    {t("admin.stats.reading.top.readers", { n: c.readers ?? 0 })}
+                  </span>
+                </div>
+              ))
+            ) : (
+              <Empty description={t("admin.stats.empty")} />
+            )}
+            <Source>recents</Source>
+          </Card>
+        </Col>
+      </Row>
+
+      <Row gutter={[16, 16]}>
+        {(["pitaka_share", "layer_share"] as const).map((key) => (
+          <Col xs={24} md={12} xl={8} key={key}>
+            <Card
+              size="small"
+              title={t(key === "pitaka_share" ? "admin.stats.reading.pitaka" : "admin.stats.reading.layer")}
+              loading={loading && !data}
+            >
+              {data?.[key]?.length ? (
+                <Pie
+                  {...base}
+                  height={240}
+                  data={data[key].map((r) => ({ type: tagLabel(r.tag), value: r.records ?? 0 }))}
+                  angleField="value"
+                  colorField="type"
+                  innerRadius={0.6}
+                  label={{ text: "type", position: "outside" }}
+                  legend={false}
+                />
+              ) : (
+                <Empty description={t("admin.stats.empty")} />
+              )}
+              <Source>recents · tag_maps</Source>
+            </Card>
+          </Col>
+        ))}
+        <Col xs={24} xl={8}>
+          <Card size="small" title={t("admin.stats.reading.duration")} loading={loading && !data}>
+            {data?.duration_buckets?.length ? (
+              <Column
+                {...base}
+                height={160}
+                data={data.duration_buckets}
+                xField="bucket"
+                yField="user_days"
+                label={{ text: "user_days", position: "inside" }}
+              />
+            ) : (
+              <Empty description={t("admin.stats.na")} />
+            )}
+            <Typography.Title level={5} style={{ marginTop: 12 }}>
+              {t("admin.stats.reading.credits")}
+            </Typography.Title>
+            {data?.reading_credits ? (
+              <Row gutter={[12, 12]}>
+                <Col span={12}>
+                  <Statistic title={t("admin.stats.reading.credits.total")} value={data.reading_credits.credits} />
+                </Col>
+                <Col span={12}>
+                  <Statistic title={t("admin.stats.reading.credits.users")} value={data.reading_credits.users} />
+                </Col>
+                <Col span={12}>
+                  <Statistic
+                    title={t("admin.stats.reading.credits.capped")}
+                    value={data.reading_credits.capped_user_days}
+                  />
+                </Col>
+                <Col span={12}>
+                  <Statistic
+                    title={
+                      <span>
+                        {t("admin.stats.reading.credits.clamped")}{" "}
+                        <Tooltip title={t("admin.stats.reading.credits.clamped.tip")}>
+                          <InfoCircleOutlined />
+                        </Tooltip>
+                      </span>
+                    }
+                    value={((data.reading_credits.clamped_ratio ?? 0) * 100).toFixed(1)}
+                    suffix="%"
+                  />
+                </Col>
+              </Row>
+            ) : (
+              <Typography.Text type="secondary">{t("admin.stats.na")}</Typography.Text>
+            )}
+            <div>
+              <Source>reading_dailies · credit_ledger</Source>
+            </div>
+          </Card>
+        </Col>
+      </Row>
+    </div>
+  );
+};
+
+export default ReadingStats;

+ 54 - 0
dashboard-v6/src/features/admin-stats/helpers.ts

@@ -0,0 +1,54 @@
+// src/features/admin-stats/helpers.ts
+// 两个统计页共用的 hook 与纯函数:区间、文案、图表主题、对比计算、迷你图数据。
+import { useMemo, useState, type ReactNode } from "react";
+import { useIntl } from "react-intl";
+import { theme } from "antd";
+import dayjs, { type Dayjs } from "dayjs";
+import type { AgentRoute } from "../../api/adminStats";
+export type Range = [Dayjs, Dayjs];
+
+/** 统计接口以 UTC 日为准。 */
+/**
+ * 全部研究路径,按画图 / 筛选的固定顺序。类型来自 OpenAPI(mint AgentRun::ROUTES):
+ * 规格里多了一种路由而这里没加,下面的 ALL_ROUTES_LISTED 编译报错。
+ */
+export const ROUTES = ["question", "term", "passage", "chat"] as const satisfies readonly AgentRoute[];
+const ALL_ROUTES_LISTED: Exclude<AgentRoute, (typeof ROUTES)[number]> extends never ? true : never = true;
+void ALL_ROUTES_LISTED;
+
+export const today = () => dayjs().startOf("day");
+
+export const useStatsRange = (days = 30) => {
+  const [range, setRange] = useState<Range>(() => [today().subtract(days - 1, "day"), today()]);
+  const query = useMemo(
+    () => ({ from: range[0].format("YYYY-MM-DD"), to: range[1].format("YYYY-MM-DD") }),
+    [range],
+  );
+  return { range, setRange, query };
+};
+
+/** 文案简写:t("admin.stats.xxx", { n: 1 }) */
+export const useT = () => {
+  const intl = useIntl();
+  return (id: string, values?: Record<string, ReactNode>) =>
+    intl.formatMessage({ id }, values as Record<string, string>) as string;
+};
+
+/** 图表主题跟着 antd 的明暗走:看当前容器背景色的亮度。 */
+export const useChartTheme = (): "classic" | "classicDark" => {
+  const { token } = theme.useToken();
+  const hex = token.colorBgContainer.replace("#", "");
+  const [r, g, b] = [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16) || 0);
+  return 0.299 * r + 0.587 * g + 0.114 * b < 128 ? "classicDark" : "classic";
+};
+
+/** 相对上一区间的变化比例;上一区间是 0 或缺数据时没有可比性。 */
+export const change = (cur?: number | null, prev?: number | null): number | null =>
+  cur == null || prev == null || prev === 0 ? null : (cur - prev) / prev;
+
+export const pct = (part: number, total: number): string =>
+  total ? ((part / total) * 100).toFixed(1) : "0.0";
+
+/** 迷你图数据:plots 2.x 的 Tiny 图要 {index, value} 加 xField / yField。 */
+export const tiny = (values: number[]) => values.map((value, index) => ({ index, value }));
+

+ 52 - 0
dashboard-v6/src/features/admin-stats/shared.tsx

@@ -0,0 +1,52 @@
+// src/features/admin-stats/shared.tsx
+// 两个统计页共用的小组件:区间 / 维度工具栏、来源脚注。
+import type { ReactNode } from "react";
+import { DatePicker, Segmented, Space, Typography } from "antd";
+import { today, useT, type Range } from "./helpers";
+
+export const Source = ({ children }: { children: ReactNode }) => {
+  const t = useT();
+  return (
+    <Typography.Text type="secondary" style={{ fontSize: 12 }}>
+      {t("admin.stats.source", { source: children })}
+    </Typography.Text>
+  );
+};
+
+export const StatsToolbar = <T extends string>({
+  title,
+  segments,
+  segment,
+  onSegment,
+  range,
+  onRange,
+}: {
+  title: ReactNode;
+  segments: { value: T; label: ReactNode }[];
+  segment: T;
+  onSegment: (v: T) => void;
+  range: Range;
+  onRange: (r: Range) => void;
+}) => {
+  const t = useT();
+  return (
+    <div style={{ display: "flex", flexWrap: "wrap", alignItems: "center", gap: 12 }}>
+      <Typography.Title level={4} style={{ margin: 0, marginRight: "auto" }}>
+        {title}
+      </Typography.Title>
+      <Space wrap>
+        <Segmented<T> options={segments} value={segment} onChange={onSegment} />
+        <DatePicker.RangePicker
+          value={range}
+          allowClear={false}
+          disabledDate={(d) => d.isAfter(today())}
+          presets={[7, 30, 90].map((n) => ({
+            label: t(`admin.stats.range.${n}`),
+            value: [today().subtract(n - 1, "day"), today()] as Range,
+          }))}
+          onChange={(v) => v && v[0] && v[1] && onRange([v[0], v[1]])}
+        />
+      </Space>
+    </div>
+  );
+};

+ 32 - 0
dashboard-v6/src/features/admin/ApiDashboard.tsx

@@ -0,0 +1,32 @@
+import { Grid } from "antd";
+import { StatisticCard } from "@ant-design/pro-components";
+import { useIntl } from "react-intl";
+import ApiStatCard from "../../components/admin/ApiStatCard";
+import ApiGaugeCard from "../../components/admin/ApiGaugeCard";
+import { useApiAverage, useApiStat } from "../../hooks/useAdmin";
+
+/** API 监控:平均响应时间、请求次数(按时段)+ 实时平均响应时间仪表盘。 */
+const ApiDashboard = () => {
+  const intl = useIntl();
+  const screens = Grid.useBreakpoint();
+  // 窄屏竖排(v4 用 ResizeObserver 判断 596px,这里用 antd 断点)
+  const vertical = !screens.md;
+  const average = useApiStat("average");
+  const count = useApiStat("count");
+  const delay = useApiAverage();
+
+  return (
+    <StatisticCard.Group
+      direction={vertical ? "column" : "row"}
+      title={intl.formatMessage({ id: "admin.api.total" })}
+    >
+      <ApiStatCard title={intl.formatMessage({ id: "admin.api.average" })} data={average} />
+      <StatisticCard.Divider orientation={vertical ? "horizontal" : "vertical"} />
+      <ApiStatCard title={intl.formatMessage({ id: "admin.api.count" })} data={count} suffix="" />
+      <StatisticCard.Divider orientation={vertical ? "horizontal" : "vertical"} />
+      <ApiGaugeCard title={intl.formatMessage({ id: "admin.api.average" })} delay={delay} />
+    </StatisticCard.Group>
+  );
+};
+
+export default ApiDashboard;

+ 48 - 0
dashboard-v6/src/features/admin/DictStatistics.tsx

@@ -0,0 +1,48 @@
+import { ProCard, StatisticCard } from "@ant-design/pro-components";
+import { useIntl } from "react-intl";
+import UserDictTable from "../../components/dict/UserDictTable";
+import { useDictStatistic } from "../../hooks/useAdmin";
+
+/** 各词典的统计卡(作为标签页头)+ 选中词典的词条表。 */
+const DictStatistics = () => {
+  const intl = useIntl();
+  const data = useDictStatistic();
+
+  return (
+    <ProCard
+      tabs={{
+        items: data?.map((item, index) => ({
+          key: item.key,
+          style: { width: "100%" },
+          label: (
+            <StatisticCard
+              colSpan={6}
+              title={item.title}
+              statistic={{
+                value: item.count,
+                description: (
+                  <>
+                    <StatisticCard.Statistic
+                      title={intl.formatMessage({ id: "admin.dict.vocabulary" })}
+                      value={item.vocabulary}
+                    />
+                    <StatisticCard.Statistic
+                      title={intl.formatMessage({ id: "admin.dict.parent" })}
+                      value={item.parent}
+                    />
+                  </>
+                ),
+              }}
+              style={{
+                borderInlineEnd: index < data.length - 1 ? "1px solid rgba(127,127,127,.15)" : undefined,
+              }}
+            />
+          ),
+          children: <UserDictTable view="all" dictName={item.key} />,
+        })),
+      }}
+    />
+  );
+};
+
+export default DictStatistics;

+ 86 - 0
dashboard-v6/src/features/admin/NissayaEndingEdit.tsx

@@ -0,0 +1,86 @@
+import { ModalForm, ProForm, ProFormText } from "@ant-design/pro-components";
+import { App, Form } from "antd";
+import { useState, type JSX } from "react";
+import { useIntl } from "react-intl";
+import { fetchNissayaEnding, saveNissayaEnding, type INissayaEnding } from "../../api/admin";
+import GrammarSelect from "../../components/admin/GrammarSelect";
+import LangSelect from "../../components/general/LangSelect";
+
+interface IWidget {
+  trigger?: JSX.Element;
+  /** 有 id 是编辑,没有是新建 */
+  id?: string;
+  onSuccess?: () => void;
+}
+
+/** 新建 / 编辑一条 Nissaya 语尾。 */
+const NissayaEndingEdit = ({ trigger = <>{"trigger"}</>, id, onSuccess }: IWidget) => {
+  const intl = useIntl();
+  const { message } = App.useApp();
+  const [form] = Form.useForm<INissayaEnding>();
+  const [title, setTitle] = useState<string | undefined>(id ? "" : intl.formatMessage({ id: "buttons.create" }));
+
+  return (
+    <ModalForm<INissayaEnding>
+      title={title}
+      trigger={trigger}
+      form={form}
+      autoFocusFirstInput
+      modalProps={{ destroyOnHidden: true }}
+      submitTimeout={2000}
+      onFinish={async (values) => {
+        const data = {
+          ...values,
+          from: { spell: values.fromSpell, case: values.fromCase ? values.fromCase : undefined },
+        };
+        const res = await saveNissayaEnding(data, id);
+        if (res.ok) {
+          message.success(intl.formatMessage({ id: "flashes.success" }));
+          onSuccess?.();
+        } else {
+          message.error(res.message);
+        }
+        return true;
+      }}
+      request={
+        id
+          ? async () => {
+              const res = await fetchNissayaEnding(id);
+              if (!res.ok) {
+                return { id: undefined, ending: "", relation: "", lang: "" };
+              }
+              setTitle(res.data.ending);
+              return {
+                id,
+                ending: res.data.ending,
+                relation: res.data.relation,
+                from: res.data.from,
+                fromCase: res.data.from?.case,
+                fromSpell: res.data.from?.spell,
+                lang: res.data.lang,
+              };
+            }
+          : undefined
+      }
+    >
+      <ProForm.Group>
+        <ProFormText
+          width="md"
+          name="ending"
+          label={intl.formatMessage({ id: "forms.fields.ending.label" })}
+          tooltip={intl.formatMessage({ id: "admin.nissaya.ending.tooltip" })}
+        />
+        <LangSelect width="md" />
+      </ProForm.Group>
+      <ProForm.Group>
+        <GrammarSelect name="fromCase" />
+        <ProFormText width="md" name="fromSpell" label={intl.formatMessage({ id: "buttons.spell" })} />
+      </ProForm.Group>
+      <ProForm.Group>
+        <ProFormText width="md" name="relation" label={intl.formatMessage({ id: "forms.fields.relation.label" })} />
+      </ProForm.Group>
+    </ModalForm>
+  );
+};
+
+export default NissayaEndingEdit;

+ 117 - 0
dashboard-v6/src/features/admin/NissayaEndingList.tsx

@@ -0,0 +1,117 @@
+import { useIntl } from "react-intl";
+import { App, Button } from "antd";
+import { ProTable } from "@ant-design/pro-components";
+import { ExclamationCircleOutlined, ExportOutlined, ImportOutlined, PlusOutlined } from "@ant-design/icons";
+import {
+  deleteNissayaEnding,
+  fetchNissayaEndingList,
+  NISSAYA_ENDING_EXPORT_URL,
+  NISSAYA_ENDING_IMPORT_URL,
+  type INissayaEnding,
+} from "../../api/admin";
+import DataImport from "../../components/general/DataImport";
+import { get as getUiLang } from "../../locales";
+import { getSorterUrl } from "../../utils";
+import NissayaEndingEdit from "./NissayaEndingEdit";
+import { nissayaEndingColumns } from "./nissayaEndingColumns";
+
+interface IParams {
+  relation?: string;
+  keyword?: string;
+}
+
+/**
+ * Nissaya 语尾表:增删改、预览、术语维护、导入导出。
+ * `relation` 来自路由 /admin/nissaya-ending/:relation,作为初始筛选。
+ */
+const NissayaEndingList = ({ relation }: { relation?: string }) => {
+  const intl = useIntl();
+  const { message, modal } = App.useApp();
+
+  const confirmDelete = (row: INissayaEnding, reload: () => void) => {
+    if (!row.id) return;
+    const id = row.id;
+    modal.confirm({
+      icon: <ExclamationCircleOutlined />,
+      title: intl.formatMessage({ id: "message.delete.confirm" }) + intl.formatMessage({ id: "message.irrevocable" }),
+      content: row.ending,
+      okText: intl.formatMessage({ id: "buttons.delete" }),
+      okType: "danger",
+      cancelText: intl.formatMessage({ id: "buttons.no" }),
+      onOk: () =>
+        deleteNissayaEnding(id)
+          .then((json) => {
+            if (json.ok) {
+              message.success(intl.formatMessage({ id: "flashes.success" }));
+              reload();
+            } else {
+              message.error(json.message);
+            }
+          })
+          .catch((e) => message.error(String(e?.message ?? e))),
+    });
+  };
+
+  return (
+    <ProTable<INissayaEnding, IParams>
+      search={{ filterType: "light" }}
+      options={{ search: true }}
+      form={{ initialValues: relation ? { relation } : undefined }}
+      columns={nissayaEndingColumns({ intl, onDelete: confirmDelete })}
+      request={async (params = {}, sorter, filter) => {
+        const pageSize = params.pageSize ?? 20;
+        const offset = ((params.current ?? 1) - 1) * pageSize;
+        let query = `&limit=${pageSize}&offset=${offset}&ui-lang=${getUiLang()}`;
+        if (params.keyword) query += `&search=${params.keyword}`;
+        if (params.relation) query += `&relation=${params.relation}`;
+        if (filter.case) query += `&case=${filter.case.join()}`;
+        if (filter.lang) query += `&lang=${filter.lang.join()}`;
+        query += getSorterUrl(sorter);
+
+        const res = await fetchNissayaEndingList(query);
+        return {
+          total: res.data.count,
+          success: res.ok,
+          data: res.data.rows.map((item, index) => ({
+            sn: offset + index + 1,
+            id: item.id,
+            ending: item.ending,
+            lang: item.lang,
+            relation: item.relation,
+            case: item.case,
+            from: item.from,
+            count: item.count,
+            termId: item.term_id,
+            termChannel: item.term_channel,
+            updated_at: item.updated_at,
+          })),
+        };
+      }}
+      rowKey="id"
+      bordered
+      pagination={{ showQuickJumper: true, showSizeChanger: true }}
+      toolBarRender={(action) => [
+        <DataImport
+          key="import"
+          url={NISSAYA_ENDING_IMPORT_URL}
+          trigger={<Button icon={<ImportOutlined />}>{intl.formatMessage({ id: "admin.import" })}</Button>}
+          onSuccess={() => action?.reload()}
+        />,
+        <Button key="export" icon={<ExportOutlined />} href={NISSAYA_ENDING_EXPORT_URL} target="_blank" rel="noreferrer">
+          {intl.formatMessage({ id: "admin.export" })}
+        </Button>,
+        <NissayaEndingEdit
+          key="create"
+          trigger={
+            <Button icon={<PlusOutlined />} type="primary">
+              {intl.formatMessage({ id: "buttons.create" })}
+            </Button>
+          }
+          onSuccess={() => action?.reload()}
+        />,
+      ]}
+    />
+  );
+};
+
+export default NissayaEndingList;

+ 97 - 0
dashboard-v6/src/features/admin/RelationEdit.tsx

@@ -0,0 +1,97 @@
+import { ModalForm, ProForm, ProFormSelect, ProFormText } from "@ant-design/pro-components";
+import { App, Form } from "antd";
+import { useState, type JSX } from "react";
+import { useIntl } from "react-intl";
+import { fetchRelation, saveRelation } from "../../api/admin";
+import type { IRelation } from "../../api/relation";
+import GrammarSelect from "../../components/admin/GrammarSelect";
+
+interface IWidget {
+  trigger?: JSX.Element;
+  /** 有 id 是编辑,没有是新建 */
+  id?: string;
+  onSuccess?: () => void;
+}
+
+/** 新建 / 编辑一条语法关系。 */
+const RelationEdit = ({ trigger = <>{"trigger"}</>, id, onSuccess }: IWidget) => {
+  const intl = useIntl();
+  const { message } = App.useApp();
+  const [form] = Form.useForm<IRelation>();
+  const [title, setTitle] = useState<string>(id ? "" : intl.formatMessage({ id: "buttons.create" }));
+
+  return (
+    <ModalForm<IRelation>
+      title={title}
+      trigger={trigger}
+      form={form}
+      autoFocusFirstInput
+      modalProps={{ destroyOnHidden: true }}
+      submitTimeout={3000}
+      onFinish={async (values) => {
+        const data = {
+          ...values,
+          from: { spell: values.fromSpell, case: values.fromCase },
+          to: { spell: values.toSpell, case: values.toCase },
+        };
+        const res = await saveRelation(data, id);
+        if (res.ok) {
+          message.success(intl.formatMessage({ id: "flashes.success" }));
+          onSuccess?.();
+        } else {
+          message.error(res.message);
+        }
+        return true;
+      }}
+      request={
+        id
+          ? async () => {
+              const res = await fetchRelation(id);
+              if (!res.ok) {
+                return { id: undefined, name: "" };
+              }
+              setTitle(res.data.name);
+              return {
+                id,
+                name: res.data.name,
+                case: res.data.case,
+                from: res.data.from,
+                fromCase: res.data.from?.case,
+                fromSpell: res.data.from?.spell,
+                to: res.data.to,
+                toCase: res.data.to?.case,
+                toSpell: res.data.to?.spell,
+                match: res.data.match ?? undefined,
+                category: res.data.category,
+              };
+            }
+          : undefined
+      }
+    >
+      <ProForm.Group>
+        <ProFormText width="md" name="name" label={intl.formatMessage({ id: "forms.fields.name.label" })} />
+      </ProForm.Group>
+      <ProForm.Group title={intl.formatMessage({ id: "forms.fields.from.label" })}>
+        <GrammarSelect name="fromCase" />
+        <ProFormText width="md" name="fromSpell" label={intl.formatMessage({ id: "buttons.spell" })} />
+      </ProForm.Group>
+      <ProForm.Group title={intl.formatMessage({ id: "forms.fields.to.label" })}>
+        <GrammarSelect name="toCase" />
+        <ProFormText width="md" name="toSpell" label={intl.formatMessage({ id: "buttons.spell" })} />
+      </ProForm.Group>
+      <ProForm.Group>
+        <ProFormSelect
+          options={["gender", "number", "case"].map((item) => ({ value: item, label: item }))}
+          fieldProps={{ mode: "tags" }}
+          width="md"
+          name="match"
+          allowClear={false}
+          label={intl.formatMessage({ id: "forms.fields.match.label" })}
+        />
+        <ProFormText width="md" name="category" label={intl.formatMessage({ id: "forms.fields.category.label" })} />
+      </ProForm.Group>
+    </ModalForm>
+  );
+};
+
+export default RelationEdit;

+ 103 - 0
dashboard-v6/src/features/admin/RelationList.tsx

@@ -0,0 +1,103 @@
+import { useIntl } from "react-intl";
+import { App, Button } from "antd";
+import { ProTable } from "@ant-design/pro-components";
+import { ExclamationCircleOutlined, ExportOutlined, ImportOutlined, PlusOutlined } from "@ant-design/icons";
+import { deleteRelation, fetchRelationList, RELATION_EXPORT_URL, RELATION_IMPORT_URL } from "../../api/admin";
+import type { IRelation } from "../../api/relation";
+import DataImport from "../../components/general/DataImport";
+import { get as getUiLang } from "../../locales";
+import { getSorterUrl } from "../../utils";
+import RelationEdit from "./RelationEdit";
+import { relationColumns } from "./relationColumns";
+
+interface IParams {
+  name?: string;
+  from?: string;
+  to?: string;
+  match?: string;
+  category?: string;
+  keyword?: string;
+}
+
+/** 语法关系表:增删改、导入导出、按名称 / 匹配 / 分类筛选。 */
+const RelationList = () => {
+  const intl = useIntl();
+  const { message, modal } = App.useApp();
+
+  const confirmDelete = (row: IRelation, reload: () => void) => {
+    if (!row.id) return;
+    const id = row.id;
+    modal.confirm({
+      icon: <ExclamationCircleOutlined />,
+      title: intl.formatMessage({ id: "message.delete.confirm" }) + intl.formatMessage({ id: "message.irrevocable" }),
+      content: row.name,
+      okText: intl.formatMessage({ id: "buttons.delete" }),
+      okType: "danger",
+      cancelText: intl.formatMessage({ id: "buttons.no" }),
+      onOk: () =>
+        deleteRelation(id)
+          .then((json) => {
+            if (json.ok) {
+              message.success(intl.formatMessage({ id: "flashes.success" }));
+              reload();
+            } else {
+              message.error(json.message);
+            }
+          })
+          .catch((e) => message.error(String(e?.message ?? e))),
+    });
+  };
+
+  return (
+    <ProTable<IRelation, IParams>
+      columns={relationColumns({ intl, onDelete: confirmDelete })}
+      request={async (params = {}, sorter, filter) => {
+        const pageSize = params.pageSize ?? 20;
+        const offset = ((params.current ?? 1) - 1) * pageSize;
+        let query = `&ui-lang=${getUiLang()}&limit=${pageSize}&offset=${offset}`;
+        if (typeof params.keyword !== "undefined") query += `&search=${params.keyword ?? ""}`;
+        if (filter.case) query += `&case=${filter.case.join()}`;
+        if (params.name) query += `&name=${params.name}`;
+        if (params.match) query += `&match=${params.match}`;
+        if (params.from) query += `&from=${params.from}`;
+        if (params.to) query += `&to=${params.to}`;
+        if (params.category) query += `&category=${params.category}`;
+        query += getSorterUrl(sorter);
+
+        const res = await fetchRelationList(query);
+        return {
+          total: res.data.count,
+          success: res.ok,
+          data: res.data.rows.map((item, index) => ({ ...item, sn: offset + index + 1 })),
+        };
+      }}
+      rowKey="id"
+      bordered
+      pagination={{ showQuickJumper: true, showSizeChanger: true }}
+      options={{ search: true }}
+      search={{ filterType: "light" }}
+      toolBarRender={(action) => [
+        <DataImport
+          key="import"
+          url={RELATION_IMPORT_URL}
+          trigger={<Button icon={<ImportOutlined />}>{intl.formatMessage({ id: "admin.import" })}</Button>}
+          onSuccess={() => action?.reload()}
+        />,
+        <Button key="export" icon={<ExportOutlined />} href={RELATION_EXPORT_URL} target="_blank" rel="noreferrer">
+          {intl.formatMessage({ id: "admin.export" })}
+        </Button>,
+        <RelationEdit
+          key="create"
+          trigger={
+            <Button icon={<PlusOutlined />} type="primary">
+              {intl.formatMessage({ id: "buttons.create" })}
+            </Button>
+          }
+          onSuccess={() => action?.reload()}
+        />,
+      ]}
+    />
+  );
+};
+
+export default RelationList;

+ 57 - 0
dashboard-v6/src/features/admin/SystemModels.tsx

@@ -0,0 +1,57 @@
+import { App, Divider, Transfer } from "antd";
+import { useState } from "react";
+import { useIntl } from "react-intl";
+import { saveSystemModels } from "../../api/admin";
+import { useAppSelector } from "../../hooks";
+import { useChatModelOptions, type IModelOption } from "../../hooks/useAdmin";
+import { siteInfo } from "../../reducers/layout";
+
+type TModelUse = "wbw" | "chat" | "summarize";
+const USES: TModelUse[] = ["wbw", "chat", "summarize"];
+
+/** 某一种用途的系统模型:左边全部可选模型,右边已选(改动即保存)。 */
+const ModelUseTransfer = ({ use, models }: { use: TModelUse; models?: IModelOption[] }) => {
+  const intl = useIntl();
+  const { message } = App.useApp();
+  const site = useAppSelector(siteInfo);
+  // 站点设置里只有 wbw / chat 两类(summarize 还没有回读,与 v4 一致);用户改过就以改后的为准
+  const saved = use === "wbw" || use === "chat" ? site?.settings?.models?.[use] : undefined;
+  const [edited, setEdited] = useState<string[] | null>(null);
+  const targetKeys = edited ?? saved?.map((item) => item.uid) ?? [];
+  const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
+
+  return (
+    <Transfer
+      dataSource={models}
+      titles={[intl.formatMessage({ id: "admin.models.all" }), intl.formatMessage({ id: "admin.models.selected" })]}
+      targetKeys={targetKeys}
+      selectedKeys={selectedKeys}
+      onChange={(next) => {
+        const keys = next.map(String);
+        setEdited(keys);
+        saveSystemModels(use, keys)
+          .then((json) => (json.ok ? message.success(intl.formatMessage({ id: "flashes.success" })) : message.error(json.message)))
+          .catch((e) => message.error(String(e?.message ?? e)));
+      }}
+      onSelectChange={(source, target) => setSelectedKeys([...source, ...target].map(String))}
+      render={(item) => item.title}
+    />
+  );
+};
+
+/** 系统级 AI 模型:逐词解析 / 对话 / 摘要 各用哪些模型。 */
+const SystemModels = () => {
+  const models = useChatModelOptions();
+  return (
+    <div>
+      {USES.map((use) => (
+        <div key={use}>
+          <Divider>{use}</Divider>
+          <ModelUseTransfer models={models} use={use} />
+        </div>
+      ))}
+    </div>
+  );
+};
+
+export default SystemModels;

+ 91 - 0
dashboard-v6/src/features/admin/UserList.tsx

@@ -0,0 +1,91 @@
+import { Space, Tag, Typography } from "antd";
+import { ProList } from "@ant-design/pro-components";
+import { useIntl } from "react-intl";
+import { Link } from "react-router";
+import { fetchUserList } from "../../api/admin";
+import type { IUserApiData } from "../../api/Auth";
+import User from "../../components/auth/User";
+import TimeShow from "../../components/general/TimeShow";
+import { getSorterUrl } from "../../utils";
+
+interface IParams {
+  role?: string;
+  keyword?: string;
+}
+
+/** 全站用户列表:按角色筛选、关键词搜索,点昵称进详情。 */
+const UserList = () => {
+  const intl = useIntl();
+  const t = (id: string) => intl.formatMessage({ id });
+
+  return (
+    <ProList<IUserApiData, IParams>
+      metas={{
+        title: {
+          dataIndex: "title",
+          search: false,
+          render: (_, entity) => <Link to={`/admin/users/${entity.id}`}>{entity.nickName}</Link>,
+        },
+        description: {
+          editable: false,
+          search: false,
+          render: (_, entity) => (
+            <Typography.Text type="secondary">
+              <Space>
+                {entity.userName}
+                <TimeShow type="secondary" createdAt={entity.created_at} updatedAt={entity.updated_at} />
+              </Space>
+            </Typography.Text>
+          ),
+        },
+        subTitle: {
+          search: false,
+          render: (_, entity) =>
+            entity.role ? (
+              <Space>
+                {entity.role.map((item) => (
+                  <Tag key={item}>{item}</Tag>
+                ))}
+              </Space>
+            ) : null,
+        },
+        avatar: {
+          editable: false,
+          search: false,
+          render: (_, entity) => (
+            <User avatar={entity.avatar} userName={entity.userName} nickName={entity.nickName} showName={false} />
+          ),
+        },
+        role: {
+          // 只用于筛选,不在列表里显示
+          title: t("admin.users.role"),
+          valueType: "select",
+          valueEnum: {
+            administrator: { text: t("admin.users.role.administrator"), status: "Error" },
+            uploader: { text: t("admin.users.role.uploader"), status: "Success" },
+            member: { text: t("admin.users.role.member"), status: "Processing" },
+            basic: { text: t("admin.users.role.basic"), status: "Processing" },
+          },
+        },
+      }}
+      request={async (params = {}, sorter) => {
+        const pageSize = params.pageSize ?? 20;
+        const offset = ((params.current ?? 1) - 1) * pageSize;
+        let query = `&limit=${pageSize}&offset=${offset}`;
+        if (params.keyword) query += `&search=${params.keyword}`;
+        if (params.role) query += `&role=${params.role}`;
+        query += getSorterUrl(sorter);
+        const res = await fetchUserList(query);
+        return { total: res.data.count, success: res.ok, data: res.data.rows };
+      }}
+      rowKey="id"
+      bordered
+      pagination={{ showQuickJumper: true, showSizeChanger: true }}
+      search={{ filterType: "light" }}
+      options={{ search: true }}
+      headerTitle=""
+    />
+  );
+};
+
+export default UserList;

+ 103 - 0
dashboard-v6/src/features/admin/nissayaEndingColumns.tsx

@@ -0,0 +1,103 @@
+import { Button, Dropdown, Space } from "antd";
+import type { ProColumns } from "@ant-design/pro-components";
+import { DeleteOutlined, MoreOutlined } from "@ant-design/icons";
+import type { IntlShape } from "react-intl";
+import type { INissayaEnding } from "../../api/admin";
+import GrammarTags from "../../components/admin/GrammarTags";
+import { LangValueEnum } from "../../components/general/LangSelect";
+import TimeShow from "../../components/general/TimeShow";
+import { NissayaCardModal } from "../../components/nissaya/NissayaCard";
+import TermModal from "../../components/term/TermModal";
+import NissayaEndingEdit from "./NissayaEndingEdit";
+
+interface IOptions {
+  intl: IntlShape;
+  /** 删除(确认后由调用方删,删完调 reload) */
+  onDelete: (row: INissayaEnding, reload: () => void) => void;
+}
+
+/** 列定义。刷新用 ProTable 传给 render 的 action,不经 ref。 */
+export const nissayaEndingColumns = ({ intl, onDelete }: IOptions): ProColumns<INissayaEnding>[] => {
+  const t = (id: string) => intl.formatMessage({ id });
+  return [
+    { title: t("dict.fields.sn.label"), dataIndex: "sn", key: "sn", width: 50, search: false },
+    {
+      title: t("forms.fields.ending.label"),
+      dataIndex: "ending",
+      key: "ending",
+      search: false,
+      sorter: true,
+      render: (_, row, _i, action) => (
+        <Space>
+          <NissayaEndingEdit
+            id={row.id}
+            trigger={
+              <Button type="link" size="small">
+                {row.ending}
+              </Button>
+            }
+            onSuccess={() => action?.reload()}
+          />
+          {row.termChannel ? (
+            <TermModal
+              trigger={<Button size="small">{t("admin.nissaya.term")}</Button>}
+              id={row.termId}
+              word={row.ending}
+              channelId={row.termChannel}
+            />
+          ) : null}
+        </Space>
+      ),
+    },
+    {
+      title: t("forms.fields.lang.label"),
+      dataIndex: "lang",
+      key: "lang",
+      search: false,
+      filters: true,
+      valueEnum: LangValueEnum(),
+    },
+    {
+      title: t("forms.fields.from.label"),
+      dataIndex: "from",
+      key: "from",
+      search: false,
+      render: (_, row) => <GrammarTags value={row.from} />,
+    },
+    { title: t("forms.fields.relation.label"), dataIndex: "relation", key: "relation", sorter: true },
+    { title: t("forms.fields.count.label"), key: "count", width: 100, search: false, dataIndex: "count", sorter: true },
+    {
+      title: t("forms.fields.updated-at.label"),
+      key: "updated_at",
+      width: 100,
+      search: false,
+      dataIndex: "updated_at",
+      valueType: "date",
+      sorter: true,
+      render: (_, row) => <TimeShow updatedAt={row.updated_at} showLabel showIcon={false} />,
+    },
+    {
+      title: t("buttons.option"),
+      key: "option",
+      width: 130,
+      valueType: "option",
+      render: (_, row, _i, action) => [
+        <NissayaCardModal key="preview" text={row.ending} trigger={<Button type="link" size="small">{t("buttons.preview")}</Button>} />,
+        <Dropdown
+          key="more"
+          trigger={["click"]}
+          menu={{
+            items: [{ key: "remove", label: t("buttons.delete"), icon: <DeleteOutlined />, danger: true }],
+            onClick: (e) => {
+              if (e.key === "remove") {
+                onDelete(row, () => action?.reload());
+              }
+            },
+          }}
+        >
+          <Button type="link" size="small" icon={<MoreOutlined />} />
+        </Dropdown>,
+      ],
+    },
+  ];
+};

+ 130 - 0
dashboard-v6/src/features/admin/relationColumns.tsx

@@ -0,0 +1,130 @@
+import { Button, Dropdown, Space, Tag } from "antd";
+import type { ProColumns } from "@ant-design/pro-components";
+import { DeleteOutlined, MoreOutlined } from "@ant-design/icons";
+import type { IntlShape } from "react-intl";
+import type { IRelation } from "../../api/relation";
+import GrammarTags from "../../components/admin/GrammarTags";
+import TimeShow from "../../components/general/TimeShow";
+import TermCell from "../../components/admin/TermCell";
+import RelationEdit from "./RelationEdit";
+
+interface IOptions {
+  intl: IntlShape;
+  /** 删除(确认后由调用方删,删完调 reload) */
+  onDelete: (row: IRelation, reload: () => void) => void;
+}
+
+/** 列定义。刷新用 ProTable 传给 render 的 action,不经 ref。 */
+export const relationColumns = ({ intl, onDelete }: IOptions): ProColumns<IRelation>[] => {
+  const t = (id: string) => intl.formatMessage({ id });
+  return [
+    { title: t("dict.fields.sn.label"), dataIndex: "sn", key: "sn", width: 50, search: false },
+    {
+      title: t("forms.fields.relation.label"),
+      dataIndex: "name",
+      key: "name",
+      sorter: true,
+      render: (_, row, _i, action) => (
+        <RelationEdit
+          id={row.id}
+          trigger={
+            <Button type="link" size="small">
+              {row.name}
+            </Button>
+          }
+          onSuccess={() => action?.reload()}
+        />
+      ),
+    },
+    {
+      title: t("forms.fields.name.label"),
+      dataIndex: "name1",
+      key: "name1",
+      search: false,
+      render: (_, row, _i, action) => (
+        <TermCell
+          term={row.name_term}
+          word={row.name}
+          channelId={row.name_term ? row.category_channel : row.name_channel}
+          reload={() => action?.reload()}
+          createLabel={t("buttons.create")}
+        />
+      ),
+    },
+    {
+      title: t("forms.fields.from.label"),
+      dataIndex: "from",
+      key: "from",
+      render: (_, row) => <GrammarTags value={row.from} />,
+    },
+    {
+      title: t("forms.fields.to.label"),
+      dataIndex: "to",
+      key: "to",
+      render: (_, row) => <GrammarTags value={row.to} />,
+    },
+    {
+      title: t("forms.fields.match.label"),
+      dataIndex: "match",
+      key: "match",
+      render: (_, row) => row.match?.map((item) => <Tag key={item}>{item}</Tag>),
+    },
+    {
+      title: t("forms.fields.category.label"),
+      dataIndex: "category",
+      key: "category",
+      sorter: true,
+      render: (_, row, _i, action) => (
+        <Space>
+          {row.category}
+          <TermCell
+            term={row.category_term}
+            word={row.category}
+            channelId={row.category_channel}
+            reload={() => action?.reload()}
+            createLabel={t("buttons.create")}
+          />
+        </Space>
+      ),
+    },
+    {
+      title: t("forms.fields.editor.label"),
+      dataIndex: "editor",
+      key: "editor",
+      search: false,
+      render: (_, row) => row.editor?.nickName,
+    },
+    {
+      title: t("forms.fields.updated-at.label"),
+      key: "updated_at",
+      width: 100,
+      search: false,
+      dataIndex: "updated_at",
+      valueType: "date",
+      sorter: true,
+      render: (_, row) => <TimeShow updatedAt={row.updated_at} showLabel={false} showIcon={false} />,
+    },
+    {
+      title: t("buttons.option"),
+      key: "option",
+      width: 80,
+      valueType: "option",
+      render: (_, row, _i, action) => [
+        <Dropdown
+          key="more"
+          trigger={["click"]}
+          menu={{
+            items: [{ key: "remove", label: t("buttons.delete"), icon: <DeleteOutlined />, danger: true }],
+            onClick: (e) => {
+              if (e.key === "remove") {
+                onDelete(row, () => action?.reload());
+              }
+            },
+          }}
+        >
+          <Button type="link" size="small" icon={<MoreOutlined />} />
+        </Dropdown>,
+      ],
+    },
+  ];
+};

+ 73 - 0
dashboard-v6/src/hooks/useAdmin.ts

@@ -0,0 +1,73 @@
+// 管理后台用到的数据 hook(API 监控、词典统计、系统模型)。
+import { useEffect, useState } from "react";
+import {
+  fetchApiAverage,
+  fetchApiStat,
+  fetchChatModels,
+  fetchDictStatistic,
+  type IApiStatPoint,
+  type IDictStatistic,
+  type TApiStatItem,
+} from "../api/admin";
+
+/** 接口统计序列(加载一次)。 */
+export function useApiStat(item: TApiStatItem, api = "all") {
+  const [data, setData] = useState<IApiStatPoint[]>([]);
+  useEffect(() => {
+    let alive = true;
+    fetchApiStat(item, api)
+      .then((json) => alive && setData(json.data ?? []))
+      .catch((e) => console.error("api stat", e));
+    return () => {
+      alive = false;
+    };
+  }, [item, api]);
+  return data;
+}
+
+/** 当前平均响应时间,每 5 秒刷新一次。 */
+export function useApiAverage(intervalMs = 5000) {
+  const [delay, setDelay] = useState(0);
+  useEffect(() => {
+    const load = () =>
+      fetchApiAverage()
+        .then((json) => setDelay(json.data))
+        .catch((e) => console.error("api average", e));
+    load();
+    const timer = setInterval(load, intervalMs);
+    return () => clearInterval(timer);
+  }, [intervalMs]);
+  return delay;
+}
+
+/** 各词典的词条 / 单词表 / 词干数。 */
+export function useDictStatistic() {
+  const [data, setData] = useState<IDictStatistic[]>();
+  useEffect(() => {
+    fetchDictStatistic()
+      .then((json) => json.ok && setData(json.data))
+      .catch((e) => console.error("dict statistic", e));
+  }, []);
+  return data;
+}
+
+export interface IModelOption {
+  key: string;
+  title: string;
+  description?: string;
+}
+
+/** 可设为系统模型的 AI 模型(chat 视图)。 */
+export function useChatModelOptions() {
+  const [models, setModels] = useState<IModelOption[]>();
+  useEffect(() => {
+    fetchChatModels()
+      .then((json) => {
+        if (json.ok) {
+          setModels(json.data.rows.map((item) => ({ key: item.uid, title: item.name, description: item.model })));
+        }
+      })
+      .catch((e) => console.error("ai models", e));
+  }, []);
+  return models;
+}

+ 87 - 0
dashboard-v6/src/hooks/useAdminStats.ts

@@ -0,0 +1,87 @@
+// src/hooks/useAdminStats.ts
+/**
+ * 管理后台统计的数据 hook:阅读统计、AI 对话统计、提问列表、单次研究过程。
+ *
+ * 参数变了就重新请求;后到的旧请求结果丢弃(快速切换区间时不会被旧数据覆盖)。
+ * 失败的提示由 api 层的 unwrap() 统一弹出,这里只把 error 交给页面渲染失败状态。
+ *
+ * @example
+ * const { data, loading, error, refresh } = useReadingStats({ from, to, client });
+ */
+import { useCallback, useEffect, useRef, useState } from "react";
+import {
+  getAgentFeedback,
+  getAgentRun,
+  getAgentRuns,
+  getAgentStats,
+  getReadingStats,
+  type AgentFeedbackList,
+  type AgentFeedbackQuery,
+  type AgentRunDetail,
+  type AgentRunList,
+  type AgentRunQuery,
+  type AgentStats,
+  type AgentStatsQuery,
+  type ReadingStats,
+  type ReadingStatsQuery,
+} from "../api/adminStats";
+
+interface AsyncState<T> {
+  data: T | null;
+  loading: boolean;
+  error: unknown;
+  refresh: () => void;
+}
+
+const useAsync = <T>(load: (() => Promise<T>) | null, key: string): AsyncState<T> => {
+  const [data, setData] = useState<T | null>(null);
+  const [loading, setLoading] = useState(false);
+  const [error, setError] = useState<unknown>(null);
+  const [tick, setTick] = useState(0);
+  const loadRef = useRef(load);
+  // 最新的 load 放进 ref(在 effect 里写,渲染期间不碰 ref);请求只跟着 key / tick 走
+  useEffect(() => {
+    loadRef.current = load;
+  });
+
+  useEffect(() => {
+    const run = loadRef.current;
+    if (!run) return;
+    let alive = true;
+    const fetchData = async () => {
+      setLoading(true);
+      setError(null);
+      try {
+        const d = await run();
+        if (alive) setData(d);
+      } catch (e) {
+        if (alive) setError(e);
+      } finally {
+        if (alive) setLoading(false);
+      }
+    };
+    void fetchData();
+    return () => {
+      alive = false;
+    };
+  }, [key, tick]);
+
+  const refresh = useCallback(() => setTick((t) => t + 1), []);
+  return { data, loading, error, refresh };
+};
+
+export const useReadingStats = (query: ReadingStatsQuery): AsyncState<ReadingStats> =>
+  useAsync(() => getReadingStats(query), JSON.stringify(query));
+
+export const useAgentStats = (query: AgentStatsQuery): AsyncState<AgentStats> =>
+  useAsync(() => getAgentStats(query), JSON.stringify(query));
+
+export const useAgentRuns = (query: AgentRunQuery): AsyncState<AgentRunList> =>
+  useAsync(() => getAgentRuns(query), JSON.stringify(query));
+
+/** runId 为 null 时不请求(抽屉关着)。 */
+export const useAgentRun = (runId: string | null): AsyncState<AgentRunDetail> =>
+  useAsync(runId ? () => getAgentRun(runId) : null, runId ?? "");
+
+export const useAgentFeedback = (query: AgentFeedbackQuery): AsyncState<AgentFeedbackList> =>
+  useAsync(() => getAgentFeedback(query), JSON.stringify(query));

+ 149 - 0
dashboard-v6/src/layouts/admin/index.tsx

@@ -0,0 +1,149 @@
+import { useState } from "react";
+import { Button, Layout, Menu, Result, Space, Spin, type MenuProps } from "antd";
+import { Link, Navigate, Outlet, useLocation } from "react-router";
+import { useIntl } from "react-intl";
+import {
+  ApartmentOutlined,
+  ApiOutlined,
+  BarChartOutlined,
+  BookOutlined,
+  DashboardOutlined,
+  FontSizeOutlined,
+  MailOutlined,
+  MenuFoldOutlined,
+  MenuUnfoldOutlined,
+  ReadOutlined,
+  RobotOutlined,
+  SettingOutlined,
+  TeamOutlined,
+} from "@ant-design/icons";
+import { useAuth } from "../../hooks/useAuth";
+import { useAppSelector } from "../../hooks";
+import { currentUser, isAdministrator, isGuest, isRoot, TO_SIGN_IN } from "../../reducers/current-user";
+import SignInAvatar from "../../components/auth/SignInAvatar";
+import HeaderBreadcrumb from "../../components/navigation/HeaderBreadcrumb";
+import ThemeSwitch from "../../components/theme/ThemeSwitch";
+import UiLangSelect from "../../components/general/UiLangSelect";
+
+const { Sider, Content } = Layout;
+
+/** 菜单项的 key 就是路由;选中项按当前路径的最长前缀匹配。 */
+const MENU_PATHS = [
+  "/admin/stats/reading",
+  "/admin/stats/ai",
+  "/admin/api",
+  "/admin/relation",
+  "/admin/nissaya-ending",
+  "/admin/dictionary/preference",
+  "/admin/dictionary",
+  "/admin/users",
+  "/admin/invite",
+  "/admin/ai-models",
+];
+
+/**
+ * 管理后台外壳:左侧菜单 + 顶部面包屑。只有 root / administrator 能进,
+ * 其他已登录用户看到 403;没登录跳登录页。
+ */
+const AdminLayout = () => {
+  const intl = useIntl();
+  const { pathname } = useLocation();
+  const { isAuthenticated } = useAuth();
+  const user = useAppSelector(currentUser);
+  const guest = useAppSelector(isGuest);
+  const root = useAppSelector(isRoot);
+  const admin = useAppSelector(isAdministrator);
+  const [collapsed, setCollapsed] = useState(false);
+
+  if (!isAuthenticated) {
+    return <Navigate to={TO_SIGN_IN} replace />;
+  }
+  // 当前用户还在加载(load.ts 里 /auth/current 未返回):先别判 403
+  if (!user && !guest) {
+    return <Spin fullscreen />;
+  }
+  if (!root && !admin) {
+    return <Result status="403" title="403" subTitle={intl.formatMessage({ id: "admin.forbidden" })} />;
+  }
+
+  const t = (id: string) => intl.formatMessage({ id });
+  const link = (path: string, id: string) => <Link to={path}>{t(id)}</Link>;
+  const items: MenuProps["items"] = [
+    {
+      key: "stats",
+      type: "group",
+      label: t("admin.menu.stats"),
+      children: [
+        { key: "/admin/stats/reading", icon: <ReadOutlined />, label: link("/admin/stats/reading", "admin.menu.stats.reading") },
+        { key: "/admin/stats/ai", icon: <RobotOutlined />, label: link("/admin/stats/ai", "admin.menu.stats.ai") },
+        { key: "/admin/api", icon: <DashboardOutlined />, label: link("/admin/api", "admin.menu.api") },
+      ],
+    },
+    {
+      key: "manage",
+      type: "group",
+      label: t("admin.menu.manage"),
+      children: [
+        { key: "/admin/relation", icon: <ApartmentOutlined />, label: link("/admin/relation", "admin.menu.relation") },
+        {
+          key: "/admin/nissaya-ending",
+          icon: <FontSizeOutlined />,
+          label: link("/admin/nissaya-ending", "admin.menu.nissaya-ending"),
+        },
+        { key: "/admin/dictionary", icon: <BookOutlined />, label: link("/admin/dictionary", "admin.menu.dictionary") },
+        {
+          key: "/admin/dictionary/preference",
+          icon: <SettingOutlined />,
+          label: link("/admin/dictionary/preference", "admin.menu.dictionary.preference"),
+        },
+        { key: "/admin/users", icon: <TeamOutlined />, label: link("/admin/users", "admin.menu.users") },
+        { key: "/admin/invite", icon: <MailOutlined />, label: link("/admin/invite", "admin.menu.invite") },
+        { key: "/admin/ai-models", icon: <ApiOutlined />, label: link("/admin/ai-models", "admin.menu.ai-models") },
+      ],
+    },
+  ];
+  const selected = MENU_PATHS.find((path) => pathname === path || pathname.startsWith(`${path}/`));
+
+  return (
+    <Layout style={{ minHeight: "100vh" }}>
+      <Sider
+        style={{ backgroundColor: "unset" }}
+        width={208}
+        breakpoint="lg"
+        collapsedWidth={0}
+        trigger={null}
+        collapsible
+        collapsed={collapsed}
+        onBreakpoint={(broken) => setCollapsed(broken)}
+      >
+        <div style={{ padding: "12px 16px", display: "flex", alignItems: "center", gap: 8 }}>
+          <BarChartOutlined />
+          <strong>{t("admin.title")}</strong>
+        </div>
+        <Menu mode="inline" selectedKeys={selected ? [selected] : []} items={items} style={{ borderInlineEnd: 0 }} />
+      </Sider>
+      <Layout>
+        <div style={{ padding: "12px 16px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 }}>
+          <Space>
+            <Button
+              type="text"
+              icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
+              onClick={() => setCollapsed(!collapsed)}
+            />
+            <HeaderBreadcrumb />
+          </Space>
+          <Space size="middle">
+            <ThemeSwitch />
+            <UiLangSelect />
+            <SignInAvatar />
+          </Space>
+        </div>
+        <Content style={{ padding: 12, minWidth: 0 }}>
+          <Outlet />
+        </Content>
+      </Layout>
+    </Layout>
+  );
+};
+
+export default AdminLayout;

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

@@ -10,6 +10,8 @@ import message from "./en-US/message";
 import label from "./en-US/label";
 import error from "./en-US/error";
 import pages from "./en-US/pages";
+import admin from "./en-US/admin";
+import adminStats from "./en-US/admin-stats";
 
 const items = {
   "columns.library.title": "Library",
@@ -59,6 +61,8 @@ const items = {
   ...label,
   ...error,
   ...pages,
+  ...admin,
+  ...adminStats,
 };
 
 export default items;

+ 139 - 0
dashboard-v6/src/locales/en-US/admin-stats.ts

@@ -0,0 +1,139 @@
+// Admin statistics pages (/admin/stats/*)
+const items = {
+  "admin.stats.reading.title": "Reading statistics",
+  "admin.stats.ai.title": "AI chat statistics",
+  "admin.stats.range.7": "Last 7 days",
+  "admin.stats.range.30": "Last 30 days",
+  "admin.stats.range.90": "Last 90 days",
+  "admin.stats.client.all": "All",
+  "admin.stats.client.web": "Web",
+  "admin.stats.client.mobile": "App",
+  "admin.stats.account.all": "All",
+  "admin.stats.account.user": "Signed in",
+  "admin.stats.account.guest": "Guests",
+  "admin.stats.compare": "vs. previous",
+  "admin.stats.source": "Source: {source}",
+  "admin.stats.na": "N/A",
+  "admin.stats.reading.readers": "Active readers",
+  "admin.stats.reading.readers.tip": "Distinct signed-in users whose reading history changed in the range (guests' reading is not visible to the server)",
+  "admin.stats.reading.dau": "DAU {dau}",
+  "admin.stats.reading.sticky": "DAU/MAU {ratio}%",
+  "admin.stats.reading.time": "Reading time",
+  "admin.stats.reading.time.tip": "Counted only while the App reader is in front and the reader scrolled within 3 minutes; the web has no timer",
+  "admin.stats.reading.time.unit": "hours",
+  "admin.stats.reading.time.avg": "{users} readers, {minutes} min each",
+  "admin.stats.reading.chapters": "Chapters opened",
+  "admin.stats.reading.chapters.tip": "Reading-history rows updated in the range (one row per user and chapter)",
+  "admin.stats.reading.chapters.avg": "{avg} per reader",
+  "admin.stats.reading.lookups": "Dictionary lookups",
+  "admin.stats.reading.lookups.tip": "Lookups by signed-in users through the v2 API",
+  "admin.stats.reading.views": "{views} chapter views (incl. guests and crawlers)",
+  "admin.stats.reading.trend.readers": "Active readers",
+  "admin.stats.reading.trend.minutes": "Reading time (min)",
+  "admin.stats.reading.trend.lookups": "Lookups",
+  "admin.stats.reading.top": "Top 10 chapters",
+  "admin.stats.reading.top.readers": "{n} readers",
+  "admin.stats.reading.pitaka": "What: by piṭaka",
+  "admin.stats.reading.layer": "What: mūla / aṭṭhakathā / ṭīkā",
+  "admin.stats.reading.duration": "How long: reading time per day (min)",
+  "admin.stats.reading.credits": "Reading credits",
+  "admin.stats.reading.credits.total": "Granted",
+  "admin.stats.reading.credits.users": "Readers credited",
+  "admin.stats.reading.credits.capped": "Hit daily cap (user-days)",
+  "admin.stats.reading.credits.clamped": "Clamped",
+  "admin.stats.reading.credits.clamped.tip": "Share of reported seconds cut back to wall-clock time; a jump means suspicious reports",
+  "admin.stats.tag.sutta": "Sutta",
+  "admin.stats.tag.vinaya": "Vinaya",
+  "admin.stats.tag.abhidhamma": "Abhidhamma",
+  "admin.stats.tag.añña": "Añña",
+  "admin.stats.tag.mūla": "Mūla",
+  "admin.stats.tag.aṭṭhakathā": "Aṭṭhakathā",
+  "admin.stats.tag.ṭīkā": "Ṭīkā",
+  "admin.stats.tag.other": "Other",
+  "admin.stats.empty": "No data in this range yet",
+  "admin.stats.ai.runs": "Questions",
+  "admin.stats.ai.runs.deep": "Deep thinking {ratio}%",
+  "admin.stats.ai.runs.passage": "From the reader {ratio}%",
+  "admin.stats.ai.askers": "People asking",
+  "admin.stats.ai.askers.tip": "Signed-in users by account, guests by anonymous device id",
+  "admin.stats.ai.askers.split": "Signed in {user} · guests {guest}",
+  "admin.stats.ai.latency": "Response time P50",
+  "admin.stats.ai.latency.p95": "P95 {seconds} s",
+  "admin.stats.ai.seconds": "s",
+  "admin.stats.ai.failed": "Blocked / failed",
+  "admin.stats.ai.failed.tip": "Blocked = status denied (out of credits); failed = status error (credits refunded)",
+  "admin.stats.ai.failed.split": "Blocked {denied} · failed {errors} · let through unchecked {unchecked}",
+  "admin.stats.ai.daily": "Questions per day (by research route)",
+  "admin.stats.ai.latency.daily": "Response time (s)",
+  "admin.stats.ai.tools": "Top tool calls",
+  "admin.stats.ai.credits": "Credit flows",
+  "admin.stats.ai.credits.spent_free": "Free spent",
+  "admin.stats.ai.credits.spent_earned": "Credits spent",
+  "admin.stats.ai.credits.refunded": "Refunded",
+  "admin.stats.ai.credits.earned_reading": "Earned reading",
+  "admin.stats.ai.credits.earned_editing": "Earned editing",
+  "admin.stats.ai.credits.adjusted": "Adjusted",
+  "admin.stats.ai.tokens": "Tokens and improvement",
+  "admin.stats.ai.tokens.in": "Input tokens",
+  "admin.stats.ai.tokens.out": "Output tokens",
+  "admin.stats.ai.tokens.per_run": "Tokens per question",
+  "admin.stats.ai.improve": "Usable for improvement",
+  "admin.stats.ai.improve.tip": "Share of questions whose asker allows using them to improve answers; the others are stored but skipped for evaluation",
+  "admin.stats.ai.clients": "Clients",
+  "admin.stats.route.question": "General question",
+  "admin.stats.route.term": "Term / word",
+  "admin.stats.route.passage": "From the reader",
+  "admin.stats.route.chat": "Chat",
+  "admin.stats.route.none": "No route",
+  "admin.stats.runs.title": "Questions",
+  "admin.stats.runs.search": "Search question text",
+  "admin.stats.runs.time": "Time",
+  "admin.stats.runs.question": "Question",
+  "admin.stats.runs.account": "Account",
+  "admin.stats.runs.client": "Client",
+  "admin.stats.runs.route": "Route",
+  "admin.stats.runs.deep": "Deep",
+  "admin.stats.runs.latency": "Time taken",
+  "admin.stats.runs.status": "Status",
+  "admin.stats.runs.improve": "Improve",
+  "admin.stats.runs.guest": "Guest",
+  "admin.stats.status.ok": "Done",
+  "admin.stats.status.denied": "Out of credits",
+  "admin.stats.status.error": "Failed",
+  "admin.stats.status.cancelled": "Cancelled",
+  "admin.stats.run.title": "Research process",
+  "admin.stats.run.answer": "Answer",
+  "admin.stats.run.evidence": "Evidence given to the answering model",
+  "admin.stats.run.plan": "Research plan",
+  "admin.stats.run.steps": "Steps",
+  "admin.stats.run.device": "Device {device}",
+  "admin.stats.run.thread": "Conversation",
+  "admin.stats.run.model": "Model",
+  "admin.stats.run.tokens": "Tokens",
+  "admin.stats.run.error": "Error",
+  "admin.stats.run.chars": "{chars} chars",
+  "admin.stats.feedback.title": "User ratings",
+  "admin.stats.feedback.review": "Rating review",
+  "admin.stats.feedback.up": "Helpful",
+  "admin.stats.feedback.down": "Not helpful",
+  "admin.stats.feedback.coverage": "Rated",
+  "admin.stats.feedback.rating": "Rating",
+  "admin.stats.feedback.tags": "Tags / reasons",
+  "admin.stats.feedback.asked": "Asked",
+  "admin.stats.feedback.asked.tip": "Given after the app asked whether the answer helped",
+  "admin.stats.feedback.no_run": "Question not stored yet",
+  "admin.stats.feedback.tag.accurate": "Accurate",
+  "admin.stats.feedback.tag.useful_citations": "Useful sources",
+  "admin.stats.feedback.tag.clear": "Clear",
+  "admin.stats.feedback.tag.inspiring": "Insightful",
+  "admin.stats.feedback.tag.citation_wrong": "Wrong or made-up source",
+  "admin.stats.feedback.tag.missed": "Said not found, but it exists",
+  "admin.stats.feedback.tag.off_topic": "Off topic",
+  "admin.stats.feedback.tag.incorrect": "Contains errors",
+  "admin.stats.feedback.tag.too_long": "Too long",
+  "admin.stats.feedback.tag.too_academic": "Too academic",
+  "admin.stats.feedback.tag.slow": "Too slow",
+  "admin.stats.feedback.tag.other": "Other",
+};
+
+export default items;

+ 37 - 0
dashboard-v6/src/locales/en-US/admin.ts

@@ -0,0 +1,37 @@
+// 管理后台(/admin)文案
+const items = {
+  "admin.title": "Admin",
+  "admin.menu.stats": "Statistics",
+  "admin.menu.stats.reading": "Reading",
+  "admin.menu.stats.ai": "AI chat",
+  "admin.menu.api": "API monitor",
+  "admin.menu.manage": "Manage",
+  "admin.menu.relation": "Relations",
+  "admin.menu.nissaya-ending": "Nissaya endings",
+  "admin.menu.dictionary": "Dictionaries",
+  "admin.menu.dictionary.preference": "Dictionary preference",
+  "admin.menu.users": "Users",
+  "admin.menu.invite": "Invitations",
+  "admin.menu.ai-models": "AI models",
+  "admin.forbidden": "Only administrators can open this page.",
+  "admin.api.total": "Totals",
+  "admin.api.average": "Average response time",
+  "admin.api.count": "Requests",
+  "admin.dict.vocabulary": "Vocabulary",
+  "admin.dict.parent": "Stems",
+  "admin.users.basic": "Basic",
+  "admin.users.statistics": "Statistics",
+  "admin.users.role": "Role",
+  "admin.users.role.administrator": "Administrator",
+  "admin.users.role.uploader": "Uploader",
+  "admin.users.role.member": "Member",
+  "admin.users.role.basic": "Basic",
+  "admin.nissaya.term": "Edit term",
+  "admin.nissaya.ending.tooltip": "Up to 24 characters",
+  "admin.import": "Import",
+  "admin.export": "Export",
+  "admin.models.all": "All",
+  "admin.models.selected": "Selected",
+};
+
+export default items;

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

@@ -10,6 +10,8 @@ import message from "./zh-Hans/message";
 import label from "./zh-Hans/label";
 import error from "./zh-Hans/error";
 import pages from "./zh-Hans/pages";
+import admin from "./zh-Hans/admin";
+import adminStats from "./zh-Hans/admin-stats";
 
 const items = {
   "columns.library.title": "藏经阁",
@@ -59,6 +61,8 @@ const items = {
   ...label,
   ...error,
   ...pages,
+  ...admin,
+  ...adminStats,
 };
 
 export default items;

+ 139 - 0
dashboard-v6/src/locales/zh-Hans/admin-stats.ts

@@ -0,0 +1,139 @@
+// 管理后台统计页(/admin/stats/*)文案
+const items = {
+  "admin.stats.reading.title": "阅读统计",
+  "admin.stats.ai.title": "AI 对话统计",
+  "admin.stats.range.7": "近 7 天",
+  "admin.stats.range.30": "近 30 天",
+  "admin.stats.range.90": "近 90 天",
+  "admin.stats.client.all": "全部",
+  "admin.stats.client.web": "Web",
+  "admin.stats.client.mobile": "App",
+  "admin.stats.account.all": "全部",
+  "admin.stats.account.user": "登录用户",
+  "admin.stats.account.guest": "游客",
+  "admin.stats.compare": "环比",
+  "admin.stats.source": "来源:{source}",
+  "admin.stats.na": "不适用",
+  "admin.stats.reading.readers": "活跃读者",
+  "admin.stats.reading.readers.tip": "区间内有阅读记录更新的去重登录用户(游客的阅读服务器看不到)",
+  "admin.stats.reading.dau": "日活 {dau}",
+  "admin.stats.reading.sticky": "DAU/MAU {ratio}%",
+  "admin.stats.reading.time": "读经时长",
+  "admin.stats.reading.time.tip": "App 阅读器在前台、且 3 分钟内有翻读动作才计时;Web 没有计时",
+  "admin.stats.reading.time.unit": "小时",
+  "admin.stats.reading.time.avg": "{users} 人,人均 {minutes} 分钟",
+  "admin.stats.reading.chapters": "打开章节",
+  "admin.stats.reading.chapters.tip": "区间内有更新的阅读记录数(同一用户同一章节只记一条)",
+  "admin.stats.reading.chapters.avg": "人均 {avg} 章",
+  "admin.stats.reading.lookups": "查词次数",
+  "admin.stats.reading.lookups.tip": "登录用户经 v2 接口的查词请求",
+  "admin.stats.reading.views": "章节浏览 {views}(含游客与爬虫)",
+  "admin.stats.reading.trend.readers": "活跃读者",
+  "admin.stats.reading.trend.minutes": "读经时长(分钟)",
+  "admin.stats.reading.trend.lookups": "查词次数",
+  "admin.stats.reading.top": "热门章节 Top 10",
+  "admin.stats.reading.top.readers": "{n} 人",
+  "admin.stats.reading.pitaka": "读什么:三藏分布",
+  "admin.stats.reading.layer": "读什么:根本 / 义注 / 复注",
+  "admin.stats.reading.duration": "读多久:单日读经时长分布(分钟)",
+  "admin.stats.reading.credits": "读经积分",
+  "admin.stats.reading.credits.total": "已发放",
+  "admin.stats.reading.credits.users": "获积分人数",
+  "admin.stats.reading.credits.capped": "达每日上限(人·天)",
+  "admin.stats.reading.credits.clamped": "墙钟核减",
+  "admin.stats.reading.credits.clamped.tip": "上报秒数被服务端按墙钟时间核减的比例;突然升高说明有异常上报",
+  "admin.stats.tag.sutta": "经藏",
+  "admin.stats.tag.vinaya": "律藏",
+  "admin.stats.tag.abhidhamma": "论藏",
+  "admin.stats.tag.añña": "藏外",
+  "admin.stats.tag.mūla": "根本",
+  "admin.stats.tag.aṭṭhakathā": "义注",
+  "admin.stats.tag.ṭīkā": "复注",
+  "admin.stats.tag.other": "其他",
+  "admin.stats.empty": "这个区间还没有数据",
+  "admin.stats.ai.runs": "提问数",
+  "admin.stats.ai.runs.deep": "深度思考 {ratio}%",
+  "admin.stats.ai.runs.passage": "阅读页提问 {ratio}%",
+  "admin.stats.ai.askers": "提问的人",
+  "admin.stats.ai.askers.tip": "登录用户按账号、游客按设备匿名 id 去重",
+  "admin.stats.ai.askers.split": "登录 {user} · 游客 {guest}",
+  "admin.stats.ai.latency": "响应耗时 P50",
+  "admin.stats.ai.latency.p95": "P95 {seconds} 秒",
+  "admin.stats.ai.seconds": "秒",
+  "admin.stats.ai.failed": "拦截 / 出错",
+  "admin.stats.ai.failed.tip": "额度拦截=status=denied;出错=status=error(已自动退积分)",
+  "admin.stats.ai.failed.split": "拦截 {denied} · 出错 {errors} · 未查额度放行 {unchecked}",
+  "admin.stats.ai.daily": "每日提问(按研究路径)",
+  "admin.stats.ai.latency.daily": "响应耗时(秒)",
+  "admin.stats.ai.tools": "工具调用 Top",
+  "admin.stats.ai.credits": "积分流水",
+  "admin.stats.ai.credits.spent_free": "赠送消耗",
+  "admin.stats.ai.credits.spent_earned": "积分消耗",
+  "admin.stats.ai.credits.refunded": "出错退回",
+  "admin.stats.ai.credits.earned_reading": "读经发放",
+  "admin.stats.ai.credits.earned_editing": "编辑发放",
+  "admin.stats.ai.credits.adjusted": "手工调整",
+  "admin.stats.ai.tokens": "Token 与改进",
+  "admin.stats.ai.tokens.in": "输入 token",
+  "admin.stats.ai.tokens.out": "输出 token",
+  "admin.stats.ai.tokens.per_run": "每问 token",
+  "admin.stats.ai.improve": "可用于改进",
+  "admin.stats.ai.improve.tip": "允许用于改进回答(improve=true)的提问占比;关掉的照样入库,评测抽题时跳过",
+  "admin.stats.ai.clients": "客户端",
+  "admin.stats.route.question": "一般问题",
+  "admin.stats.route.term": "术语 / 词",
+  "admin.stats.route.passage": "阅读页提问",
+  "admin.stats.route.chat": "闲聊",
+  "admin.stats.route.none": "未路由",
+  "admin.stats.runs.title": "提问记录",
+  "admin.stats.runs.search": "搜索提问原文",
+  "admin.stats.runs.time": "时间",
+  "admin.stats.runs.question": "提问",
+  "admin.stats.runs.account": "账号",
+  "admin.stats.runs.client": "客户端",
+  "admin.stats.runs.route": "路由",
+  "admin.stats.runs.deep": "深度",
+  "admin.stats.runs.latency": "耗时",
+  "admin.stats.runs.status": "状态",
+  "admin.stats.runs.improve": "改进",
+  "admin.stats.runs.guest": "游客",
+  "admin.stats.status.ok": "完成",
+  "admin.stats.status.denied": "额度拦截",
+  "admin.stats.status.error": "出错",
+  "admin.stats.status.cancelled": "用户取消",
+  "admin.stats.run.title": "研究过程",
+  "admin.stats.run.answer": "回答",
+  "admin.stats.run.evidence": "给作答模型的证据",
+  "admin.stats.run.plan": "研究计划",
+  "admin.stats.run.steps": "步骤",
+  "admin.stats.run.device": "设备 {device}",
+  "admin.stats.run.thread": "会话",
+  "admin.stats.run.model": "模型",
+  "admin.stats.run.tokens": "Token",
+  "admin.stats.run.error": "错误",
+  "admin.stats.run.chars": "{chars} 字",
+  "admin.stats.feedback.title": "用户评价",
+  "admin.stats.feedback.review": "用户评价审阅",
+  "admin.stats.feedback.up": "点赞",
+  "admin.stats.feedback.down": "点踩",
+  "admin.stats.feedback.coverage": "评价覆盖率",
+  "admin.stats.feedback.rating": "评价",
+  "admin.stats.feedback.tags": "标签 / 原因",
+  "admin.stats.feedback.asked": "主动询问",
+  "admin.stats.feedback.asked.tip": "用户看到「这个回答有帮助吗?」后给的评价",
+  "admin.stats.feedback.no_run": "提问记录还没入库",
+  "admin.stats.feedback.tag.accurate": "准确",
+  "admin.stats.feedback.tag.useful_citations": "出处有用",
+  "admin.stats.feedback.tag.clear": "讲得清楚",
+  "admin.stats.feedback.tag.inspiring": "有启发",
+  "admin.stats.feedback.tag.citation_wrong": "出处不对 / 引用不存在",
+  "admin.stats.feedback.tag.missed": "其实有经文,它说没找到",
+  "admin.stats.feedback.tag.off_topic": "答非所问",
+  "admin.stats.feedback.tag.incorrect": "内容有错",
+  "admin.stats.feedback.tag.too_long": "太长",
+  "admin.stats.feedback.tag.too_academic": "太学术",
+  "admin.stats.feedback.tag.slow": "太慢",
+  "admin.stats.feedback.tag.other": "其他",
+};
+
+export default items;

+ 37 - 0
dashboard-v6/src/locales/zh-Hans/admin.ts

@@ -0,0 +1,37 @@
+// 管理后台(/admin)文案
+const items = {
+  "admin.title": "管理后台",
+  "admin.menu.stats": "统计",
+  "admin.menu.stats.reading": "阅读统计",
+  "admin.menu.stats.ai": "AI 对话统计",
+  "admin.menu.api": "API 监控",
+  "admin.menu.manage": "管理",
+  "admin.menu.relation": "语法关系",
+  "admin.menu.nissaya-ending": "Nissaya 语尾",
+  "admin.menu.dictionary": "词典",
+  "admin.menu.dictionary.preference": "词典偏好",
+  "admin.menu.users": "用户",
+  "admin.menu.invite": "邀请",
+  "admin.menu.ai-models": "AI 模型",
+  "admin.forbidden": "只有管理员可以访问这个页面。",
+  "admin.api.total": "总量",
+  "admin.api.average": "平均响应时间",
+  "admin.api.count": "请求次数",
+  "admin.dict.vocabulary": "单词表",
+  "admin.dict.parent": "词干",
+  "admin.users.basic": "基本",
+  "admin.users.statistics": "统计",
+  "admin.users.role": "类型",
+  "admin.users.role.administrator": "管理员",
+  "admin.users.role.uploader": "上传",
+  "admin.users.role.member": "会员",
+  "admin.users.role.basic": "基础版",
+  "admin.nissaya.term": "术语维护",
+  "admin.nissaya.ending.tooltip": "最长为 24 位",
+  "admin.import": "导入",
+  "admin.export": "导出",
+  "admin.models.all": "全部",
+  "admin.models.selected": "已选",
+};
+
+export default items;

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

@@ -10,6 +10,8 @@ import message from "./zh-Hant/message";
 import label from "./zh-Hant/label";
 import error from "./zh-Hant/error";
 import pages from "./zh-Hant/pages";
+import admin from "./zh-Hant/admin";
+import adminStats from "./zh-Hant/admin-stats";
 
 const items = {
   "columns.library.title": "藏經閣",
@@ -59,6 +61,8 @@ const items = {
   ...label,
   ...error,
   ...pages,
+  ...admin,
+  ...adminStats,
 };
 
 export default items;

+ 139 - 0
dashboard-v6/src/locales/zh-Hant/admin-stats.ts

@@ -0,0 +1,139 @@
+// 管理後台統計頁(/admin/stats/*)文案
+const items = {
+  "admin.stats.reading.title": "閱讀統計",
+  "admin.stats.ai.title": "AI 對話統計",
+  "admin.stats.range.7": "近 7 天",
+  "admin.stats.range.30": "近 30 天",
+  "admin.stats.range.90": "近 90 天",
+  "admin.stats.client.all": "全部",
+  "admin.stats.client.web": "Web",
+  "admin.stats.client.mobile": "App",
+  "admin.stats.account.all": "全部",
+  "admin.stats.account.user": "登入用戶",
+  "admin.stats.account.guest": "訪客",
+  "admin.stats.compare": "環比",
+  "admin.stats.source": "來源:{source}",
+  "admin.stats.na": "不適用",
+  "admin.stats.reading.readers": "活躍讀者",
+  "admin.stats.reading.readers.tip": "區間內有閱讀記錄更新的去重登入用戶(訪客的閱讀伺服器看不到)",
+  "admin.stats.reading.dau": "日活 {dau}",
+  "admin.stats.reading.sticky": "DAU/MAU {ratio}%",
+  "admin.stats.reading.time": "讀經時長",
+  "admin.stats.reading.time.tip": "App 閱讀器在前台、且 3 分鐘內有翻讀動作才計時;Web 沒有計時",
+  "admin.stats.reading.time.unit": "小時",
+  "admin.stats.reading.time.avg": "{users} 人,人均 {minutes} 分鐘",
+  "admin.stats.reading.chapters": "打開章節",
+  "admin.stats.reading.chapters.tip": "區間內有更新的閱讀記錄數(同一用戶同一章節只記一條)",
+  "admin.stats.reading.chapters.avg": "人均 {avg} 章",
+  "admin.stats.reading.lookups": "查詞次數",
+  "admin.stats.reading.lookups.tip": "登入用戶經 v2 介面的查詞請求",
+  "admin.stats.reading.views": "章節瀏覽 {views}(含訪客與爬蟲)",
+  "admin.stats.reading.trend.readers": "活躍讀者",
+  "admin.stats.reading.trend.minutes": "讀經時長(分鐘)",
+  "admin.stats.reading.trend.lookups": "查詞次數",
+  "admin.stats.reading.top": "熱門章節 Top 10",
+  "admin.stats.reading.top.readers": "{n} 人",
+  "admin.stats.reading.pitaka": "讀什麼:三藏分佈",
+  "admin.stats.reading.layer": "讀什麼:根本 / 義註 / 複註",
+  "admin.stats.reading.duration": "讀多久:單日讀經時長分佈(分鐘)",
+  "admin.stats.reading.credits": "讀經積分",
+  "admin.stats.reading.credits.total": "已發放",
+  "admin.stats.reading.credits.users": "獲積分人數",
+  "admin.stats.reading.credits.capped": "達每日上限(人·天)",
+  "admin.stats.reading.credits.clamped": "牆鐘核減",
+  "admin.stats.reading.credits.clamped.tip": "上報秒數被伺服器按牆鐘時間核減的比例;突然升高說明有異常上報",
+  "admin.stats.tag.sutta": "經藏",
+  "admin.stats.tag.vinaya": "律藏",
+  "admin.stats.tag.abhidhamma": "論藏",
+  "admin.stats.tag.añña": "藏外",
+  "admin.stats.tag.mūla": "根本",
+  "admin.stats.tag.aṭṭhakathā": "義註",
+  "admin.stats.tag.ṭīkā": "複註",
+  "admin.stats.tag.other": "其他",
+  "admin.stats.empty": "這個區間還沒有資料",
+  "admin.stats.ai.runs": "提問數",
+  "admin.stats.ai.runs.deep": "深度思考 {ratio}%",
+  "admin.stats.ai.runs.passage": "閱讀頁提問 {ratio}%",
+  "admin.stats.ai.askers": "提問的人",
+  "admin.stats.ai.askers.tip": "登入用戶按帳號、訪客按裝置匿名 id 去重",
+  "admin.stats.ai.askers.split": "登入 {user} · 訪客 {guest}",
+  "admin.stats.ai.latency": "回應耗時 P50",
+  "admin.stats.ai.latency.p95": "P95 {seconds} 秒",
+  "admin.stats.ai.seconds": "秒",
+  "admin.stats.ai.failed": "攔截 / 出錯",
+  "admin.stats.ai.failed.tip": "額度攔截=status=denied;出錯=status=error(已自動退積分)",
+  "admin.stats.ai.failed.split": "攔截 {denied} · 出錯 {errors} · 未查額度放行 {unchecked}",
+  "admin.stats.ai.daily": "每日提問(按研究路徑)",
+  "admin.stats.ai.latency.daily": "回應耗時(秒)",
+  "admin.stats.ai.tools": "工具呼叫 Top",
+  "admin.stats.ai.credits": "積分流水",
+  "admin.stats.ai.credits.spent_free": "贈送消耗",
+  "admin.stats.ai.credits.spent_earned": "積分消耗",
+  "admin.stats.ai.credits.refunded": "出錯退回",
+  "admin.stats.ai.credits.earned_reading": "讀經發放",
+  "admin.stats.ai.credits.earned_editing": "編輯發放",
+  "admin.stats.ai.credits.adjusted": "手工調整",
+  "admin.stats.ai.tokens": "Token 與改進",
+  "admin.stats.ai.tokens.in": "輸入 token",
+  "admin.stats.ai.tokens.out": "輸出 token",
+  "admin.stats.ai.tokens.per_run": "每問 token",
+  "admin.stats.ai.improve": "可用於改進",
+  "admin.stats.ai.improve.tip": "允許用於改進回答(improve=true)的提問佔比;關掉的照樣入庫,評測抽題時跳過",
+  "admin.stats.ai.clients": "客戶端",
+  "admin.stats.route.question": "一般問題",
+  "admin.stats.route.term": "術語 / 詞",
+  "admin.stats.route.passage": "閱讀頁提問",
+  "admin.stats.route.chat": "閒聊",
+  "admin.stats.route.none": "未路由",
+  "admin.stats.runs.title": "提問記錄",
+  "admin.stats.runs.search": "搜尋提問原文",
+  "admin.stats.runs.time": "時間",
+  "admin.stats.runs.question": "提問",
+  "admin.stats.runs.account": "帳號",
+  "admin.stats.runs.client": "客戶端",
+  "admin.stats.runs.route": "路由",
+  "admin.stats.runs.deep": "深度",
+  "admin.stats.runs.latency": "耗時",
+  "admin.stats.runs.status": "狀態",
+  "admin.stats.runs.improve": "改進",
+  "admin.stats.runs.guest": "訪客",
+  "admin.stats.status.ok": "完成",
+  "admin.stats.status.denied": "額度攔截",
+  "admin.stats.status.error": "出錯",
+  "admin.stats.status.cancelled": "用戶取消",
+  "admin.stats.run.title": "研究過程",
+  "admin.stats.run.answer": "回答",
+  "admin.stats.run.evidence": "給作答模型的證據",
+  "admin.stats.run.plan": "研究計劃",
+  "admin.stats.run.steps": "步驟",
+  "admin.stats.run.device": "裝置 {device}",
+  "admin.stats.run.thread": "會話",
+  "admin.stats.run.model": "模型",
+  "admin.stats.run.tokens": "Token",
+  "admin.stats.run.error": "錯誤",
+  "admin.stats.run.chars": "{chars} 字",
+  "admin.stats.feedback.title": "用戶評價",
+  "admin.stats.feedback.review": "用戶評價審閱",
+  "admin.stats.feedback.up": "點讚",
+  "admin.stats.feedback.down": "點踩",
+  "admin.stats.feedback.coverage": "評價覆蓋率",
+  "admin.stats.feedback.rating": "評價",
+  "admin.stats.feedback.tags": "標籤 / 原因",
+  "admin.stats.feedback.asked": "主動詢問",
+  "admin.stats.feedback.asked.tip": "用戶看到「這個回答有幫助嗎?」後給的評價",
+  "admin.stats.feedback.no_run": "提問記錄還沒入庫",
+  "admin.stats.feedback.tag.accurate": "準確",
+  "admin.stats.feedback.tag.useful_citations": "出處有用",
+  "admin.stats.feedback.tag.clear": "講得清楚",
+  "admin.stats.feedback.tag.inspiring": "有啟發",
+  "admin.stats.feedback.tag.citation_wrong": "出處不對 / 引用不存在",
+  "admin.stats.feedback.tag.missed": "其實有經文,它說沒找到",
+  "admin.stats.feedback.tag.off_topic": "答非所問",
+  "admin.stats.feedback.tag.incorrect": "內容有錯",
+  "admin.stats.feedback.tag.too_long": "太長",
+  "admin.stats.feedback.tag.too_academic": "太學術",
+  "admin.stats.feedback.tag.slow": "太慢",
+  "admin.stats.feedback.tag.other": "其他",
+};
+
+export default items;

+ 37 - 0
dashboard-v6/src/locales/zh-Hant/admin.ts

@@ -0,0 +1,37 @@
+// 管理后台(/admin)文案
+const items = {
+  "admin.title": "管理後台",
+  "admin.menu.stats": "統計",
+  "admin.menu.stats.reading": "閱讀統計",
+  "admin.menu.stats.ai": "AI 對話統計",
+  "admin.menu.api": "API 監控",
+  "admin.menu.manage": "管理",
+  "admin.menu.relation": "語法關係",
+  "admin.menu.nissaya-ending": "Nissaya 語尾",
+  "admin.menu.dictionary": "詞典",
+  "admin.menu.dictionary.preference": "詞典偏好",
+  "admin.menu.users": "用戶",
+  "admin.menu.invite": "邀請",
+  "admin.menu.ai-models": "AI 模型",
+  "admin.forbidden": "只有管理員可以訪問這個頁面。",
+  "admin.api.total": "總量",
+  "admin.api.average": "平均響應時間",
+  "admin.api.count": "請求次數",
+  "admin.dict.vocabulary": "單詞表",
+  "admin.dict.parent": "詞幹",
+  "admin.users.basic": "基本",
+  "admin.users.statistics": "統計",
+  "admin.users.role": "類型",
+  "admin.users.role.administrator": "管理員",
+  "admin.users.role.uploader": "上傳",
+  "admin.users.role.member": "會員",
+  "admin.users.role.basic": "基礎版",
+  "admin.nissaya.term": "術語維護",
+  "admin.nissaya.ending.tooltip": "最長為 24 位",
+  "admin.import": "導入",
+  "admin.export": "導出",
+  "admin.models.all": "全部",
+  "admin.models.selected": "已選",
+};
+
+export default items;

+ 14 - 0
dashboard-v6/src/pages/admin/ai-models.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import SystemModels from "../../features/admin/SystemModels";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.ai-models" })}</title>
+      <SystemModels />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/api.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import ApiDashboard from "../../features/admin/ApiDashboard";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.api" })}</title>
+      <ApiDashboard />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/dictionary/index.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import DictStatistics from "../../../features/admin/DictStatistics";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.dictionary" })}</title>
+      <DictStatistics />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/dictionary/preference.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import DictPreference from "../../../components/dict/DictPreference";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.dictionary.preference" })}</title>
+      <DictPreference />
+    </>
+  );
+};
+
+export default Widget;

+ 15 - 0
dashboard-v6/src/pages/admin/invite.tsx

@@ -0,0 +1,15 @@
+import { useIntl } from "react-intl";
+import InviteList from "../../components/invite/InviteList";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.invite" })}</title>
+      {/* 不带 studioName = 全站邀请(view=all) */}
+      <InviteList />
+    </>
+  );
+};
+
+export default Widget;

+ 17 - 0
dashboard-v6/src/pages/admin/nissaya-ending.tsx

@@ -0,0 +1,17 @@
+import { useIntl } from "react-intl";
+import { useParams } from "react-router";
+import NissayaEndingList from "../../features/admin/NissayaEndingList";
+
+/** /admin/nissaya-ending 与 /admin/nissaya-ending/:relation(按关系预筛选)。 */
+const Widget = () => {
+  const intl = useIntl();
+  const { relation } = useParams();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.nissaya-ending" })}</title>
+      <NissayaEndingList key={relation ?? ""} relation={relation} />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/relation.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import RelationList from "../../features/admin/RelationList";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.relation" })}</title>
+      <RelationList />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/stats/ai.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import AgentStats from "../../../features/admin-stats/AgentStats";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.stats.ai" })}</title>
+      <AgentStats />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/stats/reading.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import ReadingStats from "../../../features/admin-stats/ReadingStats";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.stats.reading" })}</title>
+      <ReadingStats />
+    </>
+  );
+};
+
+export default Widget;

+ 14 - 0
dashboard-v6/src/pages/admin/users/index.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import UserList from "../../../features/admin/UserList";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.users" })}</title>
+      <UserList />
+    </>
+  );
+};
+
+export default Widget;

+ 35 - 0
dashboard-v6/src/pages/admin/users/show.tsx

@@ -0,0 +1,35 @@
+import { useState } from "react";
+import { useIntl } from "react-intl";
+import { useParams } from "react-router";
+import { Card, Tabs } from "antd";
+import type { IUserApiData } from "../../../api/Auth";
+import Account from "../../../components/auth/Account";
+import GoBack from "../../../components/studio/GoBack";
+
+/** 用户详情:基本信息(统计页签留空,与 v4 一致)。 */
+const Widget = () => {
+  const intl = useIntl();
+  const { id } = useParams();
+  const [title, setTitle] = useState("");
+
+  return (
+    <>
+      <title>{title || intl.formatMessage({ id: "admin.menu.users" })}</title>
+      <Card title={<GoBack to="/admin/users" title={title} />}>
+        <Tabs
+          size="small"
+          items={[
+            {
+              label: intl.formatMessage({ id: "admin.users.basic" }),
+              key: "basic",
+              children: <Account userId={id} onLoad={(value: IUserApiData) => setTitle(value.nickName)} />,
+            },
+            { label: intl.formatMessage({ id: "admin.users.statistics" }), key: "statistics", children: <></> },
+          ]}
+        />
+      </Card>
+    </>
+  );
+};
+
+export default Widget;

+ 61 - 0
dashboard-v6/src/routes/adminRoutes.ts

@@ -0,0 +1,61 @@
+// src/routes/adminRoutes.ts
+//
+// 管理后台(/admin)。v4 的 pages/admin 一次迁来;两个统计页是新增的。
+// 外壳 layouts/admin 负责登录与 root / administrator 权限判断。
+import { lazy } from "react";
+import { redirect, type RouteObject } from "react-router";
+
+const StatsReading = lazy(() => import("../pages/admin/stats/reading"));
+const StatsAi = lazy(() => import("../pages/admin/stats/ai"));
+const ApiMonitor = lazy(() => import("../pages/admin/api"));
+const Relation = lazy(() => import("../pages/admin/relation"));
+const NissayaEnding = lazy(() => import("../pages/admin/nissaya-ending"));
+const Dictionary = lazy(() => import("../pages/admin/dictionary/index"));
+const DictionaryPreference = lazy(() => import("../pages/admin/dictionary/preference"));
+const Users = lazy(() => import("../pages/admin/users/index"));
+const UsersShow = lazy(() => import("../pages/admin/users/show"));
+const Invite = lazy(() => import("../pages/admin/invite"));
+const AiModels = lazy(() => import("../pages/admin/ai-models"));
+
+const adminRoutes: RouteObject[] = [
+  { index: true, loader: () => redirect("/admin/stats/reading") },
+  {
+    path: "stats",
+    handle: { id: "admin.stats", crumb: "stats" },
+    children: [
+      { index: true, loader: () => redirect("/admin/stats/reading") },
+      { path: "reading", Component: StatsReading, handle: { id: "admin.stats.reading", crumb: "reading" } },
+      { path: "ai", Component: StatsAi, handle: { id: "admin.stats.ai", crumb: "ai" } },
+    ],
+  },
+  { path: "api", Component: ApiMonitor, handle: { id: "admin.api", crumb: "api" } },
+  { path: "relation", Component: Relation, handle: { id: "admin.relation", crumb: "relation" } },
+  {
+    path: "nissaya-ending",
+    handle: { id: "admin.nissaya-ending", crumb: "nissaya-ending" },
+    children: [
+      { index: true, Component: NissayaEnding },
+      { path: ":relation", Component: NissayaEnding },
+    ],
+  },
+  {
+    path: "dictionary",
+    handle: { id: "admin.dictionary", crumb: "dictionary" },
+    children: [
+      { index: true, Component: Dictionary },
+      { path: "preference", Component: DictionaryPreference, handle: { id: "admin.dictionary.preference", crumb: "preference" } },
+    ],
+  },
+  {
+    path: "users",
+    handle: { id: "admin.users", crumb: "users" },
+    children: [
+      { index: true, Component: Users },
+      { path: ":id", Component: UsersShow },
+    ],
+  },
+  { path: "invite", Component: Invite, handle: { id: "admin.invite", crumb: "invite" } },
+  { path: "ai-models", Component: AiModels, handle: { id: "admin.ai-models", crumb: "ai-models" } },
+];
+
+export default adminRoutes;

Некоторые файлы не были показаны из-за большого количества измененных файлов