Procházet zdrojové kódy

library 路由加前缀

visuddhinanda před 9 měsíci
rodič
revize
1154dbc120

+ 1 - 1
api-v8/resources/views/components/book-item.blade.php

@@ -3,7 +3,7 @@
     <div class="card h-100">
         <div class="card-body">
             <div class="book-cover-container">
-                <a href="{{ route('book.show', $book['id']) }}" class="text-decoration-none">
+                <a href="{{ route('library.book.show', $book['id']) }}" class="text-decoration-none">
                     <img src="{{ $book['cover'] ?? 'https://via.placeholder.com/300x400?text=No+Cover' }}"
                         alt="{{ $book['title'] ?? '未知书籍' }}"
                         class="book-cover"

+ 2 - 2
api-v8/resources/views/library/book/read.blade.php

@@ -323,7 +323,7 @@
                     <ul class="pagination">
                         @if(!empty($book["pagination"]["prev"]))
                         <li class="page-item page-prev">
-                            <a class="page-link" href='{{ route("book.read",$book["pagination"]["prev"]["id"]) }}'>
+                            <a class="page-link" href='{{ route("library.book.read",$book["pagination"]["prev"]["id"]) }}'>
                                 <div class="row align-items-center">
                                     <div class="col-auto">
                                         <!-- Download SVG icon from http://tabler.io/icons/icon/chevron-left -->
@@ -341,7 +341,7 @@
                         @endif
                         @if(!empty($book["pagination"]["next"]))
                         <li class="page-item page-next">
-                            <a class="page-link" href='{{ route("book.read",$book["pagination"]["next"]["id"]) }}'>
+                            <a class="page-link" href='{{ route("library.book.read",$book["pagination"]["next"]["id"]) }}'>
                                 <div class="row align-items-center">
                                     <div class="col">
                                         <div class="page-item-subtitle">next</div>

+ 4 - 4
api-v8/resources/views/library/book/show.blade.php

@@ -21,7 +21,7 @@
                 <div class="col">
                     <nav aria-label="breadcrumb">
                         <ol class="breadcrumb">
-                            <li class="breadcrumb-item"><a href="{{ route('home') }}">{{ __('labels.home') }}</a></li>
+                            <li class="breadcrumb-item"><a href="{{ route('library.home') }}">{{ __('labels.home') }}</a></li>
                             <li class="breadcrumb-item active">{{ $book['title'] }}</li>
                         </ol>
                     </nav>
@@ -34,7 +34,7 @@
                 <div class="card">
                     <img src="{{ $book['cover'] }}" class="card-img-top" alt="{{ $book['title'] }}" style="max-height: 400px; width: fit-content;">
                     <div class="card-body text-center">
-                        <a href="{{ route('book.read', $book['id']) }}" class="btn btn-primary btn-lg w-100 mb-2">
+                        <a href="{{ route('library.book.read', $book['id']) }}" class="btn btn-primary btn-lg w-100 mb-2">
                             <svg class="icon me-2" width="24" height="24">
                                 <use xlink:href="#tabler-book-2"></use>
                             </svg>
@@ -79,7 +79,7 @@
                     <div class="card-body">
                         <div class="list-group">
                             @foreach($book['contents'] as $chapter)
-                            <a href="{{ route('book.read', $chapter['id']) }}?chapter={{ $loop->iteration }}"
+                            <a href="{{ route('library.book.read', $chapter['id']) }}?chapter={{ $loop->iteration }}"
                                 class="list-group-item list-group-item-action">
                                 <div class="d-flex w-100 justify-content-between">
                                     <h4 class="mb-1">{{ $chapter['title'] }}</h4>
@@ -117,7 +117,7 @@
                                 <div class="d-flex">
                                     <img src="{{ $version['cover'] }}" class="me-3" style="width: 60px; height: 80px; object-fit: cover;" alt="{{ $version['title'] }}">
                                     <div>
