diff --git a/code/app/admin/config/router.php b/code/app/admin/config/router.php index b024377..a5e92d4 100644 --- a/code/app/admin/config/router.php +++ b/code/app/admin/config/router.php @@ -4,6 +4,7 @@ declare(strict_types=1); use app\admin\controller\Domain; use app\admin\controller\Novel; +use app\admin\controller\Site; use app\admin\middleware\AdminAuth; use think\facade\Route; @@ -39,9 +40,15 @@ Route::group("/novel", function () { # 站点 Route::group("/site", function () { - Route::get("/domain/list", [Domain::class, "getDomainList"])->name("Domain@getDomainList"); - Route::post("/domain/upload", [Domain::class, "uploadDomain"])->name("Domain@uploadDomain"); + # 域名管理 + Route::get("/domain/list", [Site::class, "getDomainList"])->name("Domain@getDomainList"); + Route::post("/domain/upload", [Site::class, "uploadDomain"])->name("Domain@uploadDomain"); + Route::post("/domain/save", [Site::class, "saveDomain"])->name("Domain@saveDomain"); - Route::get("/tkdarg/list", [Domain::class, "getTKDArgList"])->name("Domain@getDomainList"); + # TKD 参数模板 + Route::get("/tkdarg/list", [Site::class, "getTKDArgList"])->name("Domain@getTKDArgList"); + + # 视图模板 + Route::get("/template/list", [Site::class, "getTemplateList"])->name("Domain@getTKDArgList"); })->middleware(AdminAuth::class); diff --git a/code/app/admin/controller/Domain.php b/code/app/admin/controller/Site.php similarity index 53% rename from code/app/admin/controller/Domain.php rename to code/app/admin/controller/Site.php index 1434c27..76ee63f 100644 --- a/code/app/admin/controller/Domain.php +++ b/code/app/admin/controller/Site.php @@ -8,11 +8,13 @@ use app\admin\BaseController; use app\model\AdminUserModel; use app\model\ConverterMovel; use app\model\DomainModel; +use app\model\TemplatesModel; use app\Request; use PhpOffice\PhpSpreadsheet\IOFactory; use think\Response; -class Domain extends BaseController + +class Site extends BaseController { /** @@ -61,7 +63,7 @@ class Domain extends BaseController $arrDomain = [ 'd_domain' => $arrRows[0], 't_id' => $arrRows[1], - 'd_title' => $arrRows[2], + 'd_name' => $arrRows[2], 'd_keywords' => $arrRows[3], 'd_description' => $arrRows[4], 'd_statis' => $arrRows[5], @@ -69,7 +71,13 @@ class Domain extends BaseController 'd_text_log' => $arrRows[7], 'd_img_log' => $arrRows[8], ]; + + $TCfgTemplate = TemplatesModel::where('t_id', $arrDomain['t_id'])->find()->t_cfg_template; + + $arrDomain['t_cfg'] = json_encode($TCfgTemplate, JSON_UNESCAPED_UNICODE); + $DomainModel = DomainModel::where('d_domain', $arrDomain['d_domain'])->findOrEmpty(); + $DomainModel->fill($arrDomain); $DomainModel->save(); } @@ -129,4 +137,99 @@ class Domain extends BaseController return $this->success($arrResult); } + + + /** + * 添加|修改 域名 + * + * @param Request $Request + * @param AdminUserModel|null $AdminUserModel + * @return Response + */ + public function saveDomain(Request $Request, ?AdminUserModel $AdminUserModel) + { + $arrData = [ + "d_id" => $Request->post('d_id'), + "d_domain" => $Request->post('d_domain'), + "t_id" => $Request->post('t_id'), + "d_name" => $Request->post('d_name'), + "d_keywords" => $Request->post('d_keywords'), + "d_description" => $Request->post('d_description'), + "d_statis" => $Request->post('d_statis'), + "d_logo_type" => $Request->post('d_logo_type'), + "d_text_log" => $Request->post('d_text_log'), + "d_img_log" => $Request->post('d_img_log'), + "d_content_encode" => $Request->post('d_content_encode'), + "t_cfg" => $Request->post('t_cfg'), + ]; + + $arrRule = [ + // 'd_id' => 'require|number', + 'd_domain' => 'require', + 'd_logo_type' => 'require|number', + 'd_content_encode' => 'require|number', + 't_cfg' => 'require', + ]; + + $this->validate($arrData, $arrRule); + + if ($arrData['d_id']) { + $DomainModel = DomainModel::where('d_id', $arrData['d_id'])->findOrEmpty(); + } else { + $DomainModel = new DomainModel; + } + + $DomainModel->fill($arrData); + + $DomainModel->save(); + return $this->success(); + } + + /** + * 列表 + * + * @param Request $Request + * @param AdminUserModel|null $AdminUserModel + * @return Response + */ + public function getTemplateList(Request $Request, ?AdminUserModel $AdminUserModel) + { + $arrData = [ + "page" => $Request->get('page', 1), + "limit" => $Request->get('limit', 10), + "key" => $Request->get('key'), + ]; + + $arrRule = [ + 'page' => 'require|number', + 'limit' => 'require|number', + ]; + + $this->validate($arrData, $arrRule); + + $TemplatesModel = TemplatesModel::alias('t'); + + if (!empty($arrData['key'])) { + $strKey = $arrData['key']; + $TemplatesModel->where(function ($TemplatesModel) use ($strKey) { + $TemplatesModel->whereOr([ + ['t.t_code', 'like', "%" . $strKey . "%"], + ]); + }); + } + + $Paginate = $TemplatesModel->paginate([ + 'list_rows' => $arrData['limit'], + 'page' => $arrData['page'], + ]); + + $arrResult = [ + 'items' => $Paginate->items(), + 'total' => $Paginate->total(), + 'current_page' => $Paginate->currentPage(), + 'total_pages' => $Paginate->lastPage(), + ]; + + return $this->success($arrResult); + } } diff --git a/code/app/common.php b/code/app/common.php index 10da1e7..1556428 100644 --- a/code/app/common.php +++ b/code/app/common.php @@ -814,4 +814,17 @@ namespace { return $strPinYin; } + + + /** + * Undocumented function + * + * @param object $Obj + * @param string $strAction + * @return string + */ + function getFomartSubjectKey(string $strAction): string + { + return strtoupper(str_replace('::', '@', ltrim(strrchr($strAction, "\\"), "\\"))); + } } diff --git a/code/app/home/BaseController.php b/code/app/home/BaseController.php index f6122cd..176897f 100644 --- a/code/app/home/BaseController.php +++ b/code/app/home/BaseController.php @@ -75,7 +75,7 @@ abstract class BaseController private function initSiteTKD() { ConverterMovel::setVal([ - 'strSiteTitle' => $this->request->DomainModel->d_title, + 'strSiteName' => $this->request->DomainModel->d_name, 'strSiteKeywords' => $this->request->DomainModel->d_keywords, 'strSiteDescription' => $this->request->DomainModel->d_description, ]); diff --git a/code/app/home/config/router.php b/code/app/home/config/router.php index 08d3f6d..074e91c 100644 --- a/code/app/home/config/router.php +++ b/code/app/home/config/router.php @@ -14,16 +14,16 @@ use think\facade\Route; /** * 首页 */ -Route::get("/", [Index::class,'index'])->ext('html')->append(['boolIsMobile' => true]); -Route::get("/pc/", [Index::class,'getPcIndex'])->append(['boolIsMobile' => false]); +Route::get("/", [Index::class, 'index'])->ext('html')->append(['boolIsMobile' => true]); +Route::get("/pc/", [Index::class, 'getPcIndex'])->append(['boolIsMobile' => false]); // 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('/paihang/all', [Novel::class,'getNovelRank'])->append(['boolIsMobile' => true]); -Route::get("/pc/paihang/all", [Novel::class,'getNovelRank'])->append(['boolIsMobile' => false]); +Route::get('/paihang/all', [Novel::class, 'getNovelRank'])->append(['boolIsMobile' => true]); +Route::get("/pc/paihang/all", [Novel::class, 'getNovelRank'])->append(['boolIsMobile' => false]); /** * 男生/女生 - grok 推荐最优方案 @@ -35,25 +35,25 @@ Route::get('/pc/nansheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append( 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/:intGender-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary']) + * 书库 - grok 推荐最优方案 + * /shuku/strGender/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/:strGender/:strCategory/:strStatus/page:intPage', [Novel::class, 'getLibrary']) ->pattern([ - 'intGender' => '\d{1}', - 'strCategory' => '[\w]*', - 'strStatus' => '[\w]*', + 'strGender' => 'nansheng-xiaoshuo|nvsheng-xiaoshuo|all', + 'strCategory' => '[a-z\-]+', + 'strStatus' => 'all|lianzai|wanjie', 'intPage' => '\d+' ]) ->append(['boolIsMobile' => true]); -Route::get('/pc/shuku/:intGender-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary']) +Route::get('/pc/shuku/:strGender/:strCategory/:strStatus/page:intPage', [Novel::class, 'getLibrary']) ->pattern([ - 'intGender' => '\d{1}', - 'strCategory' => '[\w]*', - 'strStatus' => '[\w]*', + 'strGender' => 'nansheng-xiaoshuo|nvsheng-xiaoshuo|all', + 'strCategory' => '[a-z\-]+', + 'strStatus' => 'all|lianzai|wanjie', 'intPage' => '\d+' ]) ->append(['boolIsMobile' => false]); @@ -66,18 +66,18 @@ Route::get('/pc/shuku/:intGender-:strCategory-:strStatus-:intPage', [Novel::clas */ Route::get('/xiaoshuo/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]', [Novel::class, 'getNovelChapter']) ->append(['boolIsMobile' => true, 'intUriType' => 1]) - ->pattern(['intNovelId' => '\d+','name' => '[\w-]+','intChapterId' => '\d+','intChapterPage' => '\d+']); + ->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'intChapterId' => '\d+', 'intChapterPage' => '\d+']); Route::get('/pc/xiaoshuo/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]', [Novel::class, 'getNovelChapter']) ->append(['boolIsMobile' => false, 'intUriType' => 1]) - ->pattern(['intNovelId' => '\d+','name' => '[\w-]+','intChapterSort' => '\d+','intChapterPage' => '\d+']); + ->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'intChapterSort' => '\d+', 'intChapterPage' => '\d+']); /** * 最新章节-特殊页面处理 -*/ + */ Route::get('/pc/books/:name-:n_id/chapter/latest', [Novel::class, 'getNovelNewsChapter']) ->append(['boolIsMobile' => false, 'intUriType' => 1]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); /** @@ -86,11 +86,11 @@ Route::get('/pc/books/:name-:n_id/chapter/latest', [Novel::class, 'getNovelNewsC */ Route::get('/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]', [Novel::class, 'getNovelChapterAll']) ->append(['boolIsMobile' => true, 'intUriType' => 1]) - ->pattern(['intNovelId' => '\d+','name' => '[\w-]+','strOrder' => 'zheng|dao','intPage' => '\d+']); + ->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'strOrder' => 'zheng|dao', 'intPage' => '\d+']); Route::get('/pc/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]', [Novel::class, 'getNovelChapterAll']) ->append(['boolIsMobile' => false, 'intUriType' => 1]) - ->pattern(['intNovelId' => '\d+','name' => '[\w-]+','strOrder' => 'zheng|dao','intPage' => '\d+']); + ->pattern(['intNovelId' => '\d+', 'name' => '[\w-]+', 'strOrder' => 'zheng|dao', 'intPage' => '\d+']); /** * 小说详情 @@ -103,27 +103,28 @@ Route::get('/pc/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]', [Novel::c */ Route::get('/pc/book/:name-:n_id', [Novel::class, 'getNovelInfo']) ->append(['boolIsMobile' => false, 'intUriType' => 1]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); Route::get('/pc/novel/:name-:n_id', [Novel::class, 'getNovelInfo']) ->append(['boolIsMobile' => false, 'intUriType' => 2]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); Route::get('/pc/xiaoshuo/:name-:n_id', [Novel::class, 'getNovelInfo']) ->append(['boolIsMobile' => false, 'intUriType' => 2]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); Route::get('/pc/book-:name-:n_id', [Novel::class, 'getNovelInfo']) ->append(['boolIsMobile' => false, 'intUriType' => 3]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); Route::get('/pc/novel-:name-:n_id', [Novel::class, 'getNovelInfo']) ->append(['boolIsMobile' => false, 'intUriType' => 3]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); Route::get('/pc/xiaoshuo-:name-:n_id', [Novel::class, 'getNovelInfo']) ->append(['boolIsMobile' => false, 'intUriType' => 3]) - ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); + ->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]); + //h5 Route::get('/book/:name-:n_id', [Novel::class, 'getNovelInfo']) @@ -151,33 +152,33 @@ Route::get('/xiaoshuo-:name-:n_id', [Novel::class, 'getNovelInfo']) ->pattern(['n_id' => '\d+','name' => '[\w-]+',]); // 搜索小说 -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('/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::class,'Index'])->append(['boolIsMobile' => true]); -Route::get('/pc/user', [User::class,'Index'])->append(['boolIsMobile' => false]); +Route::get('/user', [User::class, 'Index'])->append(['boolIsMobile' => true]); +Route::get('/pc/user', [User::class, 'Index'])->append(['boolIsMobile' => false]); // 书架 -Route::get('/bookshelf', [User::class,'getBookShelf'])->append(['boolIsMobile' => true]); -Route::get('/pc/bookshelf', [User::class,'getBookShelf'])->append(['boolIsMobile' => false]); +Route::get('/bookshelf', [User::class, 'getBookShelf'])->append(['boolIsMobile' => true]); +Route::get('/pc/bookshelf', [User::class, 'getBookShelf'])->append(['boolIsMobile' => false]); // 历史记录 -Route::get('/history', [User::class,'getHistory'])->append(['boolIsMobile' => true]); -Route::get('/pc/history', [User::class,'getHistory'])->append(['boolIsMobile' => false]); +Route::get('/history', [User::class, 'getHistory'])->append(['boolIsMobile' => true]); +Route::get('/pc/history', [User::class, 'getHistory'])->append(['boolIsMobile' => false]); // 文章 列表 -Route::get('/article/list-[:intCategoryId]-[:intPage]', [Novel::class,'getArticleList'])->append(['boolIsMobile' => true]); -Route::get('/pc/article/list-[:intCategoryId]-[:intPage]', [Novel::class,'getArticleList'])->append(['boolIsMobile' => false]); -Route::get('/article/list', [Novel::class,'getArticleList'])->append(['boolIsMobile' => true]); -Route::get('/pc/article/list', [Novel::class,'getArticleList'])->append(['boolIsMobile' => false]); +Route::get('/article/list-[:intCategoryId]-[:intPage]', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => true]); +Route::get('/pc/article/list-[:intCategoryId]-[:intPage]', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => false]); +Route::get('/article/list', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => true]); +Route::get('/pc/article/list', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => false]); // 文章 详情 -Route::get('/article/info-:intArticleId', [Novel::class,'getArticleInfo'])->append(['boolIsMobile' => true]); -Route::get('/pc/article/info-:intArticleId', [Novel::class,'getArticleInfo'])->append(['boolIsMobile' => false]); +Route::get('/article/info-:intArticleId', [Novel::class, 'getArticleInfo'])->append(['boolIsMobile' => true]); +Route::get('/pc/article/info-:intArticleId', [Novel::class, 'getArticleInfo'])->append(['boolIsMobile' => false]); diff --git a/code/app/home/controller/Index.php b/code/app/home/controller/Index.php index 4d5d56e..7ea7299 100644 --- a/code/app/home/controller/Index.php +++ b/code/app/home/controller/Index.php @@ -6,6 +6,7 @@ namespace app\home\controller; use app\home\BaseController; use app\model\ConverterMovel; +use app\model\DomainModel; use app\model\NovelModel; use storage\StorageCore; use think\facade\View; @@ -161,6 +162,11 @@ class Index extends BaseController // 最近更新-随机50 $arrNewsUpdateNovel = $NovelModel->getSexNovelOnCache($Request->DomainModel->d_domain, 50); + $strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__)); + + $strTitle = ConverterMovel::convert($strTitle); + + View::assign([ 'arrNewsUpdateNovel' => $arrNewsUpdateNovel, 'arrRecommendSerializationNovel' => $arrRecommendSerializationNovel, @@ -174,17 +180,11 @@ class Index extends BaseController 'arrGirlMoonRankNovel' => $arrGirlMoonRankNovel, 'arrBGirlTotalRankNovel' => $arrBGirlTotalRankNovel, 'arrAdBanner' => [], - 'strPageCode' => 'home' + 'strPageCode' => 'home', + 'strTitle' => $strTitle, ]); - $strTitle = '最新小说网-{strSiteTitle}-{strSiteKeywords}'; - - $strTitle = ConverterMovel::convert($strTitle); - - echo $strTitle;exit; - - if ($boolIsMobile) { return View::fetch(); } else { diff --git a/code/app/home/controller/Novel.php b/code/app/home/controller/Novel.php index 6d5cf4a..aab4673 100644 --- a/code/app/home/controller/Novel.php +++ b/code/app/home/controller/Novel.php @@ -5,11 +5,13 @@ declare(strict_types=1); namespace app\home\controller; use app\home\BaseController; +use app\model\CategoryModel; use app\model\ConverterMovel; use app\model\NovelModel; use storage\StorageCore; use think\facade\View; use app\Request; +use template\page\CusteomPage02; class Novel extends BaseController { @@ -131,53 +133,90 @@ class Novel extends BaseController * @param integer $intPage 分页 * @return void */ - public function getLibrary(Request $Request) //, $strNovelChannel = 'all', $strCategory = 'all', $strStatus = 'all', $intPage = 1) + public function getLibrary(Request $Request, $strGender = 'all', $strCategory = 'all', $strStatus = 'all', $intPage = 1) { $boolIsMobile = $Request->param('boolIsMobile'); - $intGender = (int)$Request->param('intGender',0); - $strCategory = (string)$Request->param('strCategory'); - $strStatus = (string)$Request->param('strStatus'); + // 性别 + + $arrSex = [ + 'all' => 0, + 'nansheng-xiaoshuo' => 1, + 'nvsheng-xiaoshuo' => 1, + ]; + + if (!key_exists($strGender, $arrSex)) { + return response('Bad Request', 400); + } + + $intGender = $arrSex[$strGender]; + + // 分类 + // $strCategory = $Request->param('strCategory'); + + if ($strCategory == 'all') { + $strSearchCategory = NULL; + } else if (!in_array($strGender, CategoryModel::$arrCategoryPinYin)) { + return response('Bad Request', 400); + } else { + $strCategoryKey = array_search($strGender, CategoryModel::$arrCategoryPinYin); + $strSearchCategory = CategoryModel::$arrCategory[$strCategoryKey]; + } + + // 小说状态 + // $strStatus = $Request->param('strStatus'); + $arrStatus = [ + 'all' => NULL, + 'lianzai' => '连载中', + 'wanjie' => '已完结', + ]; + + if (!key_exists($strStatus, $arrStatus)) { + return response('Bad Request', 400); + } + + $strSearchStatus = $arrStatus[$strStatus]; + + $intPage = (int)$Request->param('intPage'); + if ($intPage <= 1) { + $intPage = 1; + } $intLimit = 20; $intLifeTime = 24 * 3600; + $strKey = sprintf("Novel:Library:%s:%s:%s:%s", $intGender, $strSearchCategory, $strSearchStatus, $intPage); + + $NovelModel = new NovelModel; + $arrPage = $NovelModel->getCommonNovelPageOnCache($strKey, $intPage, $intLimit, $intLifeTime, $intGender, $strSearchStatus); - $strKey = sprintf("Novel:Library:%s:%s:%s:%s", $intGender, $strCategory, $strStatus, $intPage); - // var_dump($intType);exit; - $arrPage = $NovelModel->getCommonNovelPageOnCache($strKey, $intPage, $intLimit, $intLifeTime, $intGender, $strStatus); + $strTemplate = NULL; + $intButtomNum = 5; + if ($boolIsMobile == false) { + $intButtomNum = 10; + $strTemplate = 'pc/getLibrary'; + } - // echo '
';
- // print_r($arrPage);
- // exit;
-
- // 模拟数据
- $arrNovel = [
- ['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'],
- ];
+ $strBaseUrl = sprintf('/pc/shuku/%s/%s/%s/page{page}', $strGender, $strCategory, $strStatus);
+ $arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtomNum);
View::assign([
- 'arrNovel' => $arrNovel,
+ 'arrNovel' => $arrPage['data'],
'strPageCode' => 'library',
- 'intGender' => $intGender,
+ 'strGender' => $strGender,
'strCategory' => $strCategory,
'strStatus' => $strStatus,
'intPage' => $intPage,
+ 'intTotalPage' => $arrPage['pages'],
+ 'arrCategory' => array_combine(array_values(CategoryModel::$arrCategoryPinYin), array_values(CategoryModel::$arrCategory)),
+ 'arrPaginator' => $arrPaginator,
]);
- if ($boolIsMobile) {
- return View::fetch();
- } else {
- return View::fetch('pc/getLibrary');
- }
+
+
+
+ return View::fetch($strTemplate);
}
// 书架
@@ -338,7 +377,7 @@ class Novel extends BaseController
$strNovel = '斗罗大陆';
- ConverterMovel::setVal("strNovelName",$strNovel);
+ ConverterMovel::setVal("strNovelName", $strNovel);
// 模拟数据-随机推荐数据10条
@@ -359,17 +398,24 @@ class Novel extends BaseController
// 最新要点->取新意章节, 随机提取一部分内容 大概150字数
+ // {strNovelName}最新章节_{strNovelName}{strNovelAuthor}_{strNovelName}全文阅读_{strSiteName}
+ // {strNovelName}免费全文阅读-{strNovelName}{strNovelAuthor}-{strSiteName}
-
// $strTitle = '小说详情-{strNovelName}-xxxxx';
// $strTitle = ConverterMovel::convert($strTitle);
// echo $strTitle;exit;
+ $strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__));
+ // echo $strTitle ;exit;
+ $strTitle = ConverterMovel::convert($strTitle);
+
+
View::assign([
'arrRecommendNovel' => $arrRecommendNovel,
- 'strPageCode' => 'boy'
+ 'strPageCode' => 'boy',
+ 'strTitle' => $strTitle,
]);
if ($boolIsMobile) {
return View::fetch();
diff --git a/code/app/home/view/kuangyu/Pc/getLibrary.html b/code/app/home/view/kuangyu/Pc/getLibrary.html
index 037a0c9..e1f05ba 100644
--- a/code/app/home/view/kuangyu/Pc/getLibrary.html
+++ b/code/app/home/view/kuangyu/Pc/getLibrary.html
@@ -32,25 +32,28 @@
@@ -67,19 +70,28 @@
- - «
+
+
+ {volist name="arrPaginator" id="vo" key="k" }
+ - {$vo.label}
+ {/volist}
+
+
+
+
+
diff --git a/code/app/home/view/kuangyu/basePc.html b/code/app/home/view/kuangyu/basePc.html
index 995f960..3ae8206 100644
--- a/code/app/home/view/kuangyu/basePc.html
+++ b/code/app/home/view/kuangyu/basePc.html
@@ -6,7 +6,7 @@
- 狂雨小说
+ {$strTitle??''}
diff --git a/code/app/model/CategoryModel.php b/code/app/model/CategoryModel.php
index 8ef6dec..af7dd11 100644
--- a/code/app/model/CategoryModel.php
+++ b/code/app/model/CategoryModel.php
@@ -28,6 +28,18 @@ class CategoryModel extends MongoModel
9 => '其他小说',
];
+ static $arrCategoryPinYin = [
+ 1 => 'xuanhuan-xiuzhen', // 玄幻-修真
+ 2 => 'junshi-xiaoshuo', // 军史-小说
+ 3 => 'wangyou-xiaoshuo', // 网游-小说
+ 4 => 'kehuan-xiaoshuo', // 科幻-小说
+ 5 => 'zhongsheng-chuanyue', // 重生-穿越
+ 6 => 'dushi-xiaoshuo', // 都市-小说
+ 7 => 'lingyi-xiaoshuo', // 灵异-小说
+ 8 => 'yanqing-xiaoshuo', // 言情-小说
+ 9 => 'qita-xiaoshuo', // 其他-小说
+ ];
+
static $arrMan = [
1 => '玄幻修真',
2 => '军史小说',
@@ -44,17 +56,17 @@ class CategoryModel extends MongoModel
];
- static public function getCategory():array
+ static public function getCategory(): array
{
return self::$arrCategory;
}
- static public function getManCategory():array
+ static public function getManCategory(): array
{
return self::$arrMan;
}
- static public function getWomenCategory():array
+ static public function getWomenCategory(): array
{
return self::$arrWomen;
}
diff --git a/code/app/model/ConverterMovel.php b/code/app/model/ConverterMovel.php
index 33f7902..6118500 100644
--- a/code/app/model/ConverterMovel.php
+++ b/code/app/model/ConverterMovel.php
@@ -14,21 +14,31 @@ use think\Model;
class ConverterMovel
{
static private $arrMap = [
- '{strSiteTitle}' => '',
+ '{strSiteName}' => '',
+ '{strSiteDomain}' => '',
'{strSiteKeywords}' => '',
'{strSiteDescription}' => '',
'{strNovelName}' => '',
'{strNovelChapterName}' => '',
+ '{strNovelChapterSort}' => '',
'{strNovelCategoryName}' => '',
+ '{intPage}' => '',
+ '{strNovelAuthor}' => '',
+ '{strNovelDescription}' => '',
];
static public $arrDescription = [
'{strSiteTitle}' => '这个是网站标题',
+ '{strSiteDomain}' => '这个是站点域名',
'{strSiteKeywords}' => '这个是网站关键字',
'{strSiteDescription}' => '这个是网站描述',
- '{strNovelName}' => '当前页面小说标题',
+ '{strNovelName}' => '这个是当前页面小说标题',
'{strNovelChapterName}' => '当前页面小说章节名字',
+ '{strNovelChapterSort}' => '当前页面小说章节排序号',
'{strNovelCategoryName}' => '当前页面小说分类名字',
+ '{intPage}' => '当前页面分页页码',
+ '{strNovelAuthor}' => '小说作者',
+ '{strNovelDescription}' => '小说简介',
];
static private function getKey($strKey): string
diff --git a/code/app/model/DomainModel.php b/code/app/model/DomainModel.php
index 916cf2a..09f5f3f 100644
--- a/code/app/model/DomainModel.php
+++ b/code/app/model/DomainModel.php
@@ -15,6 +15,8 @@ class DomainModel extends BaseModel
protected $name = 'domain';
protected $pk = 'd_id';
+ protected $json = ['t_cfg'];
+
static public function getDomainByCache($strDomain)
{
@@ -47,4 +49,54 @@ class DomainModel extends BaseModel
return $strWords;
}
+
+
+ /**
+ * Undocumented function
+ *
+ * @param string $strKey
+ * @return void
+ */
+ public function getFomartSubject($strKey) //, $intNum = 1, $boolRand = false)
+ {
+ // echo $strKey;
+ // //exit;
+ // echo '';
+ // var_dump($this->t_cfg);
+ // exit;
+ $intSfgId = $this->t_cfg->{$strKey}['sfg_id'];
+ // $SubjectFomartCol = SubjectFomartModel::where('sfg_id', $intSfgId)->select();
+
+ $SubjectFomartModel = SubjectFomartModel::where('sfg_id', $intSfgId)->select()->first();
+ // var_dump($SubjectFomartModel->toArray());
+ // exit;
+
+ return $SubjectFomartModel->sf_val;
+ }
+
+
+ /**
+ * Undocumented function
+ *
+ * @param array $arrArgs
+ * @return void
+ */
+ static public function getPageUrl($strKey, array $arrArgs): string
+ {
+ $Request = request();
+ // $strKey = $Request->controller(false, true) . '@' .
+ // $Request->action(true) . '@URL';
+ // $strKey = strtoupper($strKey);
+
+ $strSfVal = $Request->DomainModel->getFomartSubject($strKey);
+
+ $arrKeys = [];
+ $arrVals = [];
+ foreach ($arrArgs as $strKey => $strVal) {
+ $arrKeys[] = '{' . $strKey . '}';
+ $arrVals[] = $strVal;
+ }
+
+ return str_replace($arrKeys, $arrVals, $strSfVal);
+ }
}
diff --git a/code/app/model/NovelModel.php b/code/app/model/NovelModel.php
index 2c4ec7e..49334fb 100644
--- a/code/app/model/NovelModel.php
+++ b/code/app/model/NovelModel.php
@@ -99,8 +99,8 @@ class NovelModel extends MongoModel
$arrOptions = [
'sort' => $arrSort,
// 'limit' => $intCount * 3,
- 'skip' => ($intPage - 1) * $intLimit,
- 'limit' => $intLimit,
+ 'skip' => ($intPage - 1) * $intLimit,
+ 'limit' => $intLimit,
'projection' => [
'n_id' => 1,
'og_novel_book_name' => 1,
@@ -114,13 +114,15 @@ class NovelModel extends MongoModel
],
];
+
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
+
$intTotal = $this->getCol()->countDocuments($arrFilter);
$arrResult = iterator_to_array($Cursor);
shuffle($arrResult);
-
+
$arrResult = [
'data' => $arrResult,
'total' => $intTotal,
@@ -508,21 +510,28 @@ class NovelModel extends MongoModel
*/
static public function getNovelInfoUrl($intNId, $intPinYin): string
{
- $Request = request();
- $strFomart = $Request->DomainModel->d_novel_info_url_fomart;
+ $strKey = 'NOVEL_INFO_URL';
+ $strUrl = DomainModel::getPageUrl($strKey, [
+ 'intNId' => $intNId,
+ 'strPinYin' => $intPinYin
+ ]);
+ return (string)$strUrl;
- return str_replace(
- [
- '{intNId}',
- '{strPinYin}',
- ],
- [
- $intNId,
- $intPinYin
- ],
- $strFomart
- );
+ // $Request = request();
+ // $strFomart = $Request->DomainModel->d_novel_info_url_fomart;
- return $strUrl;
+ // return str_replace(
+ // [
+ // '{intNId}',
+ // '{strPinYin}',
+ // ],
+ // [
+ // $intNId,
+ // $intPinYin
+ // ],
+ // $strFomart
+ // );
+
+ // return $strUrl;
}
}
diff --git a/code/app/model/SubjectFomartGroupModel.php b/code/app/model/SubjectFomartGroupModel.php
new file mode 100644
index 0000000..150aac4
--- /dev/null
+++ b/code/app/model/SubjectFomartGroupModel.php
@@ -0,0 +1,19 @@
+ 1,
't_code' => 'default',
't_path' => '/app/home/view/default/',
+ 't_cfg_template' => [
+ 'INDEX@GETPCINDEX' => [
+ 'description' => '首页Title 替换模板分组ID',
+ 'sfg_id' => 0,
+ ],
+ 'NOVEL@GETNOVELINFO' => [
+ 'description' => '小说详情TITLE 替换模板分组ID',
+ 'sfg_id' => 0,
+ ],
+ 'NOVEL_INFO_URL' => [
+ 'description' => '小说详情URL 替换模板分组ID',
+ 'sfg_id' => 0,
+ ],
+ ],
],
[
't_id' => 2,
't_default' => 0,
't_code' => 'kuangYu',
't_path' => '/app/home/view/kuangYu/',
+ 't_cfg_template' => [
+ 'INDEX@GETPCINDEX' => [
+ 'description' => '首页Title 替换模板分组ID',
+ 'sfg_id' => 0,
+ ],
+ 'NOVEL@GETNOVELINFO' => [
+ 'description' => '小说详情TITLE 替换模板分组ID',
+ 'sfg_id' => 0,
+ ],
+ 'NOVEL_INFO_URL' => [
+ 'description' => '小说详情URL 替换模板分组ID',
+ 'sfg_id' => 0,
+ ],
+ ],
],
[
't_id' => 3,
@@ -39,7 +67,7 @@ class TemplateSeeder
't_code' => 'shiKong',
't_path' => '/app/home/view/shiKong/',
],
-
+
];
@@ -48,13 +76,12 @@ class TemplateSeeder
if (empty($TemplatesModel)) {
TemplatesModel::insert($arrTemplate);
+ }else {
+ // 如果记录存在,更新记录
+ $TemplatesModel->update($arrTemplate);
}
}
TemplatesModel::flushCache();
-
-
-
-
}
}
diff --git a/code/extend/template/page/CusteomPage.php b/code/extend/template/page/CusteomPage.php
index 03f32bc..89726d2 100644
--- a/code/extend/template/page/CusteomPage.php
+++ b/code/extend/template/page/CusteomPage.php
@@ -41,51 +41,51 @@ class CusteomPage extends Paginator
return $this->getPageLinkWrapper($url, $text);
}
- /**
- * 页码按钮
- * @return string
- */
-/**
- * 页码按钮
- * @return string
- */
-protected function getLinks(): string
-{
- if ($this->simple) {
- return '';
- }
-
- $block = [
- 'first' => null,
- 'slider' => null,
- 'last' => null,
- ];
-
- if ($this->lastPage <= 3) {
- // 如果总页数少于或等于3,显示所有页码
- $block['first'] = $this->getUrlRange(1, $this->lastPage);
- } else {
- if ($this->currentPage == 1) {
- // 如果当前页码是第一页,显示前两页和第三页
- $block['first'] = $this->getUrlRange(1, 3);
- } elseif ($this->currentPage == $this->lastPage) {
- // 如果当前页码是最后一页,显示最后三页
- $block['first'] = $this->getUrlRange($this->lastPage - 2, $this->lastPage);
- } else {
- // 否则,显示当前页码及其前后各一页
- $block['first'] = $this->getUrlRange($this->currentPage - 1, $this->currentPage + 1);
+ /**
+ * 页码按钮
+ * @return string
+ */
+ /**
+ * 页码按钮
+ * @return string
+ */
+ protected function getLinks(): string
+ {
+ if ($this->simple) {
+ return '';
}
+
+ $block = [
+ 'first' => null,
+ 'slider' => null,
+ 'last' => null,
+ ];
+
+ if ($this->lastPage <= 3) {
+ // 如果总页数少于或等于3,显示所有页码
+ $block['first'] = $this->getUrlRange(1, $this->lastPage);
+ } else {
+ if ($this->currentPage == 1) {
+ // 如果当前页码是第一页,显示前两页和第三页
+ $block['first'] = $this->getUrlRange(1, 3);
+ } elseif ($this->currentPage == $this->lastPage) {
+ // 如果当前页码是最后一页,显示最后三页
+ $block['first'] = $this->getUrlRange($this->lastPage - 2, $this->lastPage);
+ } else {
+ // 否则,显示当前页码及其前后各一页
+ $block['first'] = $this->getUrlRange($this->currentPage - 1, $this->currentPage + 1);
+ }
+ }
+
+ $html = '';
+
+ if (is_array($block['first'])) {
+ $html .= $this->getUrlLinks($block['first']);
+ }
+
+ return $html;
}
- $html = '';
-
- if (is_array($block['first'])) {
- $html .= $this->getUrlLinks($block['first']);
- }
-
- return $html;
-}
-
/**
* 渲染分页html
* @return mixed
diff --git a/code/extend/template/page/CusteomPage02.php b/code/extend/template/page/CusteomPage02.php
new file mode 100644
index 0000000..4b51d7e
--- /dev/null
+++ b/code/extend/template/page/CusteomPage02.php
@@ -0,0 +1,152 @@
+ '上一页',
+ 'next' => '下一页',
+ 'ellipsis' => '...'
+ ];
+ $labels = array_merge($defaultLabels, $buttonLabels);
+
+ // 验证 totalButtons 必须大于 3
+ if ($totalButtons < 3) {
+ throw new \InvalidArgumentException('Total buttons must be greater than 3');
+ }
+
+ // 计算总页数
+ $totalPages = ceil($totalItems / $itemsPerPage);
+ if ($totalPages <= 1) return []; // 只有一页时返回空数组
+
+ // 确保当前页码在有效范围内
+ $currentPage = max(1, min($currentPage, $totalPages));
+
+ // 计算除去“上一页”和“下一页”后可显示的页码按钮数
+ $pageButtons = $totalButtons - 2; // 减去“上一页”和“下一页”
+
+ // 初始化按钮数组
+ $buttons = [];
+
+ // 上一页按钮
+ $buttons[] = [
+ 'type' => 'prev',
+ 'label' => $labels['prev'],
+ 'url' => $currentPage > 1 ? str_replace('{page}', $currentPage - 1, $baseUrl) : null,
+ 'rel' => $currentPage > 1 ? 'prev' : null,
+ 'disabled' => $currentPage <= 1
+ ];
+
+ // 计算页码范围
+ $half = floor($pageButtons / 2);
+ $start = max(1, $currentPage - $half);
+ $end = $start + $pageButtons - 1;
+
+ // 调整范围,确保不超过总页数
+ if ($end > $totalPages) {
+ $end = $totalPages;
+ $start = max(1, $end - $pageButtons + 1);
+ }
+
+ // 如果总页数大于可显示的页码数,添加省略号逻辑
+ if ($totalPages > $pageButtons) {
+ if ($start > 1) {
+ $buttons[] = [
+ 'type' => 'page',
+ 'label' => '1',
+ 'url' => str_replace('{page}', 1, $baseUrl),
+ 'current' => false
+ ];
+ if ($start > 2) {
+ $buttons[] = [
+ 'type' => 'ellipsis',
+ 'label' => $labels['ellipsis'],
+ 'url' => null
+ ];
+ }
+ }
+
+ // 添加页码按钮
+ for ($i = $start; $i <= $end; $i++) {
+ $buttons[] = [
+ 'type' => 'page',
+ 'label' => (string)$i,
+ 'url' => str_replace('{page}', $i, $baseUrl),
+ 'current' => $i === $currentPage
+ ];
+ }
+
+ if ($end < $totalPages) {
+ if ($end < $totalPages - 1) {
+ $buttons[] = [
+ 'type' => 'ellipsis',
+ 'label' => $labels['ellipsis'],
+ 'url' => null
+ ];
+ }
+ $buttons[] = [
+ 'type' => 'page',
+ 'label' => (string)$totalPages,
+ 'url' => str_replace('{page}', $totalPages, $baseUrl),
+ 'current' => false
+ ];
+ }
+ } else {
+ // 总页数少于等于可显示页码数,直接全部显示
+ for ($i = 1; $i <= $totalPages; $i++) {
+ $buttons[] = [
+ 'type' => 'page',
+ 'label' => (string)$i,
+ 'url' => str_replace('{page}', $i, $baseUrl),
+ 'current' => $i === $currentPage
+ ];
+ }
+ }
+
+ // 下一页按钮
+ $buttons[] = [
+ 'type' => 'next',
+ 'label' => $labels['next'],
+ 'url' => $currentPage < $totalPages ? str_replace('{page}', $currentPage + 1, $baseUrl) : null,
+ 'rel' => $currentPage < $totalPages ? 'next' : null,
+ 'disabled' => $currentPage >= $totalPages
+ ];
+
+ return $buttons;
+ }
+}
+
+// // 测试示例 1:显示 5 个按钮
+// $currentPage = 3;
+// $totalItems = 100;
+// $itemsPerPage = 10;
+// $baseUrl = '/male/xuanhuan-xiuzhen/finished/page{page}';
+// $buttons = Pagination::generate($currentPage, $totalItems, $itemsPerPage, $baseUrl, 5);
+// print_r($buttons);
+
+// // 测试示例 2:显示 7 个按钮
+// $buttons = Pagination::generate($currentPage, $totalItems, $itemsPerPage, $baseUrl, 7);
+// print_r($buttons);
+//
diff --git a/code/域名.xlsx b/code/域名.xlsx
new file mode 100644
index 0000000..3fbcbc2
Binary files /dev/null and b/code/域名.xlsx differ