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

✨ nissaya-card 迁 v3:/v3/nissaya-cards/{ending}

缅文词尾卡片,只读、公开。只给结构化数据(去掉 markdown 分支、后端写死的表头、拼好的链接),
术语一次批量查(v2 逐格位 N+1),词尾说明用新渲染器的节点树;查不到的词尾回空卡片。
字段 row→relations、case→cases[{case,label}]、local_relation→relation_label、
local_ending→local_endings(数组)。v6 NissayaCard 切过去;v2 标 deprecated,对照表加行。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 5 часов назад
Родитель
Сommit
fe737b657c

+ 1 - 0
CLAUDE.md

@@ -363,6 +363,7 @@ Resource / FormRequest / 测试同理;URL 只换版本前缀
 | `term-vocabulary`(`view=grammar`/`community`)/ `TermVocabularyController@index` | `glossaries/{kind}` / `V3\GlossaryController` | 2026-11-17。语法术语表与社区译名表,只读、公开、整表不分页(客户端启动时拉取后本地查)。`view`→路径 `{kind}`(`grammar`/`community`);`lang` 缺省按 `Accept-Language`,没有该语言的系统 channel 时回退 en,`meta.lang` 是实际用到的语言;行字段 `guid`→`id`,空的 `tag`/`other_meaning` 给 null;已删术语不再出现;非法 `view` 不再是 500(`kind` 不对 404)。**改名**:v2 已有 `vocabulary`(字典词头补全,`VocabularyController`),为免撞名改叫 `glossaries`;注意它与批注的 `glossary` 类型(外挂术语)是两回事。v6(`load.ts` → `api/glossary.ts`)、wikipali-plugins(`wikipali terms`)已切;mobile 不用 |
 | `term-vocabulary`(`view=grammar`/`community`)/ `TermVocabularyController@index` | `glossaries/{kind}` / `V3\GlossaryController` | 2026-11-17。语法术语表与社区译名表,只读、公开、整表不分页(客户端启动时拉取后本地查)。`view`→路径 `{kind}`(`grammar`/`community`);`lang` 缺省按 `Accept-Language`,没有该语言的系统 channel 时回退 en,`meta.lang` 是实际用到的语言;行字段 `guid`→`id`,空的 `tag`/`other_meaning` 给 null;已删术语不再出现;非法 `view` 不再是 500(`kind` 不对 404)。**改名**:v2 已有 `vocabulary`(字典词头补全,`VocabularyController`),为免撞名改叫 `glossaries`;注意它与批注的 `glossary` 类型(外挂术语)是两回事。v6(`load.ts` → `api/glossary.ts`)、wikipali-plugins(`wikipali terms`)已切;mobile 不用 |
 | `terms-export`(+`/{uuid}`)+ `terms-import` / `TermExportController` | `channels/{channel}/terms`、`studios/{studio}/terms`(`Accept: xlsx`)+ `channels/{channel}/terms/imports`、`studios/{studio}/terms/imports` / `V3\ChannelTermController`、`V3\StudioTermController` + `V3\ChannelTermImportController`、`V3\StudioTermImportController`(逻辑在 `V3\TermExchangeService`) | 2026-11-17。**导出不设端点**:列表接口带 `Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` 直接返回整表 xlsx(过滤同列表、权限同列表;v2 只要登录、不查权限,且先存 Redis 再凭 uuid 下载)。列 `id / word / tag / meaning / other_meaning / summary / note / quality / content_type / redirect / language / channel_id / etag`。**导入**:multipart 上传 xlsx(不再经附件临时区、不再用 GET 写入;≤5MB、≤5000 行),按**列名**读(v2 导出的表也能用);**部分成功**(出错行跳过,`errors[{row,message}]`),有 id 改那条、word / tag 不能改、带 etag 列时校验(导出后被改过就跳过),无 id 按 word + tag 找、有就改没有就建;「有 id、word 为空就删除」去掉;channel 导入的 language / channel_id 列不看;studio 导入按 `channel_id` 落 channel(须属该 studio 且可写),空的是 studio 通用(要 language,新建要团队 owner / manager);不支持 agent;≤50 条改动立即重建搜索索引,更多的等每周 `opensearch:index-term`。生成器为此支持 `@bodyParam x file`(multipart)。v6 `TermImport` / `TermExport` 已切 |
 | `terms-export`(+`/{uuid}`)+ `terms-import` / `TermExportController` | `channels/{channel}/terms`、`studios/{studio}/terms`(`Accept: xlsx`)+ `channels/{channel}/terms/imports`、`studios/{studio}/terms/imports` / `V3\ChannelTermController`、`V3\StudioTermController` + `V3\ChannelTermImportController`、`V3\StudioTermImportController`(逻辑在 `V3\TermExchangeService`) | 2026-11-17。**导出不设端点**:列表接口带 `Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` 直接返回整表 xlsx(过滤同列表、权限同列表;v2 只要登录、不查权限,且先存 Redis 再凭 uuid 下载)。列 `id / word / tag / meaning / other_meaning / summary / note / quality / content_type / redirect / language / channel_id / etag`。**导入**:multipart 上传 xlsx(不再经附件临时区、不再用 GET 写入;≤5MB、≤5000 行),按**列名**读(v2 导出的表也能用);**部分成功**(出错行跳过,`errors[{row,message}]`),有 id 改那条、word / tag 不能改、带 etag 列时校验(导出后被改过就跳过),无 id 按 word + tag 找、有就改没有就建;「有 id、word 为空就删除」去掉;channel 导入的 language / channel_id 列不看;studio 导入按 `channel_id` 落 channel(须属该 studio 且可写),空的是 studio 通用(要 language,新建要团队 owner / manager);不支持 agent;≤50 条改动立即重建搜索索引,更多的等每周 `opensearch:index-term`。生成器为此支持 `@bodyParam x file`(multipart)。v6 `TermImport` / `TermExport` 已切 |
 | `grammar-guide/{词_语言}` / `GrammarGuideController@show` | (无新端点)`glossaries/grammar` + `terms/{term}`,退回 `terms?word=` | 2026-11-17。语法点悬停说明(v6 `components/dict/GrammarPop.tsx`)。v2 在语法术语系统 channel 里按词查一条、返回 `# 释义\n正文` 的 markdown;v6 改为:启动时已加载的 `/v3/glossaries/grammar` 里按词找 id → `GET /v3/terms/{id}`(新渲染器的 body);表里没有就按词查 `GET /v3/terms?word=&with_body=true`,只认 `_System_Grammar_Term_{界面语言}_`、其次 en 那个 channel 的;都没有显示「暂无…的语法说明」。悬停查询失败不弹全局提示(quiet)。`api/Guide.ts` 已删。顺带修了 `terms?with_body=` 与 `studios/{s}/terms?general=` 收不了查询串 `true`/`false` 的 422 |
 | `grammar-guide/{词_语言}` / `GrammarGuideController@show` | (无新端点)`glossaries/grammar` + `terms/{term}`,退回 `terms?word=` | 2026-11-17。语法点悬停说明(v6 `components/dict/GrammarPop.tsx`)。v2 在语法术语系统 channel 里按词查一条、返回 `# 释义\n正文` 的 markdown;v6 改为:启动时已加载的 `/v3/glossaries/grammar` 里按词找 id → `GET /v3/terms/{id}`(新渲染器的 body);表里没有就按词查 `GET /v3/terms?word=&with_body=true`,只认 `_System_Grammar_Term_{界面语言}_`、其次 en 那个 channel 的;都没有显示「暂无…的语法说明」。悬停查询失败不弹全局提示(quiet)。`api/Guide.ts` 已删。顺带修了 `terms?with_body=` 与 `studios/{s}/terms?general=` 收不了查询串 `true`/`false` 的 422 |