-                                        <h6><a href="{{ route('book.show', $version['id']) }}">{{ $version['title'] }}</a></h6>
+                                        <h6><a href="{{ route('library.book.show', $version['id']) }}">{{ $version['title'] }}</a></h6>
                                         <div class="text-muted small">{{ $version['author'] }}</div>
                                         <div class="text-muted small">{{ $version['language'] ?? '巴利语' }}</div>
                                     </div>

+ 3 - 3
api-v8/resources/views/library/category.blade.php

@@ -10,13 +10,13 @@
                 <div class="col">
                     <nav aria-label="breadcrumb">
                         <ol class="breadcrumb">
-                            <li class="breadcrumb-item"><a href="{{ route('home') }}">{{ __('labels.home') }}</a></li>
+                            <li class="breadcrumb-item"><a href="{{ route('library.home') }}">{{ __('labels.home') }}</a></li>
                             @foreach($breadcrumbs as $breadcrumb)
                             @if($loop->last)
                             <li class="breadcrumb-item active">{{ $breadcrumb['name'] }}</li>
                             @else
                             <li class="breadcrumb-item">
-                                <a href="{{ route('category.show', $breadcrumb['id']) }}">{{ $breadcrumb['name'] }}</a>
+                                <a href="{{ route('library.category.show', $breadcrumb['id']) }}">{{ $breadcrumb['name'] }}</a>
                             </li>
                             @endif
                             @endforeach
@@ -33,7 +33,7 @@
             <div class="col-sm-6 col-lg-3">
                 <div class="card">
                     <div class="card-body text-center">
-                        <a href="{{ route('category.show', $subCategory['id']) }}" class="btn btn-primary">
+                        <a href="{{ route('library.category.show', $subCategory['id']) }}" class="btn btn-primary">
                             {{ $subCategory['name'] }}
                         </a>
                     </div>

+ 1 - 1
api-v8/resources/views/library/index.blade.php

@@ -24,7 +24,7 @@
                     {{ $data['category']['name'] }}
                 </h3>
                 <div class="card-actions">
-                    <a href="{{ route('category.show', $data['category']['id']) }}" class="btn btn-primary btn-sm">
+                    <a href="{{ route('library.category.show', $data['category']['id']) }}" class="btn btn-primary btn-sm">
                         {{ __('buttons.more') }}
                         <svg class="icon ms-1" width="24" height="24">
                             <use xlink:href="#tabler-arrow-right"></use>

+ 7 - 4
api-v8/routes/web.php

@@ -45,10 +45,7 @@ Route::redirect('/privacy', '/privacy/index');
 use App\Http\Controllers\CategoryController;
 use App\Http\Controllers\BookController;
 
-Route::get('/library', [CategoryController::class, 'index'])->name('home');
-Route::get('/library/category/{id}', [CategoryController::class, 'show'])->name('category.show');
-Route::get('/library/book/{id}', [BookController::class, 'show'])->name('book.show');
-Route::get('/library/book/{id}/read', [BookController::class, 'read'])->name('book.read');
+
 Route::post('/theme/toggle', [BookController::class, 'toggleTheme'])->name('theme.toggle');
 Route::post('/logout', function () {
     // Handle logout
@@ -56,6 +53,12 @@ Route::post('/logout', function () {
     return redirect('/login');
 })->name('logout');
 
+Route::prefix('library')->group(function () {
+    Route::get('/', [CategoryController::class, 'index'])->name('library.home');
+    Route::get('/category/{id}', [CategoryController::class, 'show'])->name('library.category.show');
+    Route::get('/book/{id}', [BookController::class, 'show'])->name('library.book.show');
+    Route::get('/book/{id}/read', [BookController::class, 'read'])->name('library.book.read');
+});
 // 博客路由
 Route::prefix('blog')->group(function () {
     Route::get('/{user}', [BlogController::class, 'index'])->name('blog.index');