* @Date: 2026-08-10 15:26:18 * @LastEditors: YwxApp * @LastEditTime: 2026-08-15 10:14:11 * @Description: * @FilePath: \ywxapp_dev\addon\articles\route\app.php * @CustomString: Copyright (c) 2026 YwxApp */ // +---------------------------------------------------------------------- // | 文章CMS插件路由:相对路由,由 AppService::loadAddonRoutes 统一补 articles 前缀 // | 约定:不要用 Route::group('articles') 再包一层(外层已补前缀,会双重前缀) // +---------------------------------------------------------------------- use think\facade\Route; // 前台(相对规则,由外层 Route::group('articles') 统一补全前缀,url() 用 articles/xxx/index 生成) Route::get('index/index', 'addon\articles\controller\Index@index'); Route::get('read/:id', 'addon\articles\controller\Article@read'); Route::get('article/detail/:id', 'addon\articles\controller\Article@detail'); Route::get('category/index', 'addon\articles\controller\Category@index'); Route::get('category/:id', 'addon\articles\controller\Category@index'); Route::get('tag/index', 'addon\articles\controller\Tag@index'); Route::get('tag/:id', 'addon\articles\controller\Tag@index'); Route::get('search/index', 'addon\articles\controller\Article@search'); Route::post('article/comment', 'addon\articles\controller\Article@comment'); // 后台(直接把 backend/ 写进 rule 路径,避免嵌套 Route::group('backend') 产生的歧义) // 实测结论:无论用嵌套 Route::group('backend') 还是把 backend 写进 rule 路径, // loadAddonRoutes 的外层 Route::group('articles') 都会把 backend 层级拼成「带点」形式 // → 真实 URL 固定为 /articles/backend.category/index.html(斜杠形式恒 404)。 // 故后台 URL 统一用带点,menu.json 的 jump 与视图 {:url('articles/backend.xxx/yyy')} 均须用带点。 // 注意:不能用 wxchat 的 ->prefix('backend/') 写法——articles 后台控制器在 controller/backend/ 子目录, // prefix 会让 TP 解析成 backend/backend/Category 导致 500(实测)。 Route::group('backend', function () { Route::get('article/index', 'Article/index'); Route::any('article/save', 'Article/save'); Route::get('article/edit', 'Article/edit'); Route::post('article/update', 'Article/update'); Route::post('article/delete', 'Article/delete'); Route::post('article/recyclebin', 'Article/recyclebin'); Route::post('article/restore', 'Article/restore'); Route::get('tag/index', 'Tag/index'); Route::any('tag/save', 'Tag/save'); Route::get('tag/edit', 'Tag/edit'); Route::post('tag/update', 'Tag/update'); Route::post('tag/delete', 'Tag/delete'); Route::get('comment/index', 'Comment/index'); Route::post('comment/audit', 'Comment/audit'); Route::post('comment/delete', 'Comment/delete'); Route::get('category/index', 'Category/index'); Route::any('category/save', 'Category/save'); Route::get('category/edit', 'Category/edit'); Route::post('category/update', 'Category/update'); Route::post('category/delete', 'Category/delete'); })->layer('backend');;