visuddhinanda пре 2 недеља
родитељ
комит
df5b768de0

+ 44 - 11
api-v13/app/Http/Controllers/Library/WikiController.php

@@ -12,6 +12,14 @@ use App\Services\OpenSearchService;
 
 class WikiController extends Controller
 {
+    // 质量等级(数值越小等级越高)
+    private  $qualityRank = [
+        'featured' => 1,
+        'standard' => 2,
+        'draft'    => 3,
+        'pending'  => 4,
+    ];
+
     public function __construct(
         private TermService    $termService,
         private OpenSearchService    $searchService
@@ -128,16 +136,10 @@ HTML,
 
         $result = $this->searchService->search($params);
 
-        // 质量等级(数值越小等级越高)
-        $qualityRank = [
-            'featured' => 1,
-            'standard' => 2,
-            'draft'    => 3,
-            'pending'  => 4,
-        ];
+
 
         // 当前允许的最大等级
-        $maxRank = $qualityRank[$quality] ?? 4;
+        $maxRank = $this->qualityRank[$quality] ?? 4;
 
         $unique = [];
 
@@ -151,7 +153,7 @@ HTML,
                 $itemQuality = 'pending';
             }
 
-            $itemRank = $qualityRank[$itemQuality] ?? 4;
+            $itemRank = $this->qualityRank[$itemQuality] ?? 4;
 
             // 按输入质量过滤
             if ($itemRank > $maxRank) {
@@ -176,7 +178,7 @@ HTML,
 
             // 已存在时,保留质量更高的
             $existingQuality = $unique[$key]['quality'];
-            $existingRank    = $qualityRank[$existingQuality] ?? 4;
+            $existingRank    = $this->qualityRank[$existingQuality] ?? 4;
 
             if ($itemRank < $existingRank) {
                 $unique[$key] = $record;
@@ -237,7 +239,8 @@ HTML,
                 'content' => $parsed['content'],
                 'toc'     => $parsed['toc'],
                 'edit_url' => config('mint.server.dashboard_base_path') . "/workspace/term/{$term['guid']}/edit",
-                'zh' => '编辑'
+                'zh' => '编辑',
+                'other_versions' => $this->otherVersions($term['word']),
             ]),
             'categories' => $this->categories(),
             'lang' => $lang,
@@ -338,4 +341,34 @@ HTML,
             ['word' => 'Rājagaha', 'lang' => 'pi'],
         ];
     }
+
+
+    private function otherVersions(string $word): array
+    {
+        $params = [
+            'query' => $word,
+            'pageSize'     => 10,
+            'resourceType' => 'term',
+            'tags'         => array_map(fn($n) => "quality:{$n}", array_keys($this->qualityRank)),
+        ];
+
+        $result = $this->searchService->search($params);
+        $versions = [];
+
+        foreach ($result['hits']['hits'] as $item) {
+            $text = $item['_source']['title']['text'];
+            $id   = $item['_source']['resource_id'];
+            $versions[] = [
+                'type'     => 'term',
+                'id'       => $id,
+                'lang'     => $item['_source']['language'],
+                'title'    => $text['zh'] ?? 'null',
+                'quality'  => $this->getQuality($item['_source']['tags'] ?? 'quality:pending'),
+                'category' => '法義術語',
+                'snippet'  => $item['_source']['summary']['text'],
+                'updated'  => $item['_source']['updated_at'],
+            ];
+        }
+        return $versions;
+    }
 }

+ 26 - 14
api-v13/resources/css/modules/_wiki.css

