Browse Source

fix(api-v13): 阅读页无 channel 时默认展示巴利原文并强制显示原文

无 channel 参数时回退到 _System_Pali_VRI_,正文上方显示版本提示条;原文 channel 时忽略“显示原文”设置强制显示正文。
visuddhinanda 6 days ago
parent
commit
c1b9efb6f6

+ 6 - 1
api-v13/app/Http/Controllers/Library/BookController.php

@@ -103,6 +103,10 @@ class BookController extends Controller
     {
 
         $channelId = $request->input('channel');
+        $isDefaultChannel = empty($channelId);
+        if ($isDefaultChannel) {
+            $channelId = ChannelApi::getSysChannel('_System_Pali_VRI_');
+        }
 
         [$bookId, $paraId] = explode('-', $id);
         $bookId = (int) $bookId;
@@ -132,6 +136,7 @@ class BookController extends Controller
         $book['categories'] = $chapter['category'];
         $book['title'] = $chapter['title'];
         $book['author'] = $channel['name'];
+        $book['is_original'] = in_array($channel['type'], ['original', 'wbw'], true);
         $book['studio'] = $studio;
         $book['tags'] = [];
         $book['book_title'] = $this->getBookTitle($bookId, $paraId, $channelId);
@@ -154,7 +159,7 @@ class BookController extends Controller
         $editor_link = config('mint.server.dashboard_base_path')
             ."/workspace/tipitaka/chapter/{$id}?channel={$channelId}";
 
-        $view = view('library.book.read', compact('book', 'channels', 'editor_link', 'commentaryChannels'));
+        $view = view('library.book.read', compact('book', 'channels', 'editor_link', 'commentaryChannels', 'isDefaultChannel'));
 
         return $view;
     }

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

@@ -114,6 +114,7 @@ return [
     'versions' => 'Versions',
     'logout' => 'Logout',
     'select_version' => 'Select Version',
+    'default_version_notice' => 'No version selected — showing the Pali original by default.',
     'no_content' => 'No content',
     'prev_article' => 'Previous',
     'next_article' => 'Next',

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

@@ -114,6 +114,7 @@ return [
     'versions' => '版本',
     'logout' => '退出',
     'select_version' => '选择版本',
+    'default_version_notice' => '未选择版本,默认展示巴利原文。',
     'no_content' => '没有内容',
     'prev_article' => '上一篇',
     'next_article' => '下一篇',

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

@@ -114,6 +114,7 @@ return [
     'versions' => '版本',
     'logout' => '登出',
     'select_version' => '選擇版本',
+    'default_version_notice' => '未選擇版本,預設顯示巴利原文。',
     'no_content' => '無內容',
     'prev_article' => '上一篇',
     'next_article' => '下一篇',

+ 20 - 1
api-v13/resources/views/library/book/read.blade.php

@@ -170,6 +170,24 @@
                     @endif
                 </p>
 
+                {{-- 未选择版本时的提示条:默认展示巴利原文,并提供版本切换入口 --}}
+                @if(!empty($isDefaultChannel))
+                <div class="alert alert-info d-flex align-items-center justify-content-between flex-wrap gap-3 mb-4" role="alert">
+                    <div class="d-flex align-items-center gap-2">
+                        <i class="ti ti-info-circle" aria-hidden="true"></i>
+                        <span>{{ __('library.default_version_notice') }}</span>
+                    </div>
+                    @if(!empty($channels))
+                    <button type="button"
+                        class="btn btn-info btn-sm"
+                        data-bs-toggle="offcanvas"
+                        data-bs-target="#channelDrawer">
+                        <i class="ti ti-stack-2 me-1" aria-hidden="true"></i>{{ __('library.select_version') }}
+                    </button>
+                    @endif
+                </div>
+                @endif
+
                 {{-- ↓ 正文内容用 article 包裹,隔离排版作用域 ── --}}
                 <article class="reader-body">
                     @if(isset($book['content']))
@@ -361,7 +379,8 @@
     }
 
     document.addEventListener('DOMContentLoaded', function() {
-        const showOrigin = getCookie('show_origin') === 'true';
+        const isOriginalChannel = {{ !empty($book['is_original']) ? 'true' : 'false' }};
+        const showOrigin = isOriginalChannel || getCookie('show_origin') === 'true';
         document.getElementById('showOrigin').checked = showOrigin;
         document.getElementById('uiLanguage').value = getCookie('ui_language') || 'auto';
         document.getElementById('paliScript').value = getCookie('pali_script') || 'auto';