+| `nissaya-card/{ending}` / `NissayaCardController@show` | `nissaya-cards/{ending}` / `V3\NissayaCardController`(逻辑在 `V3\NissayaCardService`) | 2026-11-17。缅文 nissaya 词尾卡片(v6 `components/nissaya/NissayaCard`),只读、公开。只给结构化数据:去掉 mustache 渲染的 markdown 分支、写死在后端的表头文字、拼好的 dashboard 链接(前端自己拼);术语一次批量查(v2 逐格位 N+1);词尾说明是新渲染器的 `body` 节点树。字段 `row`→`relations`、`case`→`cases[{case,label}]`、`local_relation`→`relation_label`、`local_ending`(分号拼接)→`local_endings`(数组);查不到的词尾回空卡片(200)。语法术语 channel 没有该语言时回退 en,`lang` 是实际用到的语言。v6 已切;mobile、插件不用 |
 
 
 **注意**:`tipitaka-reading` **不是** v2 `paragraph-content` / `chapter-content` 的替代品。
 **注意**:`tipitaka-reading` **不是** v2 `paragraph-content` / `chapter-content` 的替代品。
 那两个 v2 端点支持多 channel(`channels=a,b,c`)与 edit 模式、返回 sentenceIds 供编辑器用;
 那两个 v2 端点支持多 channel(`channels=a,b,c`)与 edit 模式、返回 sentenceIds 供编辑器用;

+ 27 - 0
api-test/cases/19_nissaya_cards.php

@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * 缅文词尾卡片:GET /v3/nissaya-cards/{ending}(取代 v2 nissaya-card)。只读、公开。
+ * 各服务器数据不同,只核对形状;关系的格位译名、翻译建议过滤、回退 en、N+1 由 api-v13 的 NissayaCardV3Test 覆盖。
+ */
+
+test('GET /v3/nissaya-cards/{ending} → 200,结构完整', function () {
+    $res = raw('GET', '/v3/nissaya-cards/'.rawurlencode('သည်'), ['lang' => 'zh-Hans']);
+    assert_status(200, $res, 'nissaya card');
+    foreach (['ending', 'lang', 'term', 'relations'] as $key) {
+        assert_has_key($key, $res['body']['data'], 'nissaya card');
+    }
+    $row = $res['body']['data']['relations'][0] ?? null;
+    if ($row) {
+        assert_eq(['relation', 'relation_label', 'from', 'to', 'category', 'local_endings'], array_keys($row), '关系字段');
+    }
+});
+
+test('GET /v3/nissaya-cards/{查不到的词尾} → 200 空卡片;lang 格式不对 → 422', function () {
+    $res = raw('GET', '/v3/nissaya-cards/no-such-ending', ['lang' => 'zh-Hans']);
+    assert_status(200, $res, '空卡片');
+    assert_eq(null, $res['body']['data']['term'], '没有术语');
+    assert_eq([], $res['body']['data']['relations'], '没有关系');
+    $bad = raw('GET', '/v3/nissaya-cards/x', ['lang' => '../x']);
+    assert_status(422, $bad, 'lang 格式不对');
+});

+ 36 - 0
api-v13/app/Http/Controllers/V3/NissayaCardController.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\ShowNissayaCardRequest;
+use App\Http\Resources\V3\NissayaCardResource;
+use App\Services\V3\NissayaCardService;
+
+/**
+ * 缅文 nissaya 词尾卡片(只读、公开)。
+ *
+ * 取代 `GET /v2/nissaya-card/{ending}`(`NissayaCardController@show`)。v2 那份在 dashboard-v4 下线前原样保留,不要改动。
+ */
+class NissayaCardController extends Controller
+{
+    public function __construct(private readonly NissayaCardService $cards) {}
+
+    /**
+     * 缅文词尾卡片
+     *
+     * 词尾对应的语法术语(说明是新渲染器的节点树),以及它表达的语法关系:关系名与格位都带本地译名,
+     * 另有含义分类与翻译建议。术语取 `_System_Grammar_Term_{lang}_`,没有就用 en(`lang` 字段是实际用到的语言)。
+     * 词尾查不到时 `term` 为 null、`relations` 为空,不是 404。
+     *
+     * @unauthenticated
+     *
+     * @urlParam ending string required 缅文词尾,如 သည်
+     *
+     * @queryParam lang string 语言,如 zh-Hans。缺省用界面语言(Accept-Language 协商的结果)
+     */
+    public function __invoke(ShowNissayaCardRequest $request, string $ending)
+    {
+        return NissayaCardResource::make($this->cards->card($ending, $request->validated('lang') ?? app()->getLocale()));
+    }
+}

+ 26 - 0
api-v13/app/Http/Requests/V3/ShowNissayaCardRequest.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `GET /v3/nissaya-cards/{ending}`:卡片的语言(可选,缺省用请求协商出的界面语言)。
+ */
+class ShowNissayaCardRequest extends FormRequest
+{
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'lang' => ['sometimes', 'string', 'max:16', 'regex:/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/'],
+        ];
+    }
+}

+ 37 - 0
api-v13/app/Http/Resources/V3/NissayaCardResource.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use App\Services\V3\NissayaCardService;
+use Illuminate\Http\Request;
+
+/**
+ * 缅文 nissaya 词尾卡片({@see NissayaCardService})。
+ *
+ * - `term`:词尾对应的语法术语,`body` 是新渲染器的节点树;没有这条术语时为 null
+ * - `relations`:这个词尾表达的语法关系,每条带关系名的本地译名、来源 / 目标的格位(带本地译名)与拼写、
+ *   含义分类(`note` 是纯文本)、翻译建议
+ * - `lang`:实际用到的语言(没有该语言的语法术语表时是 en)
+ */
+class NissayaCardResource extends BaseResource
+{
+    /**
+     * @return array{
+     *     ending: string,
+     *     lang: string,
+     *     term: array{id: string, word: string, tag: string|null, meaning: string, body: list<MarkupNode>}|null,
+     *     relations: list<array{
+     *         relation: string,
+     *         relation_label: string|null,
+     *         from: array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null,
+     *         to: array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null,
+     *         category: array{name: string, meaning: string, note: string}|null,
+     *         local_endings: list<string>
+     *     }>
+     * }
+     */
+    public function toArray(Request $request): array
+    {
+        return $this->resource;
+    }
+}

+ 251 - 0
api-v13/app/Services/V3/NissayaCardService.php