@@ -185,7 +185,7 @@
 }
 
 .wiki-today-title {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-size: 1.125rem;
     font-weight: 600;
     margin-bottom: 6px;
@@ -237,7 +237,7 @@
 }
 
 .wiki-popover-word {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-size: 0.9375rem;
     font-style: italic;
     font-weight: 600;
@@ -275,7 +275,7 @@
 }
 
 .wiki-drawer-word {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-size: 1.125rem;
     font-style: italic;
     font-weight: 600;
@@ -304,7 +304,7 @@
 }
 
 .wiki-term-card-word {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-size: 0.9375rem;
     font-style: italic;
     font-weight: 600;
@@ -364,7 +364,7 @@
    ══════════════════════════════════════════ */
 
 .wiki-content-body {
-    font-family: "Noto Serif", Georgia, "Times New Roman", serif;
+    font-family: 'Noto Serif', Georgia, 'Times New Roman', serif;
     font-size: 1rem;
     line-height: 1.875;
     color: var(--tblr-body-color);
@@ -383,7 +383,7 @@
 .wiki-content-body h4,
 .wiki-content-body h5,
 .wiki-content-body h6 {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-weight: 600;
     line-height: 1.3;
     color: var(--tblr-body-color);
@@ -471,7 +471,7 @@
     margin-bottom: 1.5em;
 }
 .wiki-content-body th {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-weight: 600;
     font-size: 0.8125rem;
     text-align: left;
@@ -494,7 +494,7 @@
 .wiki-content-body code {
     font-family: var(
         --tblr-font-monospace,
-        "SFMono-Regular",
+        'SFMono-Regular',
         Consolas,
         monospace
     );
@@ -558,7 +558,7 @@
     margin-bottom: 2rem;
 }
 .wiki-home-title h1 {
-    font-family: "Noto Serif", Georgia, serif;
+    font-family: 'Noto Serif', Georgia, serif;
     font-size: 2.25rem;
     font-weight: 600;
     color: var(--tblr-body-color);
@@ -586,7 +586,9 @@
     font-size: 0.8125rem;
     text-decoration: none;
     margin: 2px;
-    transition: background 0.12s, color 0.12s;
+    transition:
+        background 0.12s,
+        color 0.12s;
 }
 .wiki-hot-tag:hover {
     background: var(--wp-brand-light);
@@ -610,7 +612,7 @@
 }
 .wiki-home-divider::before,
 .wiki-home-divider::after {
-    content: "";
+    content: '';
     flex: 1;
     border-bottom: 1px solid var(--tblr-border-color);
 }
@@ -630,7 +632,9 @@
     color: var(--tblr-body-color);
     font-size: 0.875rem;
     text-decoration: none;
-    transition: background 0.12s, border-color 0.12s;
+    transition:
+        background 0.12s,
+        border-color 0.12s;
 }
 .wiki-language-tag:hover {
     background: var(--wp-brand-light);
@@ -804,7 +808,7 @@
 }
 
 .wiki-term-link--featured::before {
-    content: "★";
+    content: '★';
     display: inline-block;
     margin-right: 0.2em;
     font-size: 0.75em;
@@ -882,7 +886,9 @@ content: "●";
     color: var(--tblr-secondary);
     cursor: pointer;
     text-decoration: none;
-    transition: background 0.12s, color 0.12s;
+    transition:
+        background 0.12s,
+        color 0.12s;
 }
 
 .wiki-action-btn:hover {
@@ -940,3 +946,9 @@ content: "●";
     cursor: pointer;
     text-decoration: underline;
 }
+
+.wiki-other-versions {
+    padding-top: 1.25rem;
+    margin-top: 1.25rem;
+    border-top: 1px solid var(--tblr-border-color);
+}

+ 10 - 0
api-v13/resources/views/library/wiki/show.blade.php

@@ -39,6 +39,16 @@
         @endforeach
     </div>
 
+    {{-- 其他版本 --}}
+    @if(isset($entry['other_versions']) && count($entry['other_versions']) > 0)
+    <div class="wiki-other-versions">
+        <div class="wiki-sidebar-title" style="margin-bottom: 0.75rem;">其他版本</div>
+        @foreach ($entry['other_versions'] as $version)
+        <x-wiki.search-result-card :result="$version" :lang="$lang" />
+        @endforeach
+    </div>
+    @endif
+
 </article>
 
 @endsection