refactor: 外链中转拆为内置插件 neatstudio.link-tracker
- 插件承载全部逻辑:redirects 迁移(hasTable 兼容旧库)、Redirect 模型、UrlRedirector、/go 路由+控制器、Filament 外链中转资源 - 核心只留 hook 接入点: - tracked_url() 助手走 link.redirect 过滤器(评论正文/作者网址/友链模板统一调用) - 正文外链改写移到插件的 post.rendered 过滤器(优先级 20,晚于会员付费过滤) - 停用插件:链接恢复直连、内容不受影响;后台「管理 → 外链中转」查看点击量/启停 - 测试更新为插件上下文(含无过滤器降级断言);97 通过
This commit is contained in:
@@ -7,7 +7,6 @@ use App\Blog\Controllers\AuthController;
|
||||
use App\Blog\Controllers\CategoryController;
|
||||
use App\Blog\Controllers\CommentController;
|
||||
use App\Blog\Controllers\FeedController;
|
||||
use App\Blog\Controllers\GoController;
|
||||
use App\Blog\Controllers\HomeController;
|
||||
use App\Blog\Controllers\LegacyController;
|
||||
use App\Blog\Controllers\LinkController;
|
||||
@@ -39,8 +38,6 @@ Route::post('/posts/{post}/comments', [CommentController::class, 'store'])->name
|
||||
// 浏览量统计(独立端点,避开整页缓存,保证实时)
|
||||
Route::get('/track-view/{post}', fn (\App\Models\Post $post) => response($post->increment('views') ? '' : '', 204))->name('track-view');
|
||||
|
||||
// 外链中转:/go/{hash} 302 跳转,记录点击量;停用状态返回 410
|
||||
Route::get('/go/{hash}', [GoController::class, 'show'])->name('go.show');
|
||||
|
||||
Route::get('/category/{slug}.shtml', [CategoryController::class, 'show'])->where('slug', '[^/]+')->name('category.show');
|
||||
Route::get('/category/{slug}', fn (string $slug) => redirect()->route('category.show', $slug, 301))->where('slug', '[^/]+');
|
||||
|
||||
Reference in New Issue
Block a user