@@ -0,0 +1,251 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Models\DhammaTerm;
+use App\Models\NissayaEnding;
+use App\Models\Relation;
+use App\Services\ChannelService as ChannelLookup;
+use App\Services\Markup\Format;
+use App\Services\Markup\MarkupService;
+use App\Services\Markup\RenderOptions;
+use Illuminate\Support\Collection;
+
+/**
+ * 缅文 nissaya 词尾卡片(只读):这个词尾对应的语法术语,以及它表达的语法关系。
+ *
+ * 取代 v2 `nissaya-card/{ending}`(`NissayaCardController@show`)。数据:
+ * - 术语取语法术语系统 channel `_System_Grammar_Term_{lang}_`,没有就用 en(与 v2 相同)
+ * - 词尾 → 关系:`nissaya_endings.relation`;关系的格位 / 分类:`relations`
+ * - 翻译建议:同一关系在 `lang` 下的其它词尾(from 为空或与关系的 from 相同)
+ *
+ * 与 v2 的差别:只给结构化数据(v2 另有 mustache 渲染的 markdown 分支,表头文字也写死在后端);
+ * 不再拼 dashboard 链接(前端自己拼);术语一次批量查(v2 逐个格位查,N+1);
+ * 词尾说明用新渲染器给节点树(v2 是旧渲染器的 HTML)。
+ */
+class NissayaCardService
+{
+    private const GRAMMAR_CHANNEL = '_System_Grammar_Term_';
+
+    public function __construct(
+        private readonly ChannelLookup $channels,
+        private readonly MarkupService $markup,
+    ) {}
+
+    /**
+     * @return array{
+     *     ending: string,
+     *     lang: string,
+     *     term: array{id: string, word: string, tag: string|null, meaning: string, body: list<array<string, mixed>>}|null,
+     *     relations: list<array{
+     *         relation: string,
+     *         relation_label: string|null,
+     *         from: array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null,
+     *         to: array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null,
+     *         category: array{name: string, meaning: string, note: string}|null,
+     *         local_endings: list<string>
+     *     }>
+     * }
+     */
+    public function card(string $ending, string $lang): array
+    {
+        [$channel, $servedLang] = $this->grammarChannel($lang);
+
+        $relationNames = NissayaEnding::where('ending', $ending)
+            ->whereNotNull('relation')
+            ->where('relation', '<>', '')
+            ->pluck('relation')
+            ->unique()
+            ->values();
+        $relations = $relationNames->isEmpty()
+            ? collect()
+            : Relation::whereIn('name', $relationNames)->orderBy('name')->get(['name', 'from', 'to', 'category']);
+
+        // 一次查出卡片上要用的全部术语:词尾、关系名、格位、分类
+        $words = collect([$ending])
+            ->merge($relations->pluck('name'))
+            ->merge($relations->pluck('category')->filter())
+            ->merge($relations->flatMap(fn (Relation $r) => [
+                ...($this->decode($r->from)['case'] ?? []),
+                ...($this->decode($r->to)['case'] ?? []),
+            ]))
+            ->filter(fn ($w) => is_string($w) && $w !== '')
+            ->unique()
+            ->values();
+        $terms = $channel === false || $words->isEmpty()
+            ? collect()
+            : DhammaTerm::where('channal', $channel)->whereIn('word', $words)
+                ->get(['guid', 'word', 'tag', 'meaning', 'note', 'content_type', 'channal'])
+                ->keyBy('word');
+
+        $localEndings = $relations->isEmpty()
+            ? collect()
+            : NissayaEnding::whereIn('relation', $relations->pluck('name'))
+                ->where('lang', $lang)
+                ->get(['ending', 'relation', 'from']);
+
+        $rendered = $this->render($terms->get($ending), $relations, $terms);
+
+        return [
+            'ending' => $ending,
+            'lang' => $servedLang,
+            'term' => $this->termOf($terms->get($ending), $rendered['body']),
+            'relations' => $relations->map(fn (Relation $relation) => $this->relationRow(
+                $relation,
+                $terms,
+                $localEndings,
+                $rendered['categories'],
+            ))->values()->all(),
+        ];
+    }
+
+    /**
+     * @return array{0: string|false, 1: string} 语法术语 channel 的 uid 与实际用到的语言
+     */
+    private function grammarChannel(string $lang): array
+    {
+        $channel = $this->channels->systemUid(self::GRAMMAR_CHANNEL.strtolower($lang).'_');
+        if ($channel !== false) {
+            return [$channel, $lang];
+        }
+
+        return [$this->channels->systemUid(self::GRAMMAR_CHANNEL.'en_'), 'en'];
+    }
+
+    /**
+     * 词尾说明(节点树)与各分类说明(纯文本)一次渲染。
+     *
+     * @param  Collection<int, Relation>  $relations
+     * @param  Collection<string, DhammaTerm>  $terms
+     * @return array{body: list<array<string, mixed>>, categories: array<string, string>}
+     */
+    private function render(?DhammaTerm $endingTerm, Collection $relations, Collection $terms): array
+    {
+        $tree = [];
+        if ($endingTerm && trim((string) $endingTerm->note) !== '') {
+            $tree['ending'] = $this->item($endingTerm);
+        }
+        $text = [];
+        foreach ($relations->pluck('category')->filter()->unique() as $name) {
+            $term = $terms->get($name);
+            if ($term && trim((string) $term->note) !== '') {
+                $text[$name] = $this->item($term);
+            }
+        }
+
+        return [
+            'body' => $tree === [] ? [] : $this->markup->renderMany($tree, new RenderOptions(format: Format::Tree))['ending'],
+            'categories' => $text === [] ? [] : array_map('strval', $this->markup->renderMany($text, new RenderOptions(format: Format::Text))),
+        ];
+    }
+
+    /**
+     * @return array{source: string, channels: list<string>, contentType: string}
+     */
+    private function item(DhammaTerm $term): array
+    {
+        return [
+            'source' => (string) $term->note,
+            'channels' => $term->channal ? [$term->channal] : [],
+            'contentType' => $term->effectiveContentType(),
+        ];
+    }
+
+    /**
+     * @param  list<array<string, mixed>>  $body
+     * @return array{id: string, word: string, tag: string|null, meaning: string, body: list<array<string, mixed>>}|null
+     */
+    private function termOf(?DhammaTerm $term, array $body): ?array
+    {
+        if ($term === null) {
+            return null;
+        }
+        $tag = trim((string) $term->tag);
+
+        return [
+            'id' => (string) $term->guid,
+            'word' => (string) $term->word,
+            'tag' => $tag === '' ? null : $tag,
+            'meaning' => (string) $term->meaning,
+            'body' => $body,
+        ];
+    }
+
+    /**
+     * @param  Collection<string, DhammaTerm>  $terms
+     * @param  Collection<int, NissayaEnding>  $localEndings
+     * @param  array<string, string>  $categoryNotes
+     * @return array{relation: string, relation_label: string|null, from: array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null, to: array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null, category: array{name: string, meaning: string, note: string}|null, local_endings: list<string>}
+     */
+    private function relationRow(Relation $relation, Collection $terms, Collection $localEndings, array $categoryNotes): array
+    {
+        $category = null;
+        if (! empty($relation->category)) {
+            $term = $terms->get($relation->category);
+            $category = [
+                'name' => (string) $relation->category,
+                'meaning' => $term ? (string) $term->meaning : (string) $relation->category,
+                'note' => trim($categoryNotes[$relation->category] ?? ($term ? '' : (string) $relation->category)),
+            ];
+        }
+
+        // 翻译建议:同一关系、该语言的词尾;词尾的 from 为空,或与关系的 from 完全相同(与 v2 一致,比较 JSON 原文)
+        $suggestions = $localEndings
+            ->filter(fn (NissayaEnding $e) => $e->relation === $relation->name
+                && (empty($e->from) || $this->raw($e->from) === $this->raw($relation->from)))
+            ->pluck('ending')
+            ->unique()
+            ->values()
+            ->all();
+
+        return [
+            'relation' => (string) $relation->name,
+            'relation_label' => $terms->get($relation->name)?->meaning,
+            'from' => $this->side($relation->from, $terms),
+            'to' => $this->side($relation->to, $terms),
+            'category' => $category,
+            'local_endings' => $suggestions,
+        ];
+    }
+
+    /**
+     * 关系的一端(from / to):格位(带本地译名)与拼写。都没有返回 null。
+     *
+     * @param  Collection<string, DhammaTerm>  $terms
+     * @return array{cases: list<array{case: string, label: string|null}>, spell: string|null}|null
+     */
+    private function side(mixed $value, Collection $terms): ?array
+    {
+        $data = $this->decode($value);
+        $cases = array_values(array_filter((array) ($data['case'] ?? []), 'is_string'));
+        $spell = isset($data['spell']) && $data['spell'] !== '' ? (string) $data['spell'] : null;
+        if ($cases === [] && $spell === null) {
+            return null;
+        }
+
+        return [
+            'cases' => array_map(fn (string $case) => ['case' => $case, 'label' => $terms->get($case)?->meaning], $cases),
+            'spell' => $spell,
+        ];
+    }
+
+    /**
+     * json 列可能是字符串(库里原样)或已解码的数组。
+     *
+     * @return array<string, mixed>
+     */
+    private function decode(mixed $value): array
+    {
+        if (is_array($value)) {
+            return $value;
+        }
+        $decoded = json_decode((string) $value, true);
+
+        return is_array($decoded) ? $decoded : [];
+    }
+
+    private function raw(mixed $value): string
+    {
+        return is_string($value) ? $value : (string) json_encode($value);
+    }
+}

