From 881c3f553502e310755da3176e79e608e8aee0ca Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Mon, 26 Jan 2026 09:54:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(api):=20=E8=B0=83=E6=95=B4=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=B7=AF=E7=94=B1=E9=85=8D=E7=BD=AE=E5=92=8C=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改前端开发环境API基础URL为本地地址 - 重新排列Markdown路由顺序,将静态路由置于动态路由之前 - 为Markdown和图片路由组添加注释说明路由冲突处理规则 - 重新排序图片删除路由以符合路由定义最佳实践 --- biji-php/config/routes.php | 8 +++++--- biji-qianduan/.env.development | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/biji-php/config/routes.php b/biji-php/config/routes.php index b5c5b51..1523b73 100644 --- a/biji-php/config/routes.php +++ b/biji-php/config/routes.php @@ -42,12 +42,13 @@ $app->group('/api/user', function (RouteCollectorProxy $group) { })->add(new AuthMiddleware()); // Markdown 相关路由(无需认证 - 公开阅读) +// 注意:静态路由必须在动态路由之前定义,避免路由冲突 $app->group('/api/markdown', function (RouteCollectorProxy $group) { - $group->get('/{id}', [MarkdownController::class, 'getById']); $group->get('', [MarkdownController::class, 'getAll']); $group->get('/search', [MarkdownController::class, 'search']); - $group->get('/grouping/{groupingId}', [MarkdownController::class, 'getByGroupingId']); $group->get('/recent', [MarkdownController::class, 'getRecent']); + $group->get('/grouping/{groupingId}', [MarkdownController::class, 'getByGroupingId']); + $group->get('/{id}', [MarkdownController::class, 'getById']); }); // Markdown 相关路由(需要认证) @@ -75,11 +76,12 @@ $app->group('/api/images', function (RouteCollectorProxy $group) { }); // 图片相关路由(需要认证) +// 注意:静态路由必须在动态路由之前定义,避免路由冲突 $app->group('/api/images', function (RouteCollectorProxy $group) { $group->post('', [ImageController::class, 'upload']); - $group->post('/{id}', [ImageController::class, 'delete']); $group->post('/deleteByUrl', [ImageController::class, 'deleteByUrl']); $group->post('/batch', [ImageController::class, 'batchDelete']); + $group->post('/{id}', [ImageController::class, 'delete']); })->add(new AuthMiddleware()); // 系统设置相关路由(无需认证 - 公开查询注册状态) diff --git a/biji-qianduan/.env.development b/biji-qianduan/.env.development index 9212022..9b9b1ea 100644 --- a/biji-qianduan/.env.development +++ b/biji-qianduan/.env.development @@ -1 +1 @@ -VITE_API_BASE_URL=https://hdy16-16.311169.xyz/api +VITE_API_BASE_URL=http://localhost:80