diff --git a/code/app/home/config/router.php b/code/app/home/config/router.php index 9e137ec..9ba6c7f 100644 --- a/code/app/home/config/router.php +++ b/code/app/home/config/router.php @@ -2,63 +2,80 @@ declare(strict_types=1); +use app\home\controller\Index; use app\home\controller\Novel; +use app\home\controller\User; use think\facade\Route; # 路由别名,可以忽略 // Route::alias("/index.html", "/")->append(['boolIsMobile' => true]); // Route::alias("/pc/index.html", "/")->append(['boolIsMobile' => false]); -Route::get("/", 'Index/index')->ext('html')->append(['boolIsMobile' => true]); -Route::get("/index", 'Index/index')->ext('html')->append(['boolIsMobile' => true]); -Route::get("/pc/index", 'Index/getPcIndex')->ext('html')->append(['boolIsMobile' => false]); -Route::get("/pc/", 'Index/getPcIndex')->append(['boolIsMobile' => false]); +Route::get("/", [Index::class,'index'])->ext('html')->append(['boolIsMobile' => true]); +Route::get("/index", [Index::class,'index'])->ext('html')->append(['boolIsMobile' => true]); +Route::get("/pc/index", [Index::class,'getPcIndex'])->ext('html')->append(['boolIsMobile' => false]); +Route::get("/pc/", [Index::class,'getPcIndex'])->append(['boolIsMobile' => false]); // 书架 -Route::get('bookshelf', 'User/getBookShelf')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/bookshelf', 'User/getBookShelf')->ext('html')->append(['boolIsMobile' => false]); +Route::get('bookshelf', [User::class,'getBookShelf'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('/pc/bookshelf', [User::class,'getBookShelf'])->ext('html')->append(['boolIsMobile' => false]); //排行榜 -Route::get('rank', 'Novel/getNovelRank')->ext('html')->append(['boolIsMobile' => true]); -Route::get("/pc/rank", 'Novel/getNovelRank')->ext('html')->append(['boolIsMobile' => false]); +Route::get('paihang', [Novel::class,'getNovelRank'])->append(['boolIsMobile' => true]); +Route::get("/pc/paihang", [Novel::class,'getNovelRank'])->append(['boolIsMobile' => false]); -// 男生/女生-grok 推荐最优方案 -Route::get('nansheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => true, 'strChannel' => 'girls']); -Route::get('pc/nvsheng-xiaoshuo', [Novel::class, 'getNovelgetNovelChannelInfo'])->append(['boolIsMobile' => false, 'strChannel' => 'girls']); +// 男生/女生 - grok 推荐最优方案 +Route::get('/nansheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => true, 'strChannel' => 'boys']); +Route::get('/nvsheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => false, 'strChannel' => 'girls']); +Route::get('/pc/nansheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => false, 'strChannel' => 'boys']); +Route::get('/pc/nvsheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append(['boolIsMobile' => false, 'strChannel' => 'girls']); + +// 书库 - grok 推荐最优方案 /shuku/channel-category-status-page +Route::get('/shuku/all', [Novel::class,'getLibrary'])->append(['boolIsMobile' => true]); +Route::get('/pc/shuku/all', [Novel::class,'getLibrary'])->append(['boolIsMobile' => false]); +Route::get('/shuku/:strNovelChannel-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary']) +->pattern([ + 'strNovelChannel' => '[\w]*', + 'strCategory' => '[\w]*', + 'strStatus' => '[\w]*', + 'intPage' => '\d+' +]) +->append(['boolIsMobile' => true]); +Route::get('/pc/shuku/:strNovelChannel-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary']) +->pattern([ + 'strNovelChannel' => '[\w]*', + 'strCategory' => '[\w]*', + 'strStatus' => '[\w]*', + 'intPage' => '\d+' +]) +->append(['boolIsMobile' => false]); //分类 -Route::get('class', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/class', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => false]); - -// //分类 使用模板:xmttxs -// Route::get('/books', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => true]); -// Route::get('/pc/books', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => false]); -// Route::get('/books/[:intCategoryId]-[:intPage]', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/fenlei/append(['boolIsMobile' => false]) -->pattern(['intCategoryId' => '\d+','intPage' => '\d+',]) -->ext('html'); +// Route::get('class', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => true]); +// Route::get('/pc/class', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => false]); +// // //分类 使用模板:xmttxs +// // Route::get('/books', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => true]); +// // Route::get('/pc/books', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => false]); +// // Route::get('/books/[:intCategoryId]-[:intPage]', 'Novel/getNovelCategory')->ext('html')->append(['boolIsMobile' => true]); +// Route::get('/pc/fenlei/append(['boolIsMobile' => false]) +// ->pattern(['intCategoryId' => '\d+','intPage' => '\d+',]) +// ->ext('html'); + -// 书库 -Route::get('/library', 'Novel/getLibrary')->ext('html')->append(['boolIsMobile' => true]); -Route::get("/pc/library", 'Novel/getLibrary')->ext('html')->append(['boolIsMobile' => false]); -Route::get('/shuku', 'Novel/getLibrary')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/shuku', 'Novel/getLibrary')->ext('html')->append(['boolIsMobile' => false]); -Route::get('/shuku/[:strNovelChannel]-[:intCategoryId]-[:strStatus]-[:intPage]', 'Novel/getLibrary')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/shuku/[:strNovelChannel]-[:intCategoryId]-[:strStatus]-[:intPage]', 'Novel/getLibrary')->ext('html')->append(['boolIsMobile' => false]); // 文章 列表 -Route::get('/article/list-[:intCategoryId]-[:intPage]', 'Novel/getArticleList')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/article/list-[:intCategoryId]-[:intPage]', 'Novel/getArticleList')->ext('html')->append(['boolIsMobile' => false]); -Route::get('/article/list', 'Novel/getArticleList')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/article/list', 'Novel/getArticleList')->ext('html')->append(['boolIsMobile' => false]); +Route::get('/article/list-[:intCategoryId]-[:intPage]', [Novel::class,'getArticleList'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('/pc/article/list-[:intCategoryId]-[:intPage]', [Novel::class,'getArticleList'])->ext('html')->append(['boolIsMobile' => false]); +Route::get('/article/list', [Novel::class,'getArticleList'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('/pc/article/list', [Novel::class,'getArticleList'])->ext('html')->append(['boolIsMobile' => false]); // 文章 详情 -Route::get('/article/info-:intArticleId', 'Novel/getArticleInfo')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/article/info-:intArticleId', 'Novel/getArticleInfo')->ext('html')->append(['boolIsMobile' => false]); +Route::get('/article/info-:intArticleId', [Novel::class,'getArticleInfo'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('/pc/article/info-:intArticleId', [Novel::class,'getArticleInfo'])->ext('html')->append(['boolIsMobile' => false]); // 小说详情 @@ -103,23 +120,23 @@ Route::get('/pc/chapter/:intNovelId-:intChapterId-[:intChapterPage]', 'Novel/get Route::get('/pc/books/:intNovelId-:intChapterId-[:intChapterPage]', 'Novel/getNovelChapter')->ext('html')->append(['boolIsMobile' => false]); // 小说目录 -Route::get('/chapters/:intNovelId-[:intPage]-[:strSort]', 'Novel/getNovelChapterAll')->ext('html')->append(['boolIsMobile' => true]); -Route::get('pc/chapters/:intNovelId-[:intPage]-[:strSort]', 'Novel/getNovelChapterAll')->ext('html')->append(['boolIsMobile' => false]); -Route::get('/chapters', 'Novel/getNovelChapterAll')->ext('html')->append(['boolIsMobile' => true]); -Route::get('pc/chapters', 'Novel/getNovelChapterAll')->ext('html')->append(['boolIsMobile' => false]); +Route::get('/chapters/:intNovelId-[:intPage]-[:strSort]', [Novel::class,'getNovelChapterAll'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('pc/chapters/:intNovelId-[:intPage]-[:strSort]', [Novel::class,'getNovelChapterAll'])->ext('html')->append(['boolIsMobile' => false]); +Route::get('/chapters', [Novel::class,'getNovelChapterAll'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('pc/chapters', [Novel::class,'getNovelChapterAll'])->ext('html')->append(['boolIsMobile' => false]); // 搜索小说 -Route::get('search', 'Novel/getSearchNovel')->ext('html')->append(['boolIsMobile' => true]); -Route::get('pc/search', 'Novel/getSearchNovel')->ext('html')->append(['boolIsMobile' => false]); +Route::get('search', [Novel::class,'getSearchNovel'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('pc/search', [Novel::class,'getSearchNovel'])->ext('html')->append(['boolIsMobile' => false]); // 小说用户中心 -Route::get('/user', 'User/Index')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/user', 'User/Index')->ext('html')->append(['boolIsMobile' => false]); +Route::get('/user', [User::class,'Index'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('/pc/user', [User::class,'Index'])->ext('html')->append(['boolIsMobile' => false]); // 历史记录 -Route::get('history', 'User/getHistory')->ext('html')->append(['boolIsMobile' => true]); -Route::get('/pc/history', 'User/getHistory')->ext('html')->append(['boolIsMobile' => false]); +Route::get('history', [User::class,'getHistory'])->ext('html')->append(['boolIsMobile' => true]); +Route::get('/pc/history', [User::class,'getHistory'])->ext('html')->append(['boolIsMobile' => false]); @@ -154,112 +171,112 @@ Route::get('/pc/history', 'User/getHistory')->ext('html')->append(['boolIsMobile // $arrRoutes = [ // # 小说推荐 // [ -// 'class'=>'Novel/getRankList', +// 'class'=>[Novel::class,'getRankList'], // 'name'=>'Novel@getTuijianList', // 'path'=>[ -// '/tj/:intTjdj-[:intPage]', -// '/tuijian/:intTjdj-[:intPage]', -// '/recommend/:intTjdj-[:intPage]', -// '/nice/:intTjdj-[:intPage]', -// '/good/:intTjdj-[:intPage]', -// '/推荐/:intTjdj-[:intPage]', +// [::class,'tj/:intTjdj-[:intPage]'], +// [::class,'tuijian/:intTjdj-[:intPage]'], +// [::class,'recommend/:intTjdj-[:intPage]'], +// [::class,'nice/:intTjdj-[:intPage]'], +// [::class,'good/:intTjdj-[:intPage]'], +// [::class,'推荐/:intTjdj-[:intPage]'], // ], // ], // # 小说分类 // [ -// 'class'=>'Novel/getCategoryList', +// 'class'=>[Novel::class,'getCategoryList'], // 'name'=>'Novel@getCategoryList', // 'path'=>[ -// '/list/:intCId-:intSort-:intStatus-[:intPage]', -// '/fenlei/:intCId-:intSort-:intStatus-[:intPage]', -// '/class/:intCId-:intSort-:intStatus-[:intPage]', -// '/type/:intCId-:intSort-:intStatus-[:intPage]', -// '/leixin/:intCId-:intSort-:intStatus-[:intPage]', -// '/小说分类/:intCId-:intSort-:intStatus-[:intPage]', +// [::class,'list/:intCId-:intSort-:intStatus-[:intPage]'], +// [::class,'fenlei/:intCId-:intSort-:intStatus-[:intPage]'], +// [::class,'class/:intCId-:intSort-:intStatus-[:intPage]'], +// [::class,'type/:intCId-:intSort-:intStatus-[:intPage]'], +// [::class,'leixin/:intCId-:intSort-:intStatus-[:intPage]'], +// [::class,'小说分类/:intCId-:intSort-:intStatus-[:intPage]'], // ], // ], // # 小说排行 // [ -// 'class'=>'Novel/getNovelRankList', +// 'class'=>[Novel::class,'getNovelRankList'], // 'name'=>'Novel@getNovelRankList', // 'path'=>[ -// '/paihang/:intCId-:intSort-[:intPage]', -// '/paihanbang/:intCId-:intSort-[:intPage]', -// '/rank/:intCId-:intSort-[:intPage]', -// '/sort/:intCId-:intSort-[:intPage]', -// '/pb/:intCId-:intSort-[:intPage]', -// '/排行榜/:intCId-:intSort-[:intPage]', +// [::class,'paihang/:intCId-:intSort-[:intPage]'], +// [::class,'paihanbang/:intCId-:intSort-[:intPage]'], +// [::class,'rank/:intCId-:intSort-[:intPage]'], +// [::class,'sort/:intCId-:intSort-[:intPage]'], +// [::class,'pb/:intCId-:intSort-[:intPage]'], +// [::class,'排行榜/:intCId-:intSort-[:intPage]'], // ], // ], // # 小说章节 // [ -// 'class'=>'Novel/getReader', +// 'class'=>[Novel::class,'getReader'], // 'name'=>'Novel@getReader', // 'path'=>[ -// '/xq/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/xiaoshuo/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/novel/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/info/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/shu/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/小说/:intNovelId/:intZhangJiePaiXu-[:strSort]', +// [::class,'xq/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'xiaoshuo/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'novel/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'info/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'shu/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'小说/:intNovelId/:intZhangJiePaiXu-[:strSort]'], -// '/book/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/kan/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/show/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/yuedu/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/see/:intNovelId/:intZhangJiePaiXu-[:strSort]', -// '/相关/:intNovelId/:intZhangJiePaiXu-[:strSort]', +// [::class,'book/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'kan/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'show/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'yuedu/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'see/:intNovelId/:intZhangJiePaiXu-[:strSort]'], +// [::class,'相关/:intNovelId/:intZhangJiePaiXu-[:strSort]'], // ], // ], // # 小说详情 // [ -// 'class'=>'Novel/getDetail', +// 'class'=>[Novel::class,'getDetail'], // 'name'=>'Novel@getDetail', // 'path'=>[ -// '/xq/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/xiaoshuo/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/novel/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/info/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/shu/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/小说/:intNovelId-[:intCurrentPage]-[:strSort]', +// [::class,'xq/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'xiaoshuo/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'novel/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'info/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'shu/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'小说/:intNovelId-[:intCurrentPage]-[:strSort]'], -// '/book/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/kan/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/show/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/yuedu/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/see/:intNovelId-[:intCurrentPage]-[:strSort]', -// '/相关/:intNovelId-[:intCurrentPage]-[:strSort]', +// [::class,'book/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'kan/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'show/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'yuedu/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'see/:intNovelId-[:intCurrentPage]-[:strSort]'], +// [::class,'相关/:intNovelId-[:intCurrentPage]-[:strSort]'], // ], // ], // # 搜索 - 小说 // [ -// 'class'=>'Search/getNovel', +// [class'=>'Search::class,'getNovel'], // 'name'=>'Search@getNovel', // 'path'=>[ -// '/search', +// [::class,'search'], // ], // ], // # 书架 // [ -// 'class'=>'Search/getShujia', -// 'name'=>'Search/getShujia', +// [class'=>'Search::class,'getShujia'], +// [name'=>'Search::class,'getShujia'], // 'path'=>[ -// '/shujia', +// [::class,'shujia'], // ], // ], // # 收藏 // [ -// 'class'=>'Search/addSc', -// 'name'=>'Search/addSc', +// [class'=>'Search::class,'addSc'], +// [name'=>'Search::class,'addSc'], // 'path'=>[ -// '/sc', +// [::class,'sc'], // ], // ], // ]; -// // Route::get('/sc', 'Novel/addSc') +// // Route::get('/sc', [Novel::class,'addSc']) // // ->middleware('Throttle:5,60') // 限制 1 分钟内最多 5 次 // // ->name('Novel@addSc'); diff --git a/code/app/home/controller/Index.php b/code/app/home/controller/Index.php index 50d6249..58a80d8 100644 --- a/code/app/home/controller/Index.php +++ b/code/app/home/controller/Index.php @@ -115,7 +115,8 @@ class Index extends BaseController /** * 首页数据-PC - * + * @param Request $Request + * @return void */ public function getPcIndex(Request $Request) { diff --git a/code/app/home/controller/Novel.php b/code/app/home/controller/Novel.php index e1035e2..5816cd5 100644 --- a/code/app/home/controller/Novel.php +++ b/code/app/home/controller/Novel.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace app\home\controller; use app\home\BaseController; +use app\model\NovelModel; use storage\StorageCore; use think\facade\View; use app\Request; @@ -119,26 +120,39 @@ class Novel extends BaseController } } - // 书库 [:strNovelChannel]-[:intCategoryId]-[:strStatus]-[:strTextNumber]-[:strUpdateTime]-[:strSort] - public function getLibrary(Request $Request, $strNovelChannel = null, $intCategoryId = null, $strStatus = null, $strTextNumber = null, $strUpdateTime = null, $strSort = null, $intPage = 1) + /** + * 书库 + * + * @param Request $Request + * @param [type] $strNovelChannel 男生/女生 -拼音 + * @param [type] $strCategory 分类 -拼音 + * @param [type] $strStatus 连载/完结 -拼音 + * @param integer $intPage 分页 + * @return void + */ + public function getLibrary(Request $Request, $strNovelChannel = 'all', $strCategory = 'all', $strStatus = 'all',$intPage = 1) { $boolIsMobile = $Request->param('boolIsMobile'); // 模拟数据 $arrNovel = [ - ['id' => 1, 'name' => '小说1', 'author' => '作者1'], - ['id' => 2, 'name' => '小说2', 'author' => '作者2'], - ['id' => 3, 'name' => '小说3', 'author' => '作者3'], - ['id' => 4, 'name' => '小说3', 'author' => '作者3'], - ['id' => 5, 'name' => '小说3', 'author' => '作者3'], - ['id' => 6, 'name' => '小说3', 'author' => '作者3'], - ['id' => 7, 'name' => '小说3', 'author' => '作者3'], - ['id' => 8, 'name' => '小说3', 'author' => '作者3'], + ['n_id' => 1, 'name' => '小说1', 'author' => '作者1'], + ['n_id' => 2, 'name' => '小说2', 'author' => '作者2'], + ['n_id' => 3, 'name' => '小说3', 'author' => '作者3'], + ['n_id' => 4, 'name' => '小说3', 'author' => '作者3'], + ['n_id' => 5, 'name' => '小说3', 'author' => '作者3'], + ['n_id' => 6, 'name' => '小说3', 'author' => '作者3'], + ['n_id' => 7, 'name' => '小说3', 'author' => '作者3'], + ['n_id' => 8, 'name' => '小说3', 'author' => '作者3'], ]; View::assign([ 'arrNovel' => $arrNovel, - 'strPageCode' => 'library' + 'strPageCode' => 'library', + 'strNovelChannel' => $strNovelChannel, + 'strCategory' => $strCategory, + 'strStatus' => $strStatus, + 'intPage' => $intPage, ]); if ($boolIsMobile) { return View::fetch(); @@ -175,68 +189,44 @@ class Novel extends BaseController } } - // 男生女生频道 + /** + * 男生女生频道 + * + * @param Request $Request + * @return void + */ public function getNovelChannel(Request $Request) { $boolIsMobile = $Request->param('boolIsMobile'); $strNovelChannel = $Request->param('strChannel'); // 区分男生/女生频道 - // 模拟数据-推荐等级为9的,连载的,男生频道/女生频道, 随机12个小说 - $arrRecommendSerializationNovel = [ - ['id' => 1, 'name' => '小说1', 'author' => '作者1'], - ['id' => 2, 'name' => '小说2', 'author' => '作者2'], - ['id' => 3, 'name' => '小说3', 'author' => '作者3'], - ['id' => 4, 'name' => '小说3', 'author' => '作者3'], - ['id' => 5, 'name' => '小说3', 'author' => '作者3'], - ['id' => 6, 'name' => '小说3', 'author' => '作者3'], - ['id' => 7, 'name' => '小说3', 'author' => '作者3'], - ['id' => 8, 'name' => '小说3', 'author' => '作者3'], - ['id' => 9, 'name' => '小说3', 'author' => '作者3'], - ['id' => 10, 'name' => '小说3', 'author' => '作者3'], - ['id' => 11, 'name' => '小说3', 'author' => '作者3'], - ['id' => 12, 'name' => '小说3', 'author' => '作者3'], - ]; - // 模拟数据-推荐等级为9的,完结的,男生频道/女生频道, 随机8个小说 - $arrRecommendEndNovel = [ - ['id' => 1, 'name' => '小说1', 'author' => '作者1'], - ['id' => 2, 'name' => '小说2', 'author' => '作者2'], - ['id' => 3, 'name' => '小说3', 'author' => '作者3'], - ['id' => 4, 'name' => '小说3', 'author' => '作者3'], - ['id' => 5, 'name' => '小说3', 'author' => '作者3'], - ['id' => 6, 'name' => '小说3', 'author' => '作者3'], - ['id' => 7, 'name' => '小说3', 'author' => '作者3'], - ['id' => 8, 'name' => '小说3', 'author' => '作者3'], + $NovelModel = new NovelModel; + $intType = ['boys' => 1, 'girls' => 2][$strNovelChannel]; + $intLifeTime = 24 * 3600; - ]; + // 推荐等级为9的,连载的,男生频道/女生频道, 随机12个小说 + $strKey = sprintf('%s:PC:Novel:Channel:Hot:%s:%s', $Request->DomainModel->d_domain, $intType, 'Serialized'); + $intCount = 12; + $strStuatus = '连载中'; + + $arrRecommendSerializationNovel = $NovelModel->getCommonNovelOnCache($strKey, $intLifeTime, $intCount, $intType, $strStuatus); + + // 推荐等级为9的,完结的,男生频道/女生频道, 随机8个小说 + $strKey = sprintf('%s:PC:Novel:Channel:Hot:%s:%s', $Request->DomainModel->d_domain, $intType, 'Finish'); + $intCount = 8; + $strStuatus = '完结'; + + $arrRecommendEndNovel = $NovelModel->getCommonNovelOnCache($strKey, $intLifeTime, $intCount, $intType, $strStuatus); // 模拟数据-最近更新-随机50 - $arrNewsUpdateNovel = [ - ['id' => 1, 'name' => '小说1', 'author' => '作者1'], - ['id' => 2, 'name' => '小说2', 'author' => '作者2'], - ['id' => 3, 'name' => '小说3', 'author' => '作者3'], - ['id' => 4, 'name' => '小说3', 'author' => '作者3'], - ['id' => 5, 'name' => '小说3', 'author' => '作者3'], - ['id' => 6, 'name' => '小说3', 'author' => '作者3'], - ['id' => 7, 'name' => '小说3', 'author' => '作者3'], - ['id' => 8, 'name' => '小说3', 'author' => '作者3'], - ['id' => 9, 'name' => '小说3', 'author' => '作者3'], - ['id' => 10, 'name' => '小说3', 'author' => '作者3'], - ['id' => 1, 'name' => '小说1', 'author' => '作者1'], - ['id' => 2, 'name' => '小说2', 'author' => '作者2'], - ['id' => 3, 'name' => '小说3', 'author' => '作者3'], - ['id' => 4, 'name' => '小说3', 'author' => '作者3'], - ['id' => 5, 'name' => '小说3', 'author' => '作者3'], - ['id' => 6, 'name' => '小说3', 'author' => '作者3'], - ['id' => 7, 'name' => '小说3', 'author' => '作者3'], - ['id' => 8, 'name' => '小说3', 'author' => '作者3'], - ['id' => 9, 'name' => '小说3', 'author' => '作者3'], - ['id' => 10, 'name' => '小说3', 'author' => '作者3'], - ]; - + $strKey = sprintf('%s:PC:Novel:Channel:Latest:%s', $Request->DomainModel->d_domain, $intType); + $intCount = 20; + $arrNewsUpdateNovel = $NovelModel->getCommonNovelOnCache($strKey, $intLifeTime, $intCount, $intType, NULL, ['og_novel_update_time' => -1]); + View::assign([ - 'arrNewsUpdateNovel' => $arrNewsUpdateNovel, 'arrRecommendSerializationNovel' => $arrRecommendSerializationNovel, 'arrRecommendEndNovel' => $arrRecommendEndNovel, + 'arrNewsUpdateNovel' => $arrNewsUpdateNovel, 'arrAdBanner' => [], 'strPageCode' => $strNovelChannel ]); @@ -248,7 +238,7 @@ class Novel extends BaseController } // 分类 - public function getNovelCategory(Request $Request,$intCategoryId = null ,$intPage = 1) + public function getNovelCategory(Request $Request, $intCategoryId = null, $intPage = 1) { $boolIsMobile = $Request->param('boolIsMobile'); $strChannel = $Request->param('strChannel'); // 区分男生 / 女生频道 @@ -426,7 +416,7 @@ class Novel extends BaseController } // 小说章节-所有章节 - public function getNovelChapterAll(Request $Request,$intNovelId=null,$intPage=1,$strSort='asc') + public function getNovelChapterAll(Request $Request, $intNovelId = null, $intPage = 1, $strSort = 'asc') { $boolIsMobile = $Request->param('boolIsMobile'); // 模拟数据 diff --git a/code/app/home/view/kuangyu/Pc/Public/endNovelList.html b/code/app/home/view/kuangyu/Pc/Public/endNovelList.html index 314f087..45cd758 100644 --- a/code/app/home/view/kuangyu/Pc/Public/endNovelList.html +++ b/code/app/home/view/kuangyu/Pc/Public/endNovelList.html @@ -1,11 +1,11 @@
  • - + {$Novel->og_novel_book_name} + src="/static/img/default.jpg" data-src="{$Novel->n_cover_path ?? ''}" + alt="{$Novel->og_novel_book_name ?? ''}">
    -

    {$Novel->og_novel_book_name}

    - {$Novel->og_novel_author} +

    {$Novel->og_novel_book_name ?? ''}

    + {$Novel->og_novel_author ?? ''}
  • \ No newline at end of file diff --git a/code/app/home/view/kuangyu/Pc/Public/shukuNovelList.html b/code/app/home/view/kuangyu/Pc/Public/shukuNovelList.html index 1fce5c7..15446eb 100644 --- a/code/app/home/view/kuangyu/Pc/Public/shukuNovelList.html +++ b/code/app/home/view/kuangyu/Pc/Public/shukuNovelList.html @@ -1,5 +1,5 @@
  • - + {$Novel->og_novel_book_name ?? ''} diff --git a/code/app/home/view/kuangyu/Pc/getLibrary.html b/code/app/home/view/kuangyu/Pc/getLibrary.html index bc5e418..83abcdc 100644 --- a/code/app/home/view/kuangyu/Pc/getLibrary.html +++ b/code/app/home/view/kuangyu/Pc/getLibrary.html @@ -6,66 +6,31 @@ {block name="main"}
    - +
    所属频道
    是否完结 -
    - -
    - 更新时间 - -
    -
    - 排序方式 -
    @@ -75,26 +40,26 @@
      - {foreach $arrNovel as $key=>$Novel} + {volist name="arrNovel" id="Novel" key="key"} {include file="Pc/Public/shuKuNovelList" /} - {/foreach} + {/volist}
    diff --git a/code/app/home/view/kuangyu/Pc/getNovelChannel.html b/code/app/home/view/kuangyu/Pc/getNovelChannel.html index bd71b2a..51f886b 100644 --- a/code/app/home/view/kuangyu/Pc/getNovelChannel.html +++ b/code/app/home/view/kuangyu/Pc/getNovelChannel.html @@ -3,7 +3,13 @@ {block name="title"}{/block} {block name="head-css"} - + +{eq name="strPageCode" value="boys"} + +{else} + +{/eq} + {/block} {block name="head-js"}{/block} @@ -20,16 +26,17 @@
      - {foreach $arrRecommendSerializationNovel as $key=>$Novel} + {volist name="arrRecommendSerializationNovel" id="Novel" key="key"} {include file="Pc/Public/endNovelList" /} - {/foreach} + {/volist}
    - {foreach $arrAdBanner as $key=>$Novel} + {volist name="arrAdBanner" id="Ad" key="key"} {include file="Pc/Public/adBanner" /} - {/foreach} + {/volist} +
    @@ -40,16 +47,16 @@

    完本推荐

      - {foreach $arrRecommendEndNovel as $key=>$Novel} + {volist name="arrRecommendEndNovel" id="Novel" key="key"} {include file="Pc/Public/endNovelList" /} - {/foreach} + {/volist}
    - {foreach $arrAdBanner as $key=>$Novel} + {volist name="arrAdBanner" id="Ad" key="key"} {include file="Pc/Public/adBanner" /} - {/foreach} + {/volist}
    @@ -70,11 +77,9 @@
  • 更新时间
  • - {foreach $arrNewsUpdateNovel as $key=>$Novel} - {if $key >= 1} + {volist name="arrNewsUpdateNovel" id="Novel" key="key"} {include file="Pc/Public/indexNewsUpdateList" /} - {/if} - {/foreach} + {/volist} diff --git a/code/app/home/view/kuangyu/baseH5.html b/code/app/home/view/kuangyu/baseH5.html index 8239a4c..c4a4fbd 100644 --- a/code/app/home/view/kuangyu/baseH5.html +++ b/code/app/home/view/kuangyu/baseH5.html @@ -65,13 +65,13 @@ 女生 - + 书库 - + 排行 - + 文章 diff --git a/code/app/home/view/kuangyu/basePc.html b/code/app/home/view/kuangyu/basePc.html index 5c34d95..3470c9a 100644 --- a/code/app/home/view/kuangyu/basePc.html +++ b/code/app/home/view/kuangyu/basePc.html @@ -24,7 +24,7 @@
    diff --git a/code/app/home/view/kuangyu/推广SEO过程设计记录/index.md b/code/app/home/view/kuangyu/推广SEO过程设计记录/index.md index d4a7553..8350511 100644 --- a/code/app/home/view/kuangyu/推广SEO过程设计记录/index.md +++ b/code/app/home/view/kuangyu/推广SEO过程设计记录/index.md @@ -1,6 +1,12 @@ # 狂雨小说模板 源地址: test.nove66.net , cms 模板部署在虚拟机 +# 是否带.html 后缀 + 根据ai 分析,不带 html 版本更具好, 第一版本不带 html + +# pc 和 h5端是否需要2个url? + 根据ai 分析,2个url 使用js 区分跳转 ,不是最优方案,h5和pc 使用一个url 才是最优方案 + # 数据渲染 PC 公共数据 @@ -32,8 +38,13 @@ pc-首页 - # 第二版本 1.增加广广告配置, 2.用户访问第一视图区域 展示数据以吸引用户留存为主要 - 3.html 标签优化 \ No newline at end of file + 3.html 标签优化 + 4.干扰码: + 4.1方案1: 每个a标签前面 生成一个 干扰码 + 4.2方案2: + 后面 随机15-30个标签 + 前面面 随机15-30个标签 + body 中间 选择 5-10行 ,a 标签前面 生成一个干扰码 \ No newline at end of file diff --git a/code/app/home/view/kuangyu/推广SEO过程设计记录/书库页面设计.md b/code/app/home/view/kuangyu/推广SEO过程设计记录/书库页面设计.md new file mode 100644 index 0000000..29d7d15 --- /dev/null +++ b/code/app/home/view/kuangyu/推广SEO过程设计记录/书库页面设计.md @@ -0,0 +1,9 @@ +# 书库页面设计 +`` + 推荐URL:/pc/shuku/nansheng/dushixiuxian/lianzai/1 + 全部URL:/pc/shuku/all/all/all/1 + 理由: + all 提供语义支持,SEO友好。 + 拼音关键词(如 nansheng、lianzai)直接优化中文搜索。 + 多参数结构支持组合筛选,权重集中。 +`` \ No newline at end of file diff --git a/code/app/model/NovelModel.php b/code/app/model/NovelModel.php index e0f060d..95d48df 100644 --- a/code/app/model/NovelModel.php +++ b/code/app/model/NovelModel.php @@ -53,6 +53,82 @@ class NovelModel extends MongoModel return true; } + /** + * Undocumented function + * + * @param string $strKey + * @param int $intLifeTime + * @param integer $intCount + * @param integer $intType + * @param string $strStatus + * @param array $arrSort + * @return array + */ + public function getCommonNovelOnCache( + string $strKey, + int $intLifeTime = 24 * 3600, + int $intCount = 10, + int $intType = 0, + $strStatus = NULL, + array $arrSort = ['n_level' => -1] + ): array { + try { + + $arrResult = Cache::get($strKey); + + // if (empty($arrResult)) { + if (true) { + $arrFilter = []; + + switch ($intType) { + case 1: + $arrCategory = array_values(CategoryModel::getManCategory()); + $arrFilter['og_novel_category'] = ['$in' => $arrCategory]; + break; + case 2: + $arrCategory = array_values(CategoryModel::getWomenCategory()); + $arrFilter['og_novel_category'] = ['$in' => $arrCategory]; + break; + } + + if ($strStatus !== NULL) { + $arrFilter['og_novel_status'] = $strStatus; + } + + $arrOptions = [ + 'sort' => $arrSort, + 'limit' => $intCount * 3, + 'projection' => [ + 'n_id' => 1, + 'og_novel_book_name' => 1, + 'og_novel_pin_yin' => 1, + 'n_cover_path' => 1, + 'og_novel_author' => 1, + 'og_novel_category' => 1, + 'og_description' => 1, + 'og_novel_latest_chapter_name' => 1, + 'og_novel_update_time' => 1, + ], + ]; + + $Cursor = $this->getCol()->find($arrFilter, $arrOptions); + $arrResult = iterator_to_array($Cursor); + + shuffle($arrResult); + + $arrResult = array_slice($arrResult, 0, $intCount); + + if (!empty($arrResult)) { + Cache::set($strKey, $arrResult, $intLifeTime); + } + } + + return $arrResult; + } catch (\Exception $e) { + return []; + } + } + /** * Undocumented function @@ -63,7 +139,7 @@ class NovelModel extends MongoModel * @param integer $intLevel * @return array */ - public function getHighLevelNovelOnCache(string $strSign, int $intCount = 10, int $intType = 0): array + public function getHighLevelNovelOnCache(string $strSign, int $intCount = 10, int $intType = 0, $strStatus = NULL): array { try { $strKey = sprintf('%s:PC:HOME:FIRST', $strSign); @@ -74,18 +150,21 @@ class NovelModel extends MongoModel // if (empty($arrResult)) { if (true) { - if ($intType == 1) { - $arrCategory = array_values(CategoryModel::getManCategory()); - $arrFilter = [ - 'og_novel_category' => ['$in' => $arrCategory] - ]; - } elseif ($intType == 2) { - $arrCategory = array_values(CategoryModel::getWomenCategory()); - $arrFilter = [ - 'og_novel_category' => ['$in' => $arrCategory] - ]; - } else { - $arrFilter = []; + $arrFilter = []; + + switch ($intType) { + case 1: + $arrCategory = array_values(CategoryModel::getManCategory()); + $arrFilter['og_novel_category'] = ['$in' => $arrCategory]; + break; + case 2: + $arrCategory = array_values(CategoryModel::getWomenCategory()); + $arrFilter['og_novel_category'] = ['$in' => $arrCategory]; + break; + } + + if ($strStatus !== NULL) { + $arrFilter['og_novel_status'] = $strStatus; } $arrOptions = [ diff --git a/code/app/task/crawler/zw630/page/NovelPage.php b/code/app/task/crawler/zw630/page/NovelPage.php index 7b44797..d98d3ab 100644 --- a/code/app/task/crawler/zw630/page/NovelPage.php +++ b/code/app/task/crawler/zw630/page/NovelPage.php @@ -159,7 +159,7 @@ class NovelPage extends BasePage } if (!isset($this->arrNovelInfo['n_cover_path']) || empty($this->arrNovelInfo['n_cover_path'])) { - $this->arrNovelInfo['n_cover_path'] = 'img/' . date('Y/m/d', time() - 24 * 3600 * 14) . '/' . $this->arrNovelInfo['n_id'] . '.jpg'; + $this->arrNovelInfo['n_cover_path'] = '/img/' . date('Y/m/d', time() - 24 * 3600 * 14) . '/' . $this->arrNovelInfo['n_id'] . '.jpg'; } $this->arrNovelInfo['updated_at'] = new \MongoDB\BSON\UTCDateTime(); diff --git a/doc/TemplateTag.md b/doc/TemplateTag.md index 09d8320..4aab6f7 100644 --- a/doc/TemplateTag.md +++ b/doc/TemplateTag.md @@ -19,7 +19,7 @@ # 转码 {site:wz wz="保存永久访问二维码" /} -# 干扰吗 +# 干扰码 {site:grm domain="Request->DomainModel->d_domain" code="kuangyu-pc-index" line="50" diff="0"/}