+ 1 - 0
api-v13/routes/api.php

@@ -355,6 +355,7 @@ Route::prefix('v3')->as('v3.')->middleware(NegotiateLocale::class)->group(functi
     require __DIR__.'/v3/tipitaka.php';
     require __DIR__.'/v3/tipitaka.php';
     require __DIR__.'/v3/channel.php';
     require __DIR__.'/v3/channel.php';
     require __DIR__.'/v3/term.php';
     require __DIR__.'/v3/term.php';
+    require __DIR__.'/v3/nissaya.php';
     require __DIR__.'/v3/group.php';
     require __DIR__.'/v3/group.php';
     require __DIR__.'/v3/interaction.php';
     require __DIR__.'/v3/interaction.php';
     require __DIR__.'/v3/auth.php';
     require __DIR__.'/v3/auth.php';

+ 16 - 0
api-v13/routes/v3/nissaya.php

@@ -0,0 +1,16 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| v3 · nissaya —— 缅文 nissaya(词尾、语法关系)
+|--------------------------------------------------------------------------
+|
+| 由 routes/api.php 的 v3 组 require 进来,前缀已在那边加好。
+|
+*/
+
+use App\Http\Controllers\V3\NissayaCardController;
+use Illuminate\Support\Facades\Route;
+
+// 缅文词尾卡片:只读、公开。取代 v2 nissaya-card
+Route::get('nissaya-cards/{ending}', NissayaCardController::class)->name('nissaya-cards.show');

+ 106 - 0
api-v13/tests/Feature/NissayaCardV3Test.php

@@ -0,0 +1,106 @@
+<?php
+
+use App\Models\DhammaTerm;
+use App\Models\NissayaEnding;
+use App\Models\Relation;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
+
+uses(RefreshDatabase::class);
+
+/*
+ * GET /v3/nissaya-cards/{ending}:缅文词尾卡片(取代 v2 nissaya-card)。
+ * 这里断言的是形状而非契约(spectator 未安装,见 v3-resource skill 第 3 步)。
+ */
+
+function grammarTerm(string $channel, string $word, string $meaning, ?string $note = null): void
+{
+    (new DhammaTerm)->forceFill([
+        'id' => random_int(1, PHP_INT_MAX), 'guid' => (string) Str::uuid(), 'word' => $word, 'word_en' => $word,
+        'meaning' => $meaning, 'note' => $note, 'channal' => $channel, 'language' => 'zh-Hans',
+        'owner' => config('mint.admin.root_uuid'), 'editor_id' => 0, 'content_type' => 'markdown-e2',
+        'create_time' => time() * 1000, 'modify_time' => time() * 1000,
+    ])->save();
+}
+
+function relation(string $name, ?array $from, ?array $to, ?string $category = null): void
+{
+    (new Relation)->forceFill([
+        'id' => (string) Str::uuid(), 'name' => $name, 'from' => $from ? json_encode($from) : null,
+        'to' => $to ? json_encode($to) : null, 'category' => $category, 'editor_id' => (string) Str::uuid(),
+    ])->save();
+}
+
+function nissayaEnding(string $ending, string $relation, string $lang = 'my', ?array $from = null): void
+{
+    (new NissayaEnding)->forceFill([
+        'id' => (string) Str::uuid(), 'ending' => $ending, 'relation' => $relation, 'lang' => $lang,
+        'from' => $from ? json_encode($from) : null, 'strlen' => mb_strlen($ending), 'count' => 0,
+        'editor_id' => (string) Str::uuid(),
+    ])->save();
+}
+
+beforeEach(function () {
+    $this->zh = makeChannel(config('mint.admin.root_uuid'), '_System_Grammar_Term_zh-hans_');
+});
+
+it('builds the card of an ending with its term and relations', function () {
+    grammarTerm($this->zh, 'သည်', '主格语尾', '主格的**标记**。');
+    grammarTerm($this->zh, 'SV', '主谓关系');
+    grammarTerm($this->zh, 'nom', '主格');
+    grammarTerm($this->zh, 'SV active', '主动分词', '说明**正文**。');
+    relation('SV', ['case' => ['nom']], ['case' => ['nom', 'prp'], 'spell' => 'x'], 'SV active');
+    relation('NOREL', null, null);
+    nissayaEnding('သည်', 'SV');
+    nissayaEnding('သည်', 'NOREL');
+    nissayaEnding('是', 'SV', 'zh-Hans');                         // 翻译建议:from 为空
+    nissayaEnding('乃', 'SV', 'zh-Hans', ['case' => ['nom']]);    // from 与关系相同
+    nissayaEnding('非', 'SV', 'zh-Hans', ['case' => ['gen']]);    // from 不同:不算
+
+    $data = $this->getJson('/api/v3/nissaya-cards/'.rawurlencode('သည်').'?lang=zh-Hans')->assertOk()->json('data');
+
+    expect($data['ending'])->toBe('သည်')->and($data['lang'])->toBe('zh-Hans');
+    expect($data['term'])->toMatchArray(['word' => 'သည်', 'meaning' => '主格语尾', 'tag' => null])
+        ->and($data['term']['body'])->toBeArray()->not->toBeEmpty();
+    expect(array_column($data['relations'], 'relation'))->toBe(['NOREL', 'SV']);
+    expect($data['relations'][0])->toMatchArray(['from' => null, 'to' => null, 'category' => null, 'relation_label' => null]);
+    expect($data['relations'][1])->toMatchArray([
+        'relation_label' => '主谓关系',
+        'from' => ['cases' => [['case' => 'nom', 'label' => '主格']], 'spell' => null],
+        'to' => ['cases' => [['case' => 'nom', 'label' => '主格'], ['case' => 'prp', 'label' => null]], 'spell' => 'x'],
+        'category' => ['name' => 'SV active', 'meaning' => '主动分词', 'note' => '说明正文。'],
+        'local_endings' => ['是', '乃'],
+    ]);
+});
+
+it('falls back to the English grammar terms, and returns an empty card for an unknown ending', function () {
+    $en = makeChannel(config('mint.admin.root_uuid'), '_System_Grammar_Term_en_');
+    grammarTerm($en, 'သည်', 'nominative ending');
+
+    $this->getJson('/api/v3/nissaya-cards/'.rawurlencode('သည်').'?lang=th')
+        ->assertOk()->assertJsonPath('data.lang', 'en')->assertJsonPath('data.term.meaning', 'nominative ending');
+    $this->getJson('/api/v3/nissaya-cards/nothing?lang=zh-Hans')
+        ->assertOk()->assertJsonPath('data.term', null)->assertJsonPath('data.relations', []);
+    $this->getJson('/api/v3/nissaya-cards/x?lang='.urlencode('../x'))->assertUnprocessable()->assertJsonValidationErrors('lang');
+});
+
+it('builds a card with a constant number of queries', function () {
+    $count = function (int $n) {
+        $ending = "e{$n}";
+        foreach (range(1, $n) as $i) {
+            grammarTerm($this->zh, "case{$n}-{$i}", "格{$i}");
+            relation("R{$n}-{$i}", ['case' => ["case{$n}-{$i}"]], ['case' => ["case{$n}-{$i}"]], "cat{$n}-{$i}");
+            nissayaEnding($ending, "R{$n}-{$i}");
+        }
+        DB::flushQueryLog();
+        DB::enableQueryLog();
+        $this->getJson("/api/v3/nissaya-cards/{$ending}?lang=zh-Hans")->assertOk();
+        $queries = count(DB::getQueryLog());
+        DB::disableQueryLog();
+
+        return $queries;
+    };
+
+    expect($count(6))->toBe($count(2));
+});

+ 24 - 0
dashboard-test/src/tests/nissaya-card.spec.ts

@@ -0,0 +1,24 @@
+import { test, expect } from '@playwright/test';
+import { collect } from '../lib/collect.js';
+
+/**
+ * 缅文词尾卡片(v3 /nissaya-cards,取代 v2 nissaya-card):词尾页显示语法关系表格。
+ */
+test('词尾页:取 v3 卡片,显示关系表格,不再请求 v2 nissaya-card', async ({ page }) => {
+  const log = collect(page);
+  const v2: string[] = [];
+  page.on('request', (r) => r.url().includes('/api/v2/nissaya-card') && v2.push(r.url()));
+  const card = page.waitForResponse((r) => r.url().includes('/api/v3/nissaya-cards/'));
+
+  await page.goto(`workspace/nissaya/ending/${encodeURIComponent('သည်')}`, { waitUntil: 'networkidle' });
+  const res = await card;
+  expect(res.status()).toBe(200);
+  const data = (await res.json()).data;
+  console.log(`>>> 词尾 ${data.ending}:${data.relations.length} 条关系(${data.lang})`);
+
+  await expect(page.locator('.ant-table-row').first()).toBeVisible();
+  expect(await page.locator('.ant-table-row').count()).toBeGreaterThan(0);
+  expect(v2).toEqual([]);
+  await page.screenshot({ path: 'testlog/assets/nissaya-card.png', fullPage: true });
+  log.dump('词尾卡片');
+});

+ 19 - 0
dashboard-v6/src/api/nissaya.ts

@@ -0,0 +1,19 @@
+// src/api/nissaya.ts
+import { api, unwrap } from "./client";
+import type { paths } from "./schema";
+
+/* ─── v3 缅文 nissaya 词尾卡片(取代 v2 nissaya-card)─── */
+
+type NissayaCardResponse =
+  paths["/v3/nissaya-cards/{ending}"]["get"]["responses"][200]["content"]["application/json"];
+export type NissayaCard = NonNullable<NissayaCardResponse["data"]>;
+export type NissayaRelation = NonNullable<NissayaCard["relations"]>[number];
+export type NissayaRelationSide = NonNullable<NissayaRelation["from"]>;
+
+/** 词尾卡片:语法术语(body 是新渲染器的节点树)+ 它表达的语法关系 */
+export const fetchNissayaCard = async (ending: string, lang?: string) =>
+  unwrap(
+    await api.GET("/v3/nissaya-cards/{ending}", {
+      params: { path: { ending }, query: { lang } },
+    }),
+  ).data;

+ 91 - 1
dashboard-v6/src/api/schema.d.ts

@@ -3782,7 +3782,10 @@ export interface paths {
         };
         };
         /**
         /**
          * 获取单个 nissaya-card/{nissaya_card}
          * 获取单个 nissaya-card/{nissaya_card}
-         * @description 实现:`NissayaCardController@show`
+         * @deprecated
+         * @description 已被 `GET /v3/nissaya-cards/{ending}` 取代:只给结构化数据(不再有 mustache 渲染的 markdown 分支、写死的表头文字、拼好的 dashboard 链接),
+         *     术语批量查(v2 逐个格位查),词尾说明是新渲染器的节点树。字段:`row`→`relations`,`case`→`cases`,`local_relation`→`relation_label`,
+         *     `local_ending`(分号拼接)→`local_endings`(数组)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
          */
          */
         get: operations["get_api_v2_nissaya_card_nissaya_card_"];
         get: operations["get_api_v2_nissaya_card_nissaya_card_"];
         /**
         /**
@@ -8887,6 +8890,30 @@ export interface paths {
         patch?: never;
         patch?: never;
         trace?: never;
         trace?: never;
     };
     };
+    "/v3/nissaya-cards/{ending}": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 缅文词尾卡片
+         * @description 词尾对应的语法术语(说明是新渲染器的节点树),以及它表达的语法关系:关系名与格位都带本地译名,
+         *     另有含义分类与翻译建议。术语取 `_System_Grammar_Term_{lang}_`,没有就用 en(`lang` 字段是实际用到的语言)。
+         *     词尾查不到时 `term` 为 null、`relations` 为空,不是 404。
+         *
+         *     实现:`V3\NissayaCardController@__invoke`
+         */
+        get: operations["get_api_v3_nissaya_cards_ending_"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
     "/v3/password-resets": {
     "/v3/password-resets": {
         parameters: {
         parameters: {
             query?: never;
             query?: never;
@@ -39878,6 +39905,69 @@ export interface operations {
             422: components["responses"]["ProblemValidation"];
             422: components["responses"]["ProblemValidation"];
         };
         };
     };
     };
+    get_api_v3_nissaya_cards_ending_: {
+        parameters: {
+            query?: {
+                /** @description 语言,如 zh-Hans。缺省用界面语言(Accept-Language 协商的结果) */
+                lang?: string;
+            };
+            header?: never;
+            path: {
+                /** @description 缅文词尾,如 သည် */
+                ending: string;
+            };
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            ending?: string;
+                            lang?: string;
+                            term?: {
+                                id?: string;
+                                word?: string;
+                                tag?: string;
+                                meaning?: string;
+                                body?: components["schemas"]["MarkupNode"][];
+                            } | null;
+                            relations?: {
+                                relation?: string;
+                                relation_label?: string | null;
+                                from?: {
+                                    cases?: {
+                                        case?: string;
+                                        label?: string;
+                                    }[];
+                                    spell?: string;
+                                } | null;
+                                to?: {
+                                    cases?: {
+                                        case?: string;
+                                        label?: string;
+                                    }[];
+                                    spell?: string;
+                                } | null;
+                                category?: {
+                                    name?: string;
+                                    meaning?: string;
+                                    note?: string;
+                                } | null;
+                                local_endings?: string[];
+                            }[];
+                        };
+                    };
+                };
+            };
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
     post_api_v3_password_resets: {
     post_api_v3_password_resets: {
         parameters: {
         parameters: {
             query?: never;
             query?: never;

+ 28 - 61
dashboard-v6/src/components/nissaya/NissayaCard.tsx

@@ -1,24 +1,16 @@
 import { useEffect, useState, type JSX } from "react";
 import { useEffect, useState, type JSX } from "react";
-import {
-  App,
-  Button,
-  Modal,
-  Popover,
-  Skeleton,
-  Typography,
-  theme,
-} from "antd";
+import { Button, Modal, Popover, Skeleton, Typography, theme } from "antd";
 import { EditOutlined, ReloadOutlined } from "@ant-design/icons";
 import { EditOutlined, ReloadOutlined } from "@ant-design/icons";
 import { Link } from "react-router";
 import { Link } from "react-router";
 import { useIntl } from "react-intl";
 import { useIntl } from "react-intl";
 
 
-import { get } from "../../request";
 import { get as getLang } from "../../locales";
 import { get as getLang } from "../../locales";
 
 
-import NissayaCardTable, { type INissayaRelation } from "./NissayaCardTable";
+import NissayaCardTable from "./NissayaCardTable";
 
 
-import type { ITerm } from "../../api/Term";
-import MdView from "../general/MdView";
+import { fetchNissayaCard, type NissayaCard } from "../../api/nissaya";
+import MarkupView from "../markup/MarkupView";
+import type { MarkupNode } from "../markup/types";
 import TermModal from "../term/TermModal";
 import TermModal from "../term/TermModal";
 
 
 const { Paragraph, Title } = Typography;
 const { Paragraph, Title } = Typography;
@@ -27,17 +19,6 @@ const { Paragraph, Title } = Typography;
 // Types
 // Types
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 
 
-interface INissayaCardData {
-  row: INissayaRelation[];
-  ending: ITerm;
-}
-
-interface INissayaCardResponse {
-  ok: boolean;
-  message: string;
-  data: INissayaCardData;
-}
-
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // Public wrappers
 // Public wrappers
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
@@ -59,7 +40,7 @@ export const NissayaCardPop = ({ text, trigger }: INissayaCardModal) => {
           <Link to={`/workspace/nissaya/ending/${text}`} target="_blank">
           <Link to={`/workspace/nissaya/ending/${text}`} target="_blank">
             {intl.formatMessage(
             {intl.formatMessage(
               { id: "buttons.open.in.new.tab" },
               { id: "buttons.open.in.new.tab" },
-              { item: "" }
+              { item: "" },
             )}
             )}
           </Link>
           </Link>
         </div>
         </div>
@@ -118,11 +99,8 @@ const NissayaCardWidget = ({
   cache = false,
   cache = false,
   hideEditButton = false,
   hideEditButton = false,
 }: IWidgetProps) => {
 }: IWidgetProps) => {
-  // antd v6: use App.useApp() instead of static message/notification
-  const { message } = App.useApp();
-
-  const [cardData, setCardData] = useState<INissayaRelation[]>();
-  const [term, setTerm] = useState<ITerm>();
+  // v3 /nissaya-cards(取代 v2 nissaya-card):失败由 unwrap 统一提示
+  const [card, setCard] = useState<NissayaCard>();
   const [loading, setLoading] = useState(false);
   const [loading, setLoading] = useState(false);
   // Incrementing this counter triggers a manual reload
   // Incrementing this counter triggers a manual reload
   const [reloadTick, setReloadTick] = useState(0);
   const [reloadTick, setReloadTick] = useState(0);
@@ -131,44 +109,31 @@ const NissayaCardWidget = ({
     if (!text) return;
     if (!text) return;
 
 
     const uiLang = getLang();
     const uiLang = getLang();
-    const cacheKey = `nissaya-ending/${uiLang}/${text}`;
+    const cacheKey = `nissaya-card/${uiLang}/${text}`;
 
 
     // ── Cache hit (synchronous path) ────────────────────────────────────────
     // ── Cache hit (synchronous path) ────────────────────────────────────────
     if (cache) {
     if (cache) {
       const cached = sessionStorage.getItem(cacheKey);
       const cached = sessionStorage.getItem(cacheKey);
       if (cached) {
       if (cached) {
-        const parsed: INissayaCardData = JSON.parse(cached);
-        setCardData(parsed.row);
-        setTerm(parsed.ending);
+        // 读缓存后在 effect 里同步 setState 是原有写法(改成惰性初始化要连同 text 变化一起处理)
+        // eslint-disable-next-line react-hooks/set-state-in-effect
+        setCard(JSON.parse(cached) as NissayaCard);
         return; // no network request needed
         return; // no network request needed
       }
       }
     }
     }
 
 
     // ── Network request ─────────────────────────────────────────────────────
     // ── Network request ─────────────────────────────────────────────────────
-    const url = `/api/v2/nissaya-card/${text}?lang=${uiLang}&content_type=json`;
-    console.debug("api request", url);
-
     let cancelled = false;
     let cancelled = false;
     setLoading(true);
     setLoading(true);
 
 
-    get<INissayaCardResponse>(url)
-      .then((json) => {
-        if (cancelled) return;
-        console.debug("api response", json);
-
-        if (json.ok) {
-          setCardData(json.data.row);
-          setTerm(json.data.ending);
-          if (cache) {
-            sessionStorage.setItem(cacheKey, JSON.stringify(json.data));
-          }
-        } else {
-          message.error(json.message);
+    fetchNissayaCard(text, uiLang)
+      .then((data) => {
+        if (cancelled || !data) return;
+        setCard(data);
+        if (cache) {
+          sessionStorage.setItem(cacheKey, JSON.stringify(data));
         }
         }
       })
       })
-      .catch((e: INissayaCardResponse) => {
-        if (!cancelled) message.error(e.message);
-      })
       .finally(() => {
       .finally(() => {
         if (!cancelled) setLoading(false);
         if (!cancelled) setLoading(false);
       });
       });
@@ -177,12 +142,11 @@ const NissayaCardWidget = ({
     return () => {
     return () => {
       cancelled = true;
       cancelled = true;
     };
     };
-    // eslint-disable-next-line react-hooks/exhaustive-deps
   }, [cache, text, reloadTick]);
   }, [cache, text, reloadTick]);
 
 
   const handleReload = () => {
   const handleReload = () => {
     const uiLang = getLang();
     const uiLang = getLang();
-    sessionStorage.removeItem(`nissaya-ending/${uiLang}/${text}`);
+    sessionStorage.removeItem(`nissaya-card/${uiLang}/${text}`);
     setReloadTick((t) => t + 1);
     setReloadTick((t) => t + 1);
   };
   };
 
 
@@ -195,10 +159,10 @@ const NissayaCardWidget = ({
       {/* Header row */}
       {/* Header row */}
       <div style={{ display: "flex", justifyContent: "space-between" }}>
       <div style={{ display: "flex", justifyContent: "space-between" }}>
         <Title level={4}>
         <Title level={4}>
-          {term?.word}
-          {!hideEditButton && (
+          {card?.term?.word ?? card?.ending}
+          {!hideEditButton && card?.term?.id && (
             <TermModal
             <TermModal
-              id={term?.id}
+              id={card.term.id}
               trigger={<Button type="link" icon={<EditOutlined />} />}
               trigger={<Button type="link" icon={<EditOutlined />} />}
             />
             />
           )}
           )}
@@ -207,9 +171,12 @@ const NissayaCardWidget = ({
         <Button type="link" icon={<ReloadOutlined />} onClick={handleReload} />
         <Button type="link" icon={<ReloadOutlined />} onClick={handleReload} />
       </div>
       </div>
 
 
-      <Paragraph>{term?.meaning}</Paragraph>
-      <MdView html={term?.html} />
-      {cardData && <NissayaCardTable data={cardData} />}
+      <Paragraph>{card?.term?.meaning}</Paragraph>
+      <MarkupView
+        className="pcd_article"
+        nodes={card?.term?.body as MarkupNode[] | undefined}
+      />
+      {card?.relations && <NissayaCardTable data={card.relations} />}
     </div>
     </div>
   );
   );
 };
 };

+ 34 - 42
dashboard-v6/src/components/nissaya/NissayaCardTable.tsx

@@ -1,3 +1,5 @@
+import type { NissayaRelation, NissayaRelationSide } from "../../api/nissaya";
+import { fullUrl } from "../../utils";
 import { Button, Space, Table, Tag, Typography } from "antd";
 import { Button, Space, Table, Tag, Typography } from "antd";
 import lodash from "lodash";
 import lodash from "lodash";
 
 
@@ -49,36 +51,21 @@ const getCaseTags = (input: string[]): ITags[] => {
 const randomString = () =>
 const randomString = () =>
   lodash.times(20, () => lodash.random(35).toString(36)).join("");
   lodash.times(20, () => lodash.random(35).toString(36)).join("");
 
 
-interface ICaseItem {
-  label: string;
-  case: string;
-  link: string;
-}
-interface IRelationNode {
-  case?: ICaseItem[];
-  spell?: string;
-}
+/** 关系的一端(来源 / 目标):格位(带本地译名)与拼写,取自 v3 /nissaya-cards */
+type IRelationNode = NissayaRelationSide;
 interface DataType {
 interface DataType {
   key: string;
   key: string;
   relation: string;
   relation: string;
   localRelation?: string;
   localRelation?: string;
   tags?: ITags[];
   tags?: ITags[];
-  to?: IRelationNode;
-  from?: IRelationNode;
-  category?: { name: string; note: string; meaning: string };
+  to?: IRelationNode | null;
+  from?: IRelationNode | null;
+  category?: NissayaRelation["category"];
   translation?: string;
   translation?: string;
   isChildren?: boolean;
   isChildren?: boolean;
   children?: DataType[];
   children?: DataType[];
 }
 }
-export interface INissayaRelation {
-  from?: IRelationNode;
-  to?: IRelationNode;
-  category?: { name: string; note: string; meaning: string };
-  local_ending: string;
-  relation: string;
-  local_relation?: string;
-  relation_link: string;
-}
+export type INissayaRelation = NissayaRelation;
 interface IWidget {
 interface IWidget {
   data?: INissayaRelation[];
   data?: INissayaRelation[];
 }
 }
@@ -94,8 +81,8 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
     const newData: DataType[] = [];
     const newData: DataType[] = [];
     data.forEach((item) => {
     data.forEach((item) => {
       if (item.category && item.category.name) {
       if (item.category && item.category.name) {
-        const key = `${item.from?.spell}-${item.from?.case
-          ?.map((item) => item.label)
+        const key = `${item.from?.spell}-${item.from?.cases
+          ?.map((item) => item.label ?? item.case)
           .join()}-${item.relation}-${item.category}`;
           .join()}-${item.relation}-${item.category}`;
         if (!category.includes(key)) {
         if (!category.includes(key)) {
           category.push(key);
           category.push(key);
@@ -104,51 +91,51 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
           const children = data
           const children = data
             .filter(
             .filter(
               (value) =>
               (value) =>
-                `${value.from?.spell}-${value.from?.case
-                  ?.map((item) => item.label)
-                  .join()}-${value.relation}-${value.category}` === key
+                `${value.from?.spell}-${value.from?.cases
+                  ?.map((item) => item.label ?? item.case)
+                  .join()}-${value.relation}-${value.category}` === key,
             )
             )
             .map((item) => {
             .map((item) => {
               return {
               return {
                 key: randomString(),
                 key: randomString(),
-                relation: item.relation,
-                localRelation: item.local_relation,
+                relation: item.relation ?? "",
+                localRelation: item.relation_label ?? undefined,
                 from: item.from,
                 from: item.from,
                 to: item.to,
                 to: item.to,
                 category: item.category,
                 category: item.category,
-                translation: item.local_ending,
+                translation: item.local_endings?.join(";"),
                 isChildren: true,
                 isChildren: true,
               };
               };
             });
             });
           console.log("children", children);
           console.log("children", children);
           const caseList: string[] = [];
           const caseList: string[] = [];
           children.forEach((value) => {
           children.forEach((value) => {
-            value.to?.case?.forEach((value1) => {
-              caseList.push(value1.case);
+            value.to?.cases?.forEach((value1) => {
+              caseList.push(value1.case ?? "");
             });
             });
           });
           });
           const tags = getCaseTags(caseList);
           const tags = getCaseTags(caseList);
           newData.push({
           newData.push({
             key: randomString(),
             key: randomString(),
-            relation: item.relation,
-            localRelation: item.local_relation,
+            relation: item.relation ?? "",
+            localRelation: item.relation_label ?? undefined,
             from: item.from,
             from: item.from,
             to: item.to,
             to: item.to,
             tags: tags,
             tags: tags,
             category: item.category,
             category: item.category,
-            translation: item.local_ending,
+            translation: item.local_endings?.join(";"),
             children: children.length > 1 ? [...children] : undefined,
             children: children.length > 1 ? [...children] : undefined,
           });
           });
         }
         }
       } else {
       } else {
         newData.push({
         newData.push({
           key: randomString(),
           key: randomString(),
-          relation: item.relation,
-          localRelation: item.local_relation,
+          relation: item.relation ?? "",
+          localRelation: item.relation_label ?? undefined,
           from: item.from,
           from: item.from,
           to: item.to,
           to: item.to,
           category: item.category,
           category: item.category,
-          translation: item.local_ending,
+          translation: item.local_endings?.join(";"),
         });
         });
       }
       }
     });
     });
@@ -168,11 +155,11 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
           render: (_value, record) => {
           render: (_value, record) => {
             return (
             return (
               <Space>
               <Space>
-                {record.from?.case?.map((item, id) => {
+                {record.from?.cases?.map((item, id) => {
                   return (
                   return (
                     <GrammarLookup key={id} word={item.case}>
                     <GrammarLookup key={id} word={item.case}>
                       <Link>
                       <Link>
-                        <Tag>{item.label}</Tag>
+                        <Tag>{item.label ?? item.case}</Tag>
                       </Link>
                       </Link>
                     </GrammarLookup>
                     </GrammarLookup>
                   );
                   );
@@ -208,15 +195,20 @@ const NissayaCardTableWidget = ({ data }: IWidget) => {
               return (
               return (
                 <Space>
                 <Space>
                   <ArrowRightOutlined />
                   <ArrowRightOutlined />
-                  {record.to?.case?.map((item, id) => {
+                  {record.to?.cases?.map((item, id) => {
                     return (
                     return (
                       <Button
                       <Button
                         key={id}
                         key={id}
                         type="link"
                         type="link"
                         size="small"
                         size="small"
-                        onClick={() => window.open(item.link, "_blank")}
+                        onClick={() =>
+                          window.open(
+                            fullUrl(`/term/list/${item.case}`),
+                            "_blank",
+                          )
+                        }
                       >
                       >
-                        <Tag key={id}>{item.label}</Tag>
+                        <Tag key={id}>{item.label ?? item.case}</Tag>
                       </Button>
                       </Button>
                     );
                     );
                   })}
                   })}

+ 2 - 0
openapi/public/assets/protocol/main.yaml

@@ -839,6 +839,8 @@ paths:
     $ref: ./resources/auto/v3-me-reactions-reaction.yaml
     $ref: ./resources/auto/v3-me-reactions-reaction.yaml
   /v3/me/reading-time:
   /v3/me/reading-time:
     $ref: ./resources/auto/v3-me-reading-time.yaml
     $ref: ./resources/auto/v3-me-reading-time.yaml
+  '/v3/nissaya-cards/{ending}':
+    $ref: ./resources/auto/v3-nissaya-cards-ending.yaml
   /v3/password-resets:
   /v3/password-resets:
     $ref: ./resources/auto/v3-password-resets.yaml
     $ref: ./resources/auto/v3-password-resets.yaml
   '/v3/password-resets/{token}':
   '/v3/password-resets/{token}':

+ 7 - 0
openapi/public/assets/protocol/overrides/v2-nissaya-card-nissaya-card.yaml

@@ -0,0 +1,7 @@
+# 手写补充:v2 缅文词尾卡片已被 v3 取代(2026-11-17)。
+get:
+  deprecated: true
+  description: |
+    已被 `GET /v3/nissaya-cards/{ending}` 取代:只给结构化数据(不再有 mustache 渲染的 markdown 分支、写死的表头文字、拼好的 dashboard 链接),
+    术语批量查(v2 逐个格位查),词尾说明是新渲染器的节点树。字段:`row`→`relations`,`case`→`cases`,`local_relation`→`relation_label`,
+    `local_ending`(分号拼接)→`local_endings`(数组)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。

+ 5 - 1
openapi/public/assets/protocol/resources/auto/v2-nissaya-card-nissaya-card.yaml

@@ -4,7 +4,10 @@ get:
   tags:
   tags:
     - nissaya-card
     - nissaya-card
   operationId: get_api_v2_nissaya_card_nissaya_card_
   operationId: get_api_v2_nissaya_card_nissaya_card_
-  description: 实现:`NissayaCardController@show`
+  description: |
+    已被 `GET /v3/nissaya-cards/{ending}` 取代:只给结构化数据(不再有 mustache 渲染的 markdown 分支、写死的表头文字、拼好的 dashboard 链接),
+    术语批量查(v2 逐个格位查),词尾说明是新渲染器的节点树。字段:`row`→`relations`,`case`→`cases`,`local_relation`→`relation_label`,
+    `local_ending`(分号拼接)→`local_endings`(数组)。保留仅为 dashboard-v4 兼容,待 v4 下线后删除。
   parameters:
   parameters:
     -
     -
       name: nissaya_card
       name: nissaya_card
@@ -41,6 +44,7 @@ get:
       $ref: '../../main.yaml#/components/responses/Unauthorized'
       $ref: '../../main.yaml#/components/responses/Unauthorized'
     422:
     422:
       $ref: '../../main.yaml#/components/responses/ValidationError'
       $ref: '../../main.yaml#/components/responses/ValidationError'
+  deprecated: true
 put:
 put:
   summary: '更新 nissaya-card/{nissaya_card}'
   summary: '更新 nissaya-card/{nissaya_card}'
   tags:
   tags:

+ 61 - 0
openapi/public/assets/protocol/resources/auto/v3-nissaya-cards-ending.yaml

@@ -0,0 +1,61 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-nissaya-cards-ending.yaml
+get:
+  summary: 缅文词尾卡片
+  tags:
+    - nissaya-cards
+  operationId: get_api_v3_nissaya_cards_ending_
+  description: |-
+    词尾对应的语法术语(说明是新渲染器的节点树),以及它表达的语法关系:关系名与格位都带本地译名,
+    另有含义分类与翻译建议。术语取 `_System_Grammar_Term_{lang}_`,没有就用 en(`lang` 字段是实际用到的语言)。
+    词尾查不到时 `term` 为 null、`relations` 为空,不是 404。
+
+    实现:`V3\NissayaCardController@__invoke`
+  security:
+    - {  }
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: ending
+      in: path
+      required: true
+      schema:
+        type: string
+      description: '缅文词尾,如 သည်'
+    -
+      name: lang
+      in: query
+      schema:
+        type: string
+      description: '语言,如 zh-Hans。缺省用界面语言(Accept-Language 协商的结果)'
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: object
+                properties:
+                  ending:
+                    type: string
+                  lang:
+                    type: string
+                  term:
+                    type: object
+                    properties:
+                      id: { type: string }
+                      word: { type: string }
+                      tag: { type: string }
+                      meaning: { type: string }
+                      body: { type: array, items: { $ref: '../../main.yaml#/components/schemas/MarkupNode' } }
+                    nullable: true
+                  relations:
+                    type: array
+                    items:
+                      type: object
+                      properties: { relation: { type: string }, relation_label: { type: string, nullable: true }, from: { type: object, properties: { cases: { type: array, items: { type: object, properties: { case: { type: string }, label: { type: string } } } }, spell: { type: string } }, nullable: true }, to: { type: object, properties: { cases: { type: array, items: { type: object, properties: { case: { type: string }, label: { type: string } } } }, spell: { type: string } }, nullable: true }, category: { type: object, properties: { name: { type: string }, meaning: { type: string }, note: { type: string } }, nullable: true }, local_endings: { type: array, items: { type: string } } }
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'