toc.blade.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {{-- resources/views/library/book/toc.blade.php
  2. TOC 列表局部视图,在 offcanvas 和侧边栏中复用。
  3. 变量:$toc array,$anthologyId(可选)
  4. 每个 item:active(当前章节高亮)、hide(折叠模式下隐藏的节点)。
  5. 折叠/展开由 .toc-tree 上的 .toc-expanded 类切换(见 reader.js / reader.css)。
  6. --}}
  7. @if(!empty($toc))
  8. @php $hasHidden = collect($toc)->contains(fn ($item) => $item['hide'] ?? false); @endphp
  9. <div class="toc-tree" data-toc-tree>
  10. @if($hasHidden)
  11. <button type="button" class="toc-toggle-all" data-toc-toggle>
  12. <i class="ti ti-arrows-maximize me-1"></i>
  13. <span class="toc-toggle-expand">{{ __('library.expand_all') }}</span>
  14. <span class="toc-toggle-collapse">{{ __('library.collapse_toc') }}</span>
  15. </button>
  16. @endif
  17. <ul>
  18. @foreach ($toc as $item)
  19. <li class="toc_item toc-level-{{ $item['level'] }}
  20. {{ ($item['active'] ?? false) ? 'toc-active' : ($item['disabled'] ? 'toc-disabled' : '') }}
  21. {{ ($item['hide'] ?? false) ? 'toc-hidden' : '' }}">
  22. @if($item['active'] ?? false)
  23. <span title="{{ $item['title'] }}">{{ $item['title'] }}</span>
  24. @elseif(!$item['disabled'])
  25. @if(isset($anthologyId))
  26. <a href="{{ route('library.anthology.read', ['anthology' => $anthologyId, 'article' => $item['id'], 'channel' => request('channel')]) }}"
  27. title="{{ $item['title'] }}">{{ $item['title'] }}</a>
  28. @else
  29. <a href="{{ route('library.tipitaka.read', ['id' => $item['id'], 'channel' => request('channel')]) }}"
  30. title="{{ $item['title'] }}">{{ $item['title'] }}</a>
  31. @endif
  32. @else
  33. <span title="{{ $item['title'] }}">{{ $item['title'] }}</span>
  34. @endif
  35. </li>
  36. @endforeach
  37. </ul>
  38. </div>
  39. @else
  40. <div class="alert alert-warning">{{ __('library.no_toc') }}</div>
  41. @endif