feat: 前台 .shtml 后缀 canonical + strict_types 全量启用 + 对外 API(Sanctum+Scramble 文档)+ pm2 ecosystem + GitHub Actions CI + 插件/主题/架构/API 文档 + REDIS_PREFIX 说明

This commit is contained in:
ak
2026-08-11 19:37:33 +08:00
parent 1c8a801238
commit fc6624cf84
244 changed files with 1902 additions and 97 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
use App\Http\Controllers\Api\ApiController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| 对外 API(小程序 / 第三方平台)
| 框架已为 api.php 自动添加 /api 前缀
| 文档:GET /docs/apiScramble 自动生成 OpenAPI
|--------------------------------------------------------------------------
*/
Route::get('/site', [ApiController::class, 'site'])->name('api.site');
Route::get('/posts', [ApiController::class, 'posts'])->name('api.posts');
Route::get('/posts/{slug}', [ApiController::class, 'post'])->name('api.post');
Route::get('/categories', [ApiController::class, 'categories'])->name('api.categories');
Route::get('/tags', [ApiController::class, 'tags'])->name('api.tags');
Route::post('/comments', [ApiController::class, 'storeComment'])->name('api.comments.store');
Route::middleware('auth:sanctum')->group(function () {
Route::get('/me', [ApiController::class, 'me'])->name('api.me');
});
+38 -17
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use App\Blog\Controllers\ArchiveController;
use App\Blog\Controllers\AuthController;
use App\Blog\Controllers\CategoryController;
@@ -16,7 +18,7 @@ use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| 前台规范路由
| 前台规范路由canonical .shtml 后缀,无后缀版本 301 兼容)
|--------------------------------------------------------------------------
*/
@@ -29,23 +31,46 @@ Route::get('/', function () {
return app(HomeController::class)->index();
})->name('home');
Route::get('/posts/{slug}', [PostController::class, 'show'])->name('posts.show');
Route::get('/posts/{slug}.shtml', [PostController::class, 'show'])->where('slug', '[A-Za-z0-9\-]+')->name('posts.show');
Route::get('/posts/{slug}', fn (string $slug) => redirect()->route('posts.show', $slug, 301))->where('slug', '[A-Za-z0-9\-]+');
Route::post('/posts/{post}/comments', [CommentController::class, 'store'])->name('comments.store');
Route::get('/category/{slug}', [CategoryController::class, 'show'])->name('category.show');
Route::get('/archives', [ArchiveController::class, 'index'])->name('archives');
Route::get('/archives/{year}/{month}', [ArchiveController::class, 'month'])->name('archives.month');
Route::get('/tags', [TagController::class, 'index'])->name('tags');
Route::get('/tags/{slug}', [TagController::class, 'show'])->name('tags.show');
Route::get('/search', [SearchController::class, 'index'])->name('search');
Route::get('/links', [LinkController::class, 'index'])->name('links');
Route::get('/comments', [CommentController::class, 'index'])->name('comments');
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
Route::get('/category/{slug}.shtml', [CategoryController::class, 'show'])->where('slug', '[A-Za-z0-9\-]+')->name('category.show');
Route::get('/category/{slug}', fn (string $slug) => redirect()->route('category.show', $slug, 301))->where('slug', '[A-Za-z0-9\-]+');
Route::get('/archives.shtml', [ArchiveController::class, 'index'])->name('archives');
Route::get('/archives', fn () => redirect()->route('archives', [], 301));
Route::get('/archives/{year}/{month}.shtml', [ArchiveController::class, 'month'])
->where(['year' => '\d{4}', 'month' => '\d{2}'])
->name('archives.month');
Route::get('/archives/{year}/{month}', fn (string $year, string $month) => redirect()->route('archives.month', [$year, $month], 301))
->where(['year' => '\d{4}', 'month' => '\d{2}']);
Route::get('/tags.shtml', [TagController::class, 'index'])->name('tags');
Route::get('/tags', fn () => redirect()->route('tags', [], 301));
Route::get('/tags/{slug}.shtml', [TagController::class, 'show'])->where('slug', '[A-Za-z0-9\-]+')->name('tags.show');
Route::get('/tags/{slug}', fn (string $slug) => redirect()->route('tags.show', $slug, 301))->where('slug', '[A-Za-z0-9\-]+');
Route::get('/search.shtml', [SearchController::class, 'index'])->name('search');
Route::get('/search', fn () => redirect()->route('search', [], 301));
Route::get('/links.shtml', [LinkController::class, 'index'])->name('links');
Route::get('/links', fn () => redirect()->route('links', [], 301));
Route::get('/comments.shtml', [CommentController::class, 'index'])->name('comments');
Route::get('/comments', fn () => redirect()->route('comments', [], 301));
Route::get('/login.shtml', [AuthController::class, 'showLogin'])->name('login');
Route::get('/login', fn () => redirect()->route('login', [], 301));
Route::post('/login', [AuthController::class, 'login']);
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
Route::get('/register', [AuthController::class, 'showRegister'])->name('register');
Route::get('/register.shtml', [AuthController::class, 'showRegister'])->name('register');
Route::get('/register', fn () => redirect()->route('register', [], 301));
Route::post('/register', [AuthController::class, 'register']);
Route::get('/profile', [AuthController::class, 'profile'])->middleware('auth')->name('profile');
Route::get('/profile.shtml', [AuthController::class, 'profile'])->middleware('auth')->name('profile');
Route::get('/profile', fn () => redirect()->route('profile', [], 301))->middleware('auth');
/*
|--------------------------------------------------------------------------
@@ -86,12 +111,8 @@ Route::get('/archives-{date}.html', [LegacyController::class, 'archivesRewritten
Route::get('/tagslist-{page}.html', fn () => redirect()->route('tags', [], 301))->where('page', '\d+');
Route::get('/tagslist.html', fn () => redirect()->route('tags', [], 301));
Route::get('/comments-{page}.html', fn () => redirect()->route('comments', [], 301))->where('page', '\d+');
Route::get('/comments.shtml', fn () => redirect()->route('comments', [], 301));
Route::get('/search-{page}.html', fn () => redirect()->route('search', [], 301))->where('page', '\d+');
Route::get('/search.shtml', fn () => redirect()->route('search', [], 301));
Route::get('/links.shtml', fn () => redirect()->route('links', [], 301));
Route::get('/reg.shtml', fn () => redirect()->route('register', [], 301));
Route::get('/login.shtml', fn () => redirect()->route('login', [], 301));
Route::get('/tag/{name}', [LegacyController::class, 'tagByName']);
Route::get('/index.php', fn () => app(LegacyController::class)->resolveAction(request()));