From 6f13d13d5a564680773d0d164359e4769dcb5fbf Mon Sep 17 00:00:00 2001 From: ak Date: Thu, 13 Aug 2026 03:32:27 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=B8=8A=E7=BA=BF=E5=89=8D=E5=8A=A0?= =?UTF-8?q?=E5=9B=BA=E2=80=94=E2=80=94=E8=B0=83=E5=BA=A6=E5=99=A8/?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=99=90=E6=B5=81/env=20=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - routes/console.php:注册每日数据库备份(03:00)+ 前台页面缓存清理(04:00) - 前台登录/注册 POST 加 throttle:6,1 防爆破 - .env.example 补 S3/LLM/MARKET/UPLOAD_DISK 配置项,新部署不再漏配 --- .env.example | 19 +++++++++++++++++++ routes/console.php | 23 ++++++++++++++++++----- routes/web.php | 8 ++++---- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 52462f3..3a913ec 100644 --- a/.env.example +++ b/.env.example @@ -76,3 +76,22 @@ WORKERMAN_QUEUE_CONNECTION=database WORKERMAN_QUEUES=default,ai WORKERMAN_MAX_TRIES=3 WORKERMAN_TIMEOUT=60 + +# ---- 附件 S3 兼容存储(R2 / COS / OSS / MinIO),不配置则回退本地 public ---- +UPLOAD_DISK=uploads +S3_ACCESS_KEY= +S3_SECRET_KEY= +S3_REGION=auto +S3_BUCKET= +S3_ENDPOINT= +S3_USE_PATH_STYLE_ENDPOINT=false +S3_URL= + +# ---- LLM(OpenAI 兼容:DeepSeek / 通义 / 自建代理),AI 评论审核与润色 ---- +LLM_BASE_URL=https://api.openai.com/v1 +LLM_API_KEY= +LLM_MODEL=gpt-4o-mini + +# ---- 插件/主题市场(可选,本地 ZIP 安装无需配置)---- +MARKET_URL= +MARKET_TOKEN= diff --git a/routes/console.php b/routes/console.php index 3c9adf1..694a5de 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,8 +1,21 @@ comment(Inspiring::quote()); -})->purpose('Display an inspiring quote'); +use Illuminate\Support\Facades\Schedule; + +/* +|-------------------------------------------------------------------------- +| 调度器(生产需配置 cron:* * * * * php artisan schedule:run) +|-------------------------------------------------------------------------- +*/ + +// 数据库每日备份(保留 7 天;spatie/laravel-backup) +Schedule::command('backup:run --only-db') + ->dailyAt('03:00') + ->withoutOverlapping() + ->appendOutputTo(storage_path('logs/backup.log')); + +// 每日清理前台页面缓存(避免旧缓存长期驻留) +Schedule::call(fn () => \App\Blog\Support\PageCacheMiddleware::flush()) + ->dailyAt('04:00'); diff --git a/routes/web.php b/routes/web.php index 5cd07d3..6b3450a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -66,15 +66,15 @@ 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.shtml', [AuthController::class, 'login']); -Route::post('/login', [AuthController::class, 'login']); +Route::post('/login.shtml', [AuthController::class, 'login'])->middleware('throttle:6,1'); +Route::post('/login', [AuthController::class, 'login'])->middleware('throttle:6,1'); Route::post('/logout.shtml', [AuthController::class, 'logout'])->name('logout'); Route::post('/logout', [AuthController::class, 'logout']); Route::get('/register.shtml', [AuthController::class, 'showRegister'])->name('register'); Route::get('/register', fn () => redirect()->route('register', [], 301)); -Route::post('/register.shtml', [AuthController::class, 'register']); -Route::post('/register', [AuthController::class, 'register']); +Route::post('/register.shtml', [AuthController::class, 'register'])->middleware('throttle:6,1'); +Route::post('/register', [AuthController::class, 'register'])->middleware('throttle:6,1'); Route::get('/profile.shtml', [AuthController::class, 'profile'])->middleware('auth')->name('profile'); Route::get('/profile', fn () => redirect()->route('profile', [], 301))->middleware('auth');