This commit is contained in:
make
2025-04-21 17:47:12 +08:00
parent 24cef96a26
commit 7ef217c1b9
523 changed files with 0 additions and 93250 deletions

View File

@@ -1,512 +0,0 @@
<?php
declare(strict_types=1);
use app\home\controller\Index;
use app\home\controller\Novel;
use app\home\controller\User;
use app\services\SiteContext;
use think\facade\Route;
Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) {
return view('test/test01/index.html');
});
/**
* 路由配置文件
*/
$arrRoutes = [
// H5/PC 端前缀
'prefixes' => [
'pc' => ['/pc', '/web', '/desktop', '/index', '/shouye', '/zhuomian'],
'h5' => ['','/nindex'],
],
// 通用路径别名
'paths' => [
// 章节相关路径
'chapter' => [
'/xiaoshuo/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]',
'/novel/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]',
'/book/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]',
'/xiaoshuo-:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]',
'/novel-:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]',
'/book-:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]',
],
// 最新章节-特殊页面处理
'latest' => [
'/xiaoshuo/:name-:intNovelId/chapter/latest',
'/novel/:name-:intNovelId/chapter/latest',
'/book/:name-:intNovelId/chapter/latest',
'/xiaoshuo-:name-:intNovelId/chapter/latest',
'/novel-:name-:intNovelId/chapter/latest',
'/book-:name-:intNovelId/chapter/latest',
],
// 目录相关路径
'catalog' => [
'/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]',
'/novel/:name-:intNovelId/catalog/:strOrder/[:intPage]',
'/book/:name-:intNovelId/table/:strOrder/[:intPage]',
'/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]',
'/novel/:name-:intNovelId/catalog/:strOrder/[:intPage]',
'/book/:name-:intNovelId/table/:strOrder/[:intPage]',
],
// 伪小说详情相关路径
'kan-novel' => [
'/kan-xiaoshuo/:name-:intNovelId-:n_forge_id',
'/show-novel/:name-:intNovelId-:n_forge_id',
'/seo-book/:name-:intNovelId-:n_forge_id',
'/show-xiaoshuo-:name-:intNovelId-:n_forge_id',
'/see-novel-:name-:intNovelId-:n_forge_id',
'/good-book-:name-:intNovelId-:n_forge_id',
],
// 小说详情相关路径
'novel' => [
'/xiaoshuo/:name-:intNovelId',
'/novel/:name-:intNovelId',
'/book/:name-:intNovelId',
'/xiaoshuo-:name-:intNovelId',
'/novel-:name-:intNovelId',
'/book-:name-:intNovelId',
],
// 书库
'library' => [
/**
* /shuku/nansheng-xiaoshuo/all/all/all/page1
* '/:strGender?/:strCategory?/:strStatus?/:strOrder?/:intPage?';
* 完整路由
* 使用: {site:nflurl gender="$strGender" category="$CategoryPinyin" status="all" order="all" page="1"/}
*/
// '/shuku/:strGender?/:strCategory?/:strStatus?/:strOrder?/page:intPage?',
'/shuku/:strGender/:strCategory/:strStatus/:strOrder/page:intPage',
'/books/:strGender/:strCategory/:strStatus/:strOrder/page:intPage',
'/library/:strGender/:strCategory/:strStatus/:strOrder/page:intPage',
'/fenlei/:strGender/:strCategory/:strStatus/:strOrder/page:intPage',
'/class/:strGender/:strCategory/:strStatus/:strOrder/page:intPage',
'/category/:strGender/:strCategory/:strStatus/:strOrder/page:intPage',
/**
* default 模板
* strGender 不需要
* 使用 gender 传空/或者不传,控制器会默认值是 all
* {site:nflurl gender="" category="$CategoryPinyin" status="all" order="all" page="1"/}
*/
'/shuku/:strCategory/:strStatus/:strOrder/page:intPage',
'/books/:strCategory/:strStatus/:strOrder/page:intPage',
'/library/:strCategory/:strStatus/:strOrder/page:intPage',
'/fenlei/:strCategory/:strStatus/:strOrder/page:intPage',
'/class/:strCategory/:strStatus/:strOrder/page:intPage',
'/category/:strCategory/:strStatus/:strOrder/page:intPage',
/**
* default 模板
* strGender strOrder 不需要
* 使用 gender 传空/或者不传,控制器会默认值是 all
* {site:nflurl gender="" category="$CategoryPinyin" status="all" order="all" page="1"/}
*/
// '/shuku/:strCategory/:strStatus/page:intPage',
// '/books/:strCategory/:strStatus/page:intPage',
// '/library/:strCategory/:strStatus/page:intPage',
// '/fenlei/:strCategory/:strStatus/page:intPage',
// '/class/:strCategory/:strStatus/page:intPage',
// '/category/:strCategory/:strStatus/page:intPage',
/**
* default 模板
* strGender 不需要
* 使用 gender 传空/或者不传,控制器会默认值是 all
* {site:nflurl gender="" category="$CategoryPinyin" status="all" order="all" page="1"/}
*/
// '/shuku/:strCategory/:strOrder/page:intPage',
// '/books/:strCategory/:strOrder/page:intPage',
// '/library/:strCategory/:strOrder/page:intPage',
// '/fenlei/:strCategory/:strOrder/page:intPage',
// '/class/:strCategory/:strOrder/page:intPage',
// '/category/:strCategory/:strOrder/page:intPage',
/**
* default 模板 /shuku/xuanhuan-xiuzhen/page1
* strGender strStatus strOrder 不需要
* 使用 gender 传空/或者不传,控制器会默认值是 all
* {site:nflurl gender="" category="$CategoryPinyin" status="all" order="all" page="1"/}
*/
// '/shuku/:strCategory/page:intPage',
// '/books/:strCategory/page:intPage',
// '/library/:strCategory/page:intPage',
// '/fenlei/:strCategory/page:intPage',
// '/class/:strCategory/page:intPage',
// '/category/:strCategory/page:intPage',
/**
* kuangyu 模板
* strOrder 不需要
* 使用 order 传空/或者不传,控制器会默认值是 all
* {site:nflurl gender="$strGender" category="$CategoryPinyin" status="all" page="1"/}
*/
'/shuku/:strGender/:strCategory/:strStatus/page:intPage',
'/books/:strGender/:strCategory/:strStatus/page:intPage',
'/library/:strGender/:strCategory/:strStatus/page:intPage',
'/fenlei/:strGender/:strCategory/:strStatus/page:intPage',
'/class/:strGender/:strCategory/:strStatus/page:intPage',
'/category/:strGender/:strCategory/:strStatus/page:intPage',
// '/shuku/:strGender/page:intPage',
// '/books/:strGender/page:intPage',
// '/library/:strGender/page:intPage',
// '/fenlei/:strGender/page:intPage',
// '/class/:strGender/page:intPage',
// '/category/:strGender/page:intPage',
],
// 书库首页
'library-index' => [
'/shuku/index',
'/books/index',
'/library/index',
'/fenlei/index',
'/class/index',
'/category/index',
],
//排行榜
'rank' => ['/paihang/all', '/rank/all', '/paihang-quan', '/top/all', '/paihang-bang', '/ranks/all'],
// 男生
'boys' => ['/nansheng-xiaoshuo', '/boys-novel', '/nansheng-shu', '/man-read', '/nansheng-book', '/male-novels'],
//女生
'girls' => ['/nvsheng-xiaoshuo', '/girls-novel', '/nvsheng-shu', '/woman-read', '/nvsheng-book', '/female-novels'],
//搜索
'search' => ['/search', '/explore', '/sousuo', '/find', '/query', '/keywords'],
// 用户中心
'user' => ['/user', '/my-account', '/profile', '/yonghu', '/wode-zhongxin', '/personal-center'],
//书架
'bookshelf' => ['/bookshelf', '/book-shelf', '/reading-shelf', '/shujia', '/yuedu-shujia', '/book-collection'],
//历史记录
'history' => ['/history', '/reading-history', '/read-record', '/lishi', '/yuedu-lishi', '/browse-past'],
// 首页
'index' => ['/'],
// 首页 - 如果info_id 》 0
'nindex' => ['/nindex'],
],
];
/**
* 遍历路由配置,动态注册 H5 和 PC 路由
*/
foreach ($arrRoutes['prefixes'] as $platform => $prefixes) {
$prefixes = is_array($prefixes) ? $prefixes : [$prefixes];
$boolIsMobile = $platform === 'h5';
foreach ($prefixes as $strPath) {
foreach ($arrRoutes['paths'] as $key => $arrUrl) {
foreach ($arrUrl as $strUrl) {
$strRoute = $strPath . $strUrl;
switch ($key) {
case 'latest':
//最新章节
$strView = 'pc/getNovelCatalog.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelCatalog.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})
->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]);
break;
case 'chapter':
//章节
$strView = 'pc/getNovelChapter.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelChapter.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})
->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'intChapterSort' => '\d+', 'intChapterPage' => '\d+']);
break;
case 'kan-novel':
//伪造小说详情
$strView = 'pc/getNovelInfo.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelInfo.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})
->pattern(['n_id' => '\d+', 'n_forge_id' => '\d+', 'name' => '[\w-]+',]);
break;
case 'novel':
//小说详情
$strView = 'pc/getNovelInfo.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelInfo.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})
->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]);
break;
case 'catalog':
//目录
$strView = 'pc/getNovelCatalog.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelCatalog.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})
->pattern(['n_id' => '\d+', 'name' => '[\w-]+', 'strOrder' => 'zheng|dao', 'intPage' => '\d+']);
break;
case 'library':
$strView = 'pc/getLibrary.html';
if ($platform == 'h5') {
$strView = 'novel/getLibrary.html';
}
//书库/分类
Route::get($strRoute, function () use ($strView) {
return view($strView);
})
->pattern([
'strGender' => '[a-z\-]*', // 允许空值
'strCategory' => '[a-z\-]*', // 允许空值
'strStatus' => '(all|lianzai|wanjie)?', // 允许空值
'strOrder' => '[a-z\-]*', // 允许空值
'intPage' => '\d*', // 允许空值
// 'strCategory' => 'all|xuanhuan-xiuzhen|junshi-xiaoshuo|wangyou-xiaoshuo|kehuan-xiaoshuo|zhongsheng-chuanyue|dushi-xiaoshuo|lingyi-xiaoshuo|yanqing-xiaoshuo|qita-xiaoshuo',
]);
break;
case 'library-index':
//书库/分类首页
$strView = 'pc/getLibrary.html';
if ($platform == 'h5') {
$strView = 'novel/getLibrary.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
});
break;
case 'rank':
//排行榜
$strView = 'pc/getNovelRank.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelRank.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
});
break;
case 'boys':
//男生
$strView = 'pc/getNovelChannel.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelChannel.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})->append(['strChannel' => 'man']);
//Route::get($strRoute, [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => $boolIsMobile, 'strChannel' => 'boys']);
break;
case 'girls':
//女生
$strView = 'pc/getNovelChannel.html';
if ($platform == 'h5') {
$strView = 'novel/getNovelChannel.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})->append(['strChannel' => 'women']);
//Route::get($strRoute, [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => $boolIsMobile, 'strChannel' => 'girls']);
break;
case 'search':
//搜素
$strView = 'pc/getSearchNovel.html';
if ($platform == 'h5') {
$strView = 'novel/getSearchNovel.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
})->ext('html');
break;
case 'user':
//用户中心
$strView = 'pc/user/index.html';
if ($platform == 'h5') {
$strView = 'user/index.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
});
break;
case 'bookshelf':
//书架
$strView = 'pc/user/getBookShelf.html';
if ($platform == 'h5') {
$strView = 'user/getBookShelf.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
});
break;
case 'history':
//历史记录
$strView = 'pc/user/getHistory.html';
if ($platform == 'h5') {
$strView = 'user/getHistory.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
});
break;
case 'index':
// 首页
if ($platform == 'h5') {
Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext ) {
return view($SiteContext->getHomeView('h5'));
});
} else {
Route::get($strRoute, function (\think\Request $Request, SiteContext $SiteContext ) {
return view($SiteContext->getHomeView('pc'));
});
}
break;
case 'nindex':
// 首页
$strView = 'pc/index.html';
if ($platform == 'h5') {
$strView = 'index/index.html';
}
Route::get($strRoute, function () use ($strView) {
return view($strView);
});
break;
}
}
}
}
}
/**
* 遍历路由配置,动态注册 H5 和 PC 路由
*/
// foreach ($arrRoutes['prefixes'] as $platform => $prefixes) {
// $prefixes = is_array($prefixes) ? $prefixes : [$prefixes];
// $boolIsMobile = $platform === 'h5';
// foreach ($prefixes as $strPath) {
// foreach ($arrRoutes['paths'] as $key => $arrUrl) {
// foreach ($arrUrl as $strUrl) {
// $strRoute = $strPath . $strUrl;
// switch ($key) {
// case 'latest':
// //最新章节
// Route::get($strRoute, [Novel::class, 'getNovelLatestChapter'])
// ->append(['boolIsMobile' => $boolIsMobile])
// ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]);
// break;
// case 'chapter':
// //章节
// Route::get($strRoute, [Novel::class, 'getNovelChapter'])
// ->append(['boolIsMobile' => $boolIsMobile])
// ->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'intChapterSort' => '\d+', 'intChapterPage' => '\d+']);
// break;
// case 'kan-novel':
// //伪造小说详情
// Route::get($strRoute, [Novel::class, 'getKanNovelInfo'])
// ->append(['boolIsMobile' => $boolIsMobile])
// ->pattern(['n_id' => '\d+', 'n_forge_id' => '\d+', 'name' => '[\w-]+',]);
// break;
// case 'novel':
// //小说详情
// Route::get($strRoute, [Novel::class, 'getNovelInfo'])
// ->append(['boolIsMobile' => $boolIsMobile])
// ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]);
// break;
// case 'catalog':
// //目录
// Route::get($strRoute, [Novel::class, 'getNovelCatalog'])
// ->append(['boolIsMobile' => $boolIsMobile])
// ->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'strOrder' => 'zheng|dao', 'intPage' => '\d+']);
// break;
// case 'library':
// //书库/分类 /shuku/all/xuanhuan-xiuzhen/all/all/page1
// Route::get($strRoute, [Novel::class, 'getLibrary'])
// ->append(['boolIsMobile' => $boolIsMobile])
// ->pattern([
// //'strGender' => 'all|nansheng-xiaoshuo|boys-novel|nansheng-shu|man-read|nansheng-book|male-novels|nvsheng-xiaoshuo|girls-novel|nvsheng-shu|woman-read|nvsheng-book|female-novels',
// 'strGender' => '[a-z\-]+',
// 'strCategory' => '[a-z\-]+',
// 'strStatus' => 'all|lianzai|wanjie',
// // 'strOrder' => '[a-z\-]+',
// 'intPage' => '\d+'
// ]);
// break;
// case 'library-index':
// //书库/分类首页
// Route::get($strRoute, [Novel::class, 'getLibrary'])->append(['boolIsMobile' => $boolIsMobile]);
// break;
// case 'rank':
// //排行榜
// Route::get($strRoute, [Novel::class, 'getNovelRank'])->append(['boolIsMobile' => $boolIsMobile]);
// break;
// case 'boys':
// //男生
// Route::get($strRoute, [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => $boolIsMobile, 'strChannel' => 'boys']);
// break;
// case 'girls':
// //女生
// Route::get($strRoute, [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => $boolIsMobile, 'strChannel' => 'girls']);
// break;
// case 'search':
// //搜素
// Route::get($strRoute, [Novel::class, 'getSearchNovel'])->ext('html')->append(['boolIsMobile' => $boolIsMobile]);
// break;
// case 'user':
// //用户中心
// Route::get($strRoute, [User::class, 'Index'])->append(['boolIsMobile' => $boolIsMobile]);
// break;
// case 'bookshelf':
// //书架
// Route::get($strRoute, [User::class, 'getBookShelf'])->append(['boolIsMobile' => $boolIsMobile]);
// break;
// case 'history':
// //历史记录
// Route::get($strRoute, [User::class, 'getHistory'])->append(['boolIsMobile' => $boolIsMobile]);
// break;
// case 'index':
// // 首页
// if ($platform == 'h5') {
// Route::get($strRoute, [Index::class, 'index'])->append(['boolIsMobile' => $boolIsMobile]);
// } else {
// Route::get($strRoute, [Index::class, 'getPcIndex'])->append(['boolIsMobile' => $boolIsMobile]);
// }
// break;
// }
// }
// }
// }
// }

View File

@@ -1,5 +0,0 @@
<?php
use app\services\SiteContext;
return app(SiteContext::class)->getViewConfig();