seed
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use app\admin\controller\Domain;
|
use app\admin\controller\Domain;
|
||||||
use app\admin\controller\Novel;
|
use app\admin\controller\Novel;
|
||||||
|
use app\admin\controller\Site;
|
||||||
use app\admin\middleware\AdminAuth;
|
use app\admin\middleware\AdminAuth;
|
||||||
use think\facade\Route;
|
use think\facade\Route;
|
||||||
|
|
||||||
@@ -39,9 +40,15 @@ Route::group("/novel", function () {
|
|||||||
|
|
||||||
# 站点
|
# 站点
|
||||||
Route::group("/site", 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);
|
})->middleware(AdminAuth::class);
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ use app\admin\BaseController;
|
|||||||
use app\model\AdminUserModel;
|
use app\model\AdminUserModel;
|
||||||
use app\model\ConverterMovel;
|
use app\model\ConverterMovel;
|
||||||
use app\model\DomainModel;
|
use app\model\DomainModel;
|
||||||
|
use app\model\TemplatesModel;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
use think\Response;
|
use think\Response;
|
||||||
|
|
||||||
class Domain extends BaseController
|
|
||||||
|
class Site extends BaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +63,7 @@ class Domain extends BaseController
|
|||||||
$arrDomain = [
|
$arrDomain = [
|
||||||
'd_domain' => $arrRows[0],
|
'd_domain' => $arrRows[0],
|
||||||
't_id' => $arrRows[1],
|
't_id' => $arrRows[1],
|
||||||
'd_title' => $arrRows[2],
|
'd_name' => $arrRows[2],
|
||||||
'd_keywords' => $arrRows[3],
|
'd_keywords' => $arrRows[3],
|
||||||
'd_description' => $arrRows[4],
|
'd_description' => $arrRows[4],
|
||||||
'd_statis' => $arrRows[5],
|
'd_statis' => $arrRows[5],
|
||||||
@@ -69,7 +71,13 @@ class Domain extends BaseController
|
|||||||
'd_text_log' => $arrRows[7],
|
'd_text_log' => $arrRows[7],
|
||||||
'd_img_log' => $arrRows[8],
|
'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 = DomainModel::where('d_domain', $arrDomain['d_domain'])->findOrEmpty();
|
||||||
|
|
||||||
$DomainModel->fill($arrDomain);
|
$DomainModel->fill($arrDomain);
|
||||||
$DomainModel->save();
|
$DomainModel->save();
|
||||||
}
|
}
|
||||||
@@ -129,4 +137,99 @@ class Domain extends BaseController
|
|||||||
|
|
||||||
return $this->success($arrResult);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -814,4 +814,17 @@ namespace {
|
|||||||
|
|
||||||
return $strPinYin;
|
return $strPinYin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @param object $Obj
|
||||||
|
* @param string $strAction
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getFomartSubjectKey(string $strAction): string
|
||||||
|
{
|
||||||
|
return strtoupper(str_replace('::', '@', ltrim(strrchr($strAction, "\\"), "\\")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ abstract class BaseController
|
|||||||
private function initSiteTKD()
|
private function initSiteTKD()
|
||||||
{
|
{
|
||||||
ConverterMovel::setVal([
|
ConverterMovel::setVal([
|
||||||
'strSiteTitle' => $this->request->DomainModel->d_title,
|
'strSiteName' => $this->request->DomainModel->d_name,
|
||||||
'strSiteKeywords' => $this->request->DomainModel->d_keywords,
|
'strSiteKeywords' => $this->request->DomainModel->d_keywords,
|
||||||
'strSiteDescription' => $this->request->DomainModel->d_description,
|
'strSiteDescription' => $this->request->DomainModel->d_description,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ use think\facade\Route;
|
|||||||
/**
|
/**
|
||||||
* 首页
|
* 首页
|
||||||
*/
|
*/
|
||||||
Route::get("/", [Index::class,'index'])->ext('html')->append(['boolIsMobile' => true]);
|
Route::get("/", [Index::class, 'index'])->ext('html')->append(['boolIsMobile' => true]);
|
||||||
Route::get("/pc/", [Index::class,'getPcIndex'])->append(['boolIsMobile' => false]);
|
Route::get("/pc/", [Index::class, 'getPcIndex'])->append(['boolIsMobile' => false]);
|
||||||
// Route::get("/index", [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", [Index::class,'getPcIndex'])->ext('html')->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//排行榜
|
//排行榜
|
||||||
Route::get('/paihang/all', [Novel::class,'getNovelRank'])->append(['boolIsMobile' => true]);
|
Route::get('/paihang/all', [Novel::class, 'getNovelRank'])->append(['boolIsMobile' => true]);
|
||||||
Route::get("/pc/paihang/all", [Novel::class,'getNovelRank'])->append(['boolIsMobile' => false]);
|
Route::get("/pc/paihang/all", [Novel::class, 'getNovelRank'])->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 男生/女生 - grok 推荐最优方案
|
* 男生/女生 - grok 推荐最优方案
|
||||||
@@ -38,22 +38,22 @@ Route::get('/pc/nvsheng-xiaoshuo', [Novel::class, 'getNovelChannel'])->append([
|
|||||||
* 书库 - grok 推荐最优方案
|
* 书库 - grok 推荐最优方案
|
||||||
* /shuku/channel-category-status-page
|
* /shuku/channel-category-status-page
|
||||||
*/
|
*/
|
||||||
Route::get('/shuku/all', [Novel::class,'getLibrary'])->append(['boolIsMobile' => true]);
|
Route::get('/shuku/all', [Novel::class, 'getLibrary'])->append(['boolIsMobile' => true]);
|
||||||
Route::get('/pc/shuku/all', [Novel::class,'getLibrary'])->append(['boolIsMobile' => false]);
|
Route::get('/pc/shuku/all', [Novel::class, 'getLibrary'])->append(['boolIsMobile' => false]);
|
||||||
Route::get('/shuku/:intGender-:strCategory-:strStatus-:intPage', [Novel::class,'getLibrary'])
|
Route::get('/shuku/:strGender/:strCategory/:strStatus/page:intPage', [Novel::class, 'getLibrary'])
|
||||||
->pattern([
|
->pattern([
|
||||||
'intGender' => '\d{1}',
|
'strGender' => 'nansheng-xiaoshuo|nvsheng-xiaoshuo|all',
|
||||||
'strCategory' => '[\w]*',
|
'strCategory' => '[a-z\-]+',
|
||||||
'strStatus' => '[\w]*',
|
'strStatus' => 'all|lianzai|wanjie',
|
||||||
'intPage' => '\d+'
|
'intPage' => '\d+'
|
||||||
])
|
])
|
||||||
->append(['boolIsMobile' => true]);
|
->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([
|
->pattern([
|
||||||
'intGender' => '\d{1}',
|
'strGender' => 'nansheng-xiaoshuo|nvsheng-xiaoshuo|all',
|
||||||
'strCategory' => '[\w]*',
|
'strCategory' => '[a-z\-]+',
|
||||||
'strStatus' => '[\w]*',
|
'strStatus' => 'all|lianzai|wanjie',
|
||||||
'intPage' => '\d+'
|
'intPage' => '\d+'
|
||||||
])
|
])
|
||||||
->append(['boolIsMobile' => false]);
|
->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'])
|
Route::get('/xiaoshuo/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]', [Novel::class, 'getNovelChapter'])
|
||||||
->append(['boolIsMobile' => true, 'intUriType' => 1])
|
->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'])
|
Route::get('/pc/xiaoshuo/:name-:intNovelId/zhang-:intChapterSort/[:intChapterPage]', [Novel::class, 'getNovelChapter'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 1])
|
->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'])
|
Route::get('/pc/books/:name-:n_id/chapter/latest', [Novel::class, 'getNovelNewsChapter'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 1])
|
->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'])
|
Route::get('/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]', [Novel::class, 'getNovelChapterAll'])
|
||||||
->append(['boolIsMobile' => true, 'intUriType' => 1])
|
->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'])
|
Route::get('/pc/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]', [Novel::class, 'getNovelChapterAll'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 1])
|
->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,57 +103,57 @@ Route::get('/pc/xiaoshuo/:name-:intNovelId/mulu/:strOrder/[:intPage]', [Novel::c
|
|||||||
*/
|
*/
|
||||||
Route::get('/pc/book/:name-:n_id', [Novel::class, 'getNovelInfo'])
|
Route::get('/pc/book/:name-:n_id', [Novel::class, 'getNovelInfo'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 1])
|
->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'])
|
Route::get('/pc/novel/:name-:n_id', [Novel::class, 'getNovelInfo'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 2])
|
->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'])
|
Route::get('/pc/xiaoshuo/:name-:n_id', [Novel::class, 'getNovelInfo'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 2])
|
->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'])
|
Route::get('/pc/book-:name-:n_id', [Novel::class, 'getNovelInfo'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 3])
|
->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'])
|
Route::get('/pc/novel-:name-:n_id', [Novel::class, 'getNovelInfo'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 3])
|
->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'])
|
Route::get('/pc/xiaoshuo-:name-:n_id', [Novel::class, 'getNovelInfo'])
|
||||||
->append(['boolIsMobile' => false, 'intUriType' => 3])
|
->append(['boolIsMobile' => false, 'intUriType' => 3])
|
||||||
->pattern(['n_id' => '\d+','name' => '[\w-]+',]);
|
->pattern(['n_id' => '\d+', 'name' => '[\w-]+',]);
|
||||||
|
|
||||||
|
|
||||||
// 搜索小说
|
// 搜索小说
|
||||||
Route::get('/search', [Novel::class,'getSearchNovel'])->ext('html')->append(['boolIsMobile' => true]);
|
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('/pc/search', [Novel::class, 'getSearchNovel'])->ext('html')->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
// 小说用户中心
|
// 小说用户中心
|
||||||
Route::get('/user', [User::class,'Index'])->append(['boolIsMobile' => true]);
|
Route::get('/user', [User::class, 'Index'])->append(['boolIsMobile' => true]);
|
||||||
Route::get('/pc/user', [User::class,'Index'])->append(['boolIsMobile' => false]);
|
Route::get('/pc/user', [User::class, 'Index'])->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
|
|
||||||
// 书架
|
// 书架
|
||||||
Route::get('/bookshelf', [User::class,'getBookShelf'])->append(['boolIsMobile' => true]);
|
Route::get('/bookshelf', [User::class, 'getBookShelf'])->append(['boolIsMobile' => true]);
|
||||||
Route::get('/pc/bookshelf', [User::class,'getBookShelf'])->append(['boolIsMobile' => false]);
|
Route::get('/pc/bookshelf', [User::class, 'getBookShelf'])->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
// 历史记录
|
// 历史记录
|
||||||
Route::get('/history', [User::class,'getHistory'])->append(['boolIsMobile' => true]);
|
Route::get('/history', [User::class, 'getHistory'])->append(['boolIsMobile' => true]);
|
||||||
Route::get('/pc/history', [User::class,'getHistory'])->append(['boolIsMobile' => false]);
|
Route::get('/pc/history', [User::class, 'getHistory'])->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 文章 列表
|
// 文章 列表
|
||||||
Route::get('/article/list-[:intCategoryId]-[:intPage]', [Novel::class,'getArticleList'])->append(['boolIsMobile' => true]);
|
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('/pc/article/list-[:intCategoryId]-[:intPage]', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => false]);
|
||||||
Route::get('/article/list', [Novel::class,'getArticleList'])->append(['boolIsMobile' => true]);
|
Route::get('/article/list', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => true]);
|
||||||
Route::get('/pc/article/list', [Novel::class,'getArticleList'])->append(['boolIsMobile' => false]);
|
Route::get('/pc/article/list', [Novel::class, 'getArticleList'])->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
// 文章 详情
|
// 文章 详情
|
||||||
Route::get('/article/info-:intArticleId', [Novel::class,'getArticleInfo'])->append(['boolIsMobile' => true]);
|
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('/pc/article/info-:intArticleId', [Novel::class, 'getArticleInfo'])->append(['boolIsMobile' => false]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace app\home\controller;
|
|||||||
|
|
||||||
use app\home\BaseController;
|
use app\home\BaseController;
|
||||||
use app\model\ConverterMovel;
|
use app\model\ConverterMovel;
|
||||||
|
use app\model\DomainModel;
|
||||||
use app\model\NovelModel;
|
use app\model\NovelModel;
|
||||||
use storage\StorageCore;
|
use storage\StorageCore;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
@@ -161,6 +162,11 @@ class Index extends BaseController
|
|||||||
// 最近更新-随机50
|
// 最近更新-随机50
|
||||||
$arrNewsUpdateNovel = $NovelModel->getSexNovelOnCache($Request->DomainModel->d_domain, 50);
|
$arrNewsUpdateNovel = $NovelModel->getSexNovelOnCache($Request->DomainModel->d_domain, 50);
|
||||||
|
|
||||||
|
$strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__));
|
||||||
|
|
||||||
|
$strTitle = ConverterMovel::convert($strTitle);
|
||||||
|
|
||||||
|
|
||||||
View::assign([
|
View::assign([
|
||||||
'arrNewsUpdateNovel' => $arrNewsUpdateNovel,
|
'arrNewsUpdateNovel' => $arrNewsUpdateNovel,
|
||||||
'arrRecommendSerializationNovel' => $arrRecommendSerializationNovel,
|
'arrRecommendSerializationNovel' => $arrRecommendSerializationNovel,
|
||||||
@@ -174,17 +180,11 @@ class Index extends BaseController
|
|||||||
'arrGirlMoonRankNovel' => $arrGirlMoonRankNovel,
|
'arrGirlMoonRankNovel' => $arrGirlMoonRankNovel,
|
||||||
'arrBGirlTotalRankNovel' => $arrBGirlTotalRankNovel,
|
'arrBGirlTotalRankNovel' => $arrBGirlTotalRankNovel,
|
||||||
'arrAdBanner' => [],
|
'arrAdBanner' => [],
|
||||||
'strPageCode' => 'home'
|
'strPageCode' => 'home',
|
||||||
|
'strTitle' => $strTitle,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$strTitle = '最新小说网-{strSiteTitle}-{strSiteKeywords}';
|
|
||||||
|
|
||||||
$strTitle = ConverterMovel::convert($strTitle);
|
|
||||||
|
|
||||||
echo $strTitle;exit;
|
|
||||||
|
|
||||||
|
|
||||||
if ($boolIsMobile) {
|
if ($boolIsMobile) {
|
||||||
return View::fetch();
|
return View::fetch();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ declare(strict_types=1);
|
|||||||
namespace app\home\controller;
|
namespace app\home\controller;
|
||||||
|
|
||||||
use app\home\BaseController;
|
use app\home\BaseController;
|
||||||
|
use app\model\CategoryModel;
|
||||||
use app\model\ConverterMovel;
|
use app\model\ConverterMovel;
|
||||||
use app\model\NovelModel;
|
use app\model\NovelModel;
|
||||||
use storage\StorageCore;
|
use storage\StorageCore;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use app\Request;
|
use app\Request;
|
||||||
|
use template\page\CusteomPage02;
|
||||||
|
|
||||||
class Novel extends BaseController
|
class Novel extends BaseController
|
||||||
{
|
{
|
||||||
@@ -131,53 +133,90 @@ class Novel extends BaseController
|
|||||||
* @param integer $intPage 分页
|
* @param integer $intPage 分页
|
||||||
* @return void
|
* @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');
|
$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');
|
$intPage = (int)$Request->param('intPage');
|
||||||
|
if ($intPage <= 1) {
|
||||||
|
$intPage = 1;
|
||||||
|
}
|
||||||
$intLimit = 20;
|
$intLimit = 20;
|
||||||
$intLifeTime = 24 * 3600;
|
$intLifeTime = 24 * 3600;
|
||||||
|
|
||||||
|
$strKey = sprintf("Novel:Library:%s:%s:%s:%s", $intGender, $strSearchCategory, $strSearchStatus, $intPage);
|
||||||
|
|
||||||
|
|
||||||
$NovelModel = new NovelModel;
|
$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;
|
$strTemplate = NULL;
|
||||||
$arrPage = $NovelModel->getCommonNovelPageOnCache($strKey, $intPage, $intLimit, $intLifeTime, $intGender, $strStatus);
|
$intButtomNum = 5;
|
||||||
|
if ($boolIsMobile == false) {
|
||||||
|
$intButtomNum = 10;
|
||||||
|
$strTemplate = 'pc/getLibrary';
|
||||||
|
}
|
||||||
|
|
||||||
// echo '<pre>';
|
$strBaseUrl = sprintf('/pc/shuku/%s/%s/%s/page{page}', $strGender, $strCategory, $strStatus);
|
||||||
// print_r($arrPage);
|
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||||
// 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'],
|
|
||||||
];
|
|
||||||
|
|
||||||
View::assign([
|
View::assign([
|
||||||
'arrNovel' => $arrNovel,
|
'arrNovel' => $arrPage['data'],
|
||||||
'strPageCode' => 'library',
|
'strPageCode' => 'library',
|
||||||
'intGender' => $intGender,
|
'strGender' => $strGender,
|
||||||
'strCategory' => $strCategory,
|
'strCategory' => $strCategory,
|
||||||
'strStatus' => $strStatus,
|
'strStatus' => $strStatus,
|
||||||
'intPage' => $intPage,
|
'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 = '斗罗大陆';
|
$strNovel = '斗罗大陆';
|
||||||
|
|
||||||
ConverterMovel::setVal("strNovelName",$strNovel);
|
ConverterMovel::setVal("strNovelName", $strNovel);
|
||||||
|
|
||||||
|
|
||||||
// 模拟数据-随机推荐数据10条
|
// 模拟数据-随机推荐数据10条
|
||||||
@@ -359,7 +398,8 @@ class Novel extends BaseController
|
|||||||
// 最新要点->取新意章节, 随机提取一部分内容 大概150字数
|
// 最新要点->取新意章节, 随机提取一部分内容 大概150字数
|
||||||
|
|
||||||
|
|
||||||
|
// {strNovelName}最新章节_{strNovelName}{strNovelAuthor}_{strNovelName}全文阅读_{strSiteName}
|
||||||
|
// {strNovelName}免费全文阅读-{strNovelName}{strNovelAuthor}-{strSiteName}
|
||||||
|
|
||||||
// $strTitle = '小说详情-{strNovelName}-xxxxx';
|
// $strTitle = '小说详情-{strNovelName}-xxxxx';
|
||||||
|
|
||||||
@@ -367,9 +407,15 @@ class Novel extends BaseController
|
|||||||
|
|
||||||
// echo $strTitle;exit;
|
// echo $strTitle;exit;
|
||||||
|
|
||||||
|
$strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__));
|
||||||
|
// echo $strTitle ;exit;
|
||||||
|
$strTitle = ConverterMovel::convert($strTitle);
|
||||||
|
|
||||||
|
|
||||||
View::assign([
|
View::assign([
|
||||||
'arrRecommendNovel' => $arrRecommendNovel,
|
'arrRecommendNovel' => $arrRecommendNovel,
|
||||||
'strPageCode' => 'boy'
|
'strPageCode' => 'boy',
|
||||||
|
'strTitle' => $strTitle,
|
||||||
]);
|
]);
|
||||||
if ($boolIsMobile) {
|
if ($boolIsMobile) {
|
||||||
return View::fetch();
|
return View::fetch();
|
||||||
|
|||||||
@@ -28,25 +28,28 @@
|
|||||||
<div class="optCl" mod="search_channel">
|
<div class="optCl" mod="search_channel">
|
||||||
<span class="optTit">所属频道</span>
|
<span class="optTit">所属频道</span>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a class="on" href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}.html" btn="search_category">全部</a></li>
|
<li><a class="on" href="/pc/shuku/all/{$strCategory}/{$strStatus}/page{$intPage}.html" btn="search_category">全部</a></li>
|
||||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">男生</a></li>
|
<li><a href="/pc/shuku/nansheng-xiaoshuo/{$strCategory}/{$strStatus}/page{$intPage}" btn="search_category">男生</a></li>
|
||||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">女生</a></li>
|
<li><a href="/pc/shuku/nvsheng-xiaoshuo/{$strCategory}/{$strStatus}/page{$intPage}" btn="search_category">女生</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="optCl" mod="search_channel">
|
<div class="optCl" mod="search_channel">
|
||||||
<span class="optTit">所属分类</span>
|
<span class="optTit">所属分类</span>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a class="on" href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">全部</a></li>
|
<li><a class="on" href="/pc/shuku/{$strGender}/all/{$strStatus}/page{$intPage}" btn="search_category">全部</a></li>
|
||||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">都市修仙</a></li>
|
|
||||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">玄幻修真</a></li>
|
{foreach $arrCategory as $key=>$vo }
|
||||||
|
<li><a href="/pc/shuku/{$strGender}/{$key}/{$strStatus}/page{$intPage}" btn="search_category">{$vo}</a></li>
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="optCl">
|
<div class="optCl">
|
||||||
<span class="optTit">是否完结</span>
|
<span class="optTit">是否完结</span>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a class="on" href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">全部</a></li>
|
<li><a class="on" href="/pc/shuku/{$strGender}/{$strCategory}/all/page{$intPage}" btn="search_category">全部</a></li>
|
||||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">连载</a></li>
|
<li><a href="/pc/shuku/{$strGender}/{$strCategory}/lianzai/page{$intPage}" btn="search_category">连载</a></li>
|
||||||
<li><a href="/pc/shuku/{$intGender}-{$strCategory}-{$strStatus}-{$intPage}" btn="search_category">完本</a></li>
|
<li><a href="/pc/shuku/{$strGender}/{$strCategory}/wanjie/page{$intPage}" btn="search_category">完本</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,19 +66,28 @@
|
|||||||
<!--页码切换 开始-->
|
<!--页码切换 开始-->
|
||||||
<div class="changepage">
|
<div class="changepage">
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<li class="disabled"><span>«</span></li>
|
|
||||||
|
|
||||||
|
{volist name="arrPaginator" id="vo" key="k" }
|
||||||
|
<li><a href="{$vo.url}">{$vo.label}</a></li>
|
||||||
|
{/volist}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <li class="disabled"><span>«</span></li>
|
||||||
<li class="active"><span>1</span></li>
|
<li class="active"><span>1</span></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-2">2</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-2">2</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-3">3</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-3">3</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-4">4</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-4">4</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-5">5</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-5">5</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-6">6</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-6">6</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-7">7</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-7">7</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-8">8</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-8">8</a></li>
|
||||||
<li class="disabled"><span>...</span></li>
|
<li class="disabled"><span>...</span></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-33">33</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-33">33</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-34">34</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-34">34</a></li>
|
||||||
<li><a href="/pc/{$intGender}-{$strCategory}-{$strStatus}-2">»</a></li>
|
<li><a href="/pc/{$strGender}-{$strCategory}-{$strStatus}-2">»</a></li> -->
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!--页码切换 结束-->
|
<!--页码切换 结束-->
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
|
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
|
||||||
<meta name="keywords" content="狂雨小说">
|
<meta name="keywords" content="狂雨小说">
|
||||||
<meta name="description" content="狂雨小说">
|
<meta name="description" content="狂雨小说">
|
||||||
<title>狂雨小说</title>
|
<title>{$strTitle??''}</title>
|
||||||
<link rel="stylesheet" href="/template/kuangyu/home/bai_web/css/style.css" type="text/css">
|
<link rel="stylesheet" href="/template/kuangyu/home/bai_web/css/style.css" type="text/css">
|
||||||
<link rel="stylesheet" href="/template/kuangyu/public/css/common.css" type="text/css">
|
<link rel="stylesheet" href="/template/kuangyu/public/css/common.css" type="text/css">
|
||||||
<link rel="stylesheet" href="/public/layer/need/layer.css" type="text/css">
|
<link rel="stylesheet" href="/public/layer/need/layer.css" type="text/css">
|
||||||
|
|||||||
@@ -28,6 +28,18 @@ class CategoryModel extends MongoModel
|
|||||||
9 => '其他小说',
|
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 = [
|
static $arrMan = [
|
||||||
1 => '玄幻修真',
|
1 => '玄幻修真',
|
||||||
2 => '军史小说',
|
2 => '军史小说',
|
||||||
@@ -44,17 +56,17 @@ class CategoryModel extends MongoModel
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
static public function getCategory():array
|
static public function getCategory(): array
|
||||||
{
|
{
|
||||||
return self::$arrCategory;
|
return self::$arrCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getManCategory():array
|
static public function getManCategory(): array
|
||||||
{
|
{
|
||||||
return self::$arrMan;
|
return self::$arrMan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getWomenCategory():array
|
static public function getWomenCategory(): array
|
||||||
{
|
{
|
||||||
return self::$arrWomen;
|
return self::$arrWomen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use think\Model;
|
|||||||
class ConverterMovel
|
class ConverterMovel
|
||||||
{
|
{
|
||||||
static private $arrMap = [
|
static private $arrMap = [
|
||||||
'{strSiteTitle}' => '',
|
'{strSiteName}' => '',
|
||||||
'{strSiteKeywords}' => '',
|
'{strSiteKeywords}' => '',
|
||||||
'{strSiteDescription}' => '',
|
'{strSiteDescription}' => '',
|
||||||
'{strNovelName}' => '',
|
'{strNovelName}' => '',
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ class DomainModel extends BaseModel
|
|||||||
protected $name = 'domain';
|
protected $name = 'domain';
|
||||||
protected $pk = 'd_id';
|
protected $pk = 'd_id';
|
||||||
|
|
||||||
|
protected $json = ['t_cfg'];
|
||||||
|
|
||||||
|
|
||||||
static public function getDomainByCache($strDomain)
|
static public function getDomainByCache($strDomain)
|
||||||
{
|
{
|
||||||
@@ -47,4 +49,54 @@ class DomainModel extends BaseModel
|
|||||||
|
|
||||||
return $strWords;
|
return $strWords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @param string $strKey
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getFomartSubject($strKey) //, $intNum = 1, $boolRand = false)
|
||||||
|
{
|
||||||
|
// echo $strKey;
|
||||||
|
// //exit;
|
||||||
|
// echo '<pre>';
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,9 @@ class NovelModel extends MongoModel
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||||
|
|
||||||
$intTotal = $this->getCol()->countDocuments($arrFilter);
|
$intTotal = $this->getCol()->countDocuments($arrFilter);
|
||||||
|
|
||||||
$arrResult = iterator_to_array($Cursor);
|
$arrResult = iterator_to_array($Cursor);
|
||||||
@@ -507,21 +509,28 @@ class NovelModel extends MongoModel
|
|||||||
*/
|
*/
|
||||||
static public function getNovelInfoUrl($intNId, $intPinYin): string
|
static public function getNovelInfoUrl($intNId, $intPinYin): string
|
||||||
{
|
{
|
||||||
$Request = request();
|
$strKey = 'NOVEL_INFO_URL';
|
||||||
$strFomart = $Request->DomainModel->d_novel_info_url_fomart;
|
$strUrl = DomainModel::getPageUrl($strKey, [
|
||||||
|
'intNId' => $intNId,
|
||||||
|
'strPinYin' => $intPinYin
|
||||||
|
]);
|
||||||
|
return (string)$strUrl;
|
||||||
|
|
||||||
return str_replace(
|
// $Request = request();
|
||||||
[
|
// $strFomart = $Request->DomainModel->d_novel_info_url_fomart;
|
||||||
'{intNId}',
|
|
||||||
'{strPinYin}',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
$intNId,
|
|
||||||
$intPinYin
|
|
||||||
],
|
|
||||||
$strFomart
|
|
||||||
);
|
|
||||||
|
|
||||||
return $strUrl;
|
// return str_replace(
|
||||||
|
// [
|
||||||
|
// '{intNId}',
|
||||||
|
// '{strPinYin}',
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// $intNId,
|
||||||
|
// $intPinYin
|
||||||
|
// ],
|
||||||
|
// $strFomart
|
||||||
|
// );
|
||||||
|
|
||||||
|
// return $strUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
code/app/model/SubjectFomartGroupModel.php
Normal file
19
code/app/model/SubjectFomartGroupModel.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use think\facade\Cache;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin think\Model
|
||||||
|
*/
|
||||||
|
class SubjectFomartGroupModel extends BaseModel
|
||||||
|
{
|
||||||
|
protected $name = 'subject_fomart_group';
|
||||||
|
protected $pk = 'sfg_id';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
17
code/app/model/SubjectFomartModel.php
Normal file
17
code/app/model/SubjectFomartModel.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace app\model;
|
||||||
|
|
||||||
|
use think\facade\Cache;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin think\Model
|
||||||
|
*/
|
||||||
|
class SubjectFomartModel extends BaseModel
|
||||||
|
{
|
||||||
|
protected $name = 'subject_fomart';
|
||||||
|
protected $pk = 'sf_id';
|
||||||
|
}
|
||||||
@@ -13,8 +13,26 @@ use think\Model;
|
|||||||
class TemplatesModel extends BaseModel
|
class TemplatesModel extends BaseModel
|
||||||
{
|
{
|
||||||
protected $name = 'templates';
|
protected $name = 'templates';
|
||||||
|
|
||||||
protected $pk = 't_id';
|
protected $pk = 't_id';
|
||||||
|
|
||||||
|
protected $json = ['t_cfg_template'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @param string $strVal
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
// public function getTCfgTemplatesAttr($strVal)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// if (!empty($strVal)) {
|
||||||
|
// return json_decode($strVal);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
static $arrTemplates = [];
|
static $arrTemplates = [];
|
||||||
|
|
||||||
static public function getTemplateOnCache($intTId)
|
static public function getTemplateOnCache($intTId)
|
||||||
|
|||||||
@@ -63,19 +63,19 @@ CREATE TABLE `domain` (
|
|||||||
`d_id` int NOT NULL AUTO_INCREMENT COMMENT '域名ID',
|
`d_id` int NOT NULL AUTO_INCREMENT COMMENT '域名ID',
|
||||||
`d_domain` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '域名',
|
`d_domain` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '域名',
|
||||||
`t_id` int DEFAULT NULL COMMENT '模板ID',
|
`t_id` int DEFAULT NULL COMMENT '模板ID',
|
||||||
`d_title` varchar(300) COLLATE utf8mb4_unicode_ci DEFAULT '',
|
`d_name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '',
|
||||||
`d_keywords` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
`d_keywords` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
`d_description` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
`d_description` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
`d_statis` text COLLATE utf8mb4_unicode_ci COMMENT '单域名统计',
|
`d_statis` text COLLATE utf8mb4_unicode_ci COMMENT '单域名统计',
|
||||||
`d_logo_type` tinyint(1) DEFAULT NULL,
|
`d_logo_type` tinyint(1) DEFAULT NULL,
|
||||||
`d_text_log` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
`d_text_log` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
`d_img_log` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
`d_img_log` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
`d_novel_info_url_fomart` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
||||||
`d_content_encode` tinyint unsigned DEFAULT '0',
|
`d_content_encode` tinyint unsigned DEFAULT '0',
|
||||||
|
`t_cfg` json DEFAULT NULL,
|
||||||
PRIMARY KEY (`d_id`),
|
PRIMARY KEY (`d_id`),
|
||||||
KEY `t_id` (`t_id`),
|
UNIQUE KEY `d_domain` (`d_domain`) USING BTREE,
|
||||||
KEY `d_domain` (`d_domain`)
|
KEY `t_id` (`t_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='域名表';
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='域名表';
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -175,6 +175,36 @@ CREATE TABLE `plan_task` (
|
|||||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
|
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `subject_fomart`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `subject_fomart`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `subject_fomart` (
|
||||||
|
`sf_id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`sfg_id` int DEFAULT NULL COMMENT '所属格式化分组ID',
|
||||||
|
`sf_val` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '待格式化内容',
|
||||||
|
PRIMARY KEY (`sf_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `subject_fomart_group`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `subject_fomart_group`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `subject_fomart_group` (
|
||||||
|
`sfg_id` int unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`sfg_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`sfg_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
|
||||||
|
PRIMARY KEY (`sfg_id`) USING BTREE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `system_config`
|
-- Table structure for table `system_config`
|
||||||
--
|
--
|
||||||
@@ -205,9 +235,10 @@ CREATE TABLE `templates` (
|
|||||||
`t_default` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否默认模板',
|
`t_default` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否默认模板',
|
||||||
`t_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '模板编码',
|
`t_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '模板编码',
|
||||||
`t_path` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '模板位置',
|
`t_path` varchar(1000) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '模板位置',
|
||||||
|
`t_cfg_template` json DEFAULT NULL COMMENT '模板需要配置的变量',
|
||||||
PRIMARY KEY (`t_id`),
|
PRIMARY KEY (`t_id`),
|
||||||
KEY `t_code` (`t_code`)
|
KEY `t_code` (`t_code`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='模板表';
|
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='模板表';
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -236,4 +267,4 @@ CREATE TABLE `zi_yuan_duan_dian` (
|
|||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2025-03-28 21:52:16
|
-- Dump completed on 2025-03-31 23:11:02
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace database\seeders;
|
namespace database\seeders;;
|
||||||
;
|
|
||||||
use app\model\TemplatesModel;
|
use app\model\TemplatesModel;
|
||||||
|
|
||||||
class TemplateSeeder
|
class TemplateSeeder
|
||||||
@@ -14,6 +14,20 @@ class TemplateSeeder
|
|||||||
't_default' => 1,
|
't_default' => 1,
|
||||||
't_code' => 'default',
|
't_code' => 'default',
|
||||||
't_path' => '/app/home/view/default/',
|
't_path' => '/app/home/view/default/',
|
||||||
|
't_cfg_template' => [
|
||||||
|
'HOME@INDEX' => [
|
||||||
|
'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_id' => 2,
|
||||||
@@ -52,9 +66,5 @@ class TemplateSeeder
|
|||||||
}
|
}
|
||||||
|
|
||||||
TemplatesModel::flushCache();
|
TemplatesModel::flushCache();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,51 +41,51 @@ class CusteomPage extends Paginator
|
|||||||
return $this->getPageLinkWrapper($url, $text);
|
return $this->getPageLinkWrapper($url, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页码按钮
|
* 页码按钮
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* 页码按钮
|
* 页码按钮
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getLinks(): string
|
protected function getLinks(): string
|
||||||
{
|
{
|
||||||
if ($this->simple) {
|
if ($this->simple) {
|
||||||
return '';
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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
|
* 渲染分页html
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
|||||||
152
code/extend/template/page/CusteomPage02.php
Normal file
152
code/extend/template/page/CusteomPage02.php
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace template\page;
|
||||||
|
|
||||||
|
use think\Paginator;
|
||||||
|
|
||||||
|
class CusteomPage02
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 生成分页按钮数据
|
||||||
|
* @param int $currentPage 当前页码
|
||||||
|
* @param int $totalItems 总数据量
|
||||||
|
* @param int $itemsPerPage 每页条数
|
||||||
|
* @param string $baseUrl 基础 URL 模板(如 /male/xuanhuan-xiuzhen/finished/page{page})
|
||||||
|
* @param int $totalButtons 总按钮数量(必须大于3)
|
||||||
|
* @param array $buttonLabels 按钮文本配置
|
||||||
|
* @return array 分页按钮数据
|
||||||
|
*/
|
||||||
|
public static function generate(
|
||||||
|
$currentPage,
|
||||||
|
$totalItems,
|
||||||
|
$itemsPerPage,
|
||||||
|
$baseUrl,
|
||||||
|
$totalButtons = 5,
|
||||||
|
$buttonLabels = []
|
||||||
|
) {
|
||||||
|
// 默认按钮文本
|
||||||
|
$defaultLabels = [
|
||||||
|
'prev' => '上一页',
|
||||||
|
'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);
|
||||||
|
//
|
||||||
BIN
code/域名.xlsx
Normal file
BIN
code/域名.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user