This commit is contained in:
Default
2025-04-19 16:50:08 +08:00
parent aafd25260a
commit 4299706868
7 changed files with 300 additions and 216 deletions

View File

@@ -808,4 +808,22 @@ namespace {
}
}
}
/**
* generate string
*
* @param integer $length
* @return string
*/
function randomString(int $length): string {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$max = 51; // 字符集长度减1 (0-51)
$result = '';
for ($i = 0; $i < $length; $i++) {
$result .= $chars[random_int(0, $max)];
}
return $result;
}
}

View File

@@ -9,9 +9,9 @@ use app\services\SiteContext;
use think\facade\Route;
// Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) {
// return view($SiteContext->getHomeView());
// });
Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) {
return view('test/test01/index.html');
});

View File

@@ -1,3 +1,24 @@
{novel:pagerexp page="1" limit="10" n_category="$Request.route.category" d_key="d_key" d_val="novel" p_val="page_data"
cache_life="1000" func="generateSearchPager" export_name="fadfads" /}
{php}var_dump($fadfads['p_data']);{/php}
<!-- {novel:pager page="1" limit="10" n_category="$Request.route.category" d_key="d_key" d_val="novel" p_val="page_data"
cache_life="1000" func="generateSearchPager"}
<li>
Index: {$d_key}
Title: {$novel.n_name}
Author: {$novel.n_category}
</li>
{/novel:pager}
{php}var_dump($page_data);{/php} -->
<!-- {site:grm page_code="fdasfadsf" diff="fadsfdsa" num="10" g_key="arrGrm" /}
{php}var_dump($arrGrm);{/php} -->
@@ -49,9 +70,9 @@
{/novel:sort} -->
<!--
{novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /}
{$arrNovel01.n_name}
{$arrNovel01.n_name} -->
<!-- {$DomainModel->d_domain} -->
@@ -66,17 +87,3 @@
</li>
{/novel:list} -->
<!--
{novel:pager page="1" limit="10" n_category="$Request.route.category" d_key="d_key" d_val="novel" p_val="page_data"
cache_life="1000" func="generateSearchPager"}
<li>
Index: {$d_key}
Title: {$novel.n_name}
Author: {$novel.n_category}
</li>
{/novel:pager}
{php}var_dump($page_data);{/php}
-->

View File

@@ -168,7 +168,7 @@ class ChapterService
$strCacheKey = '';
$intLifeTime = 0;
if (empty($arrFilter['$and'])) {
$arrFilter = [];
}
@@ -188,7 +188,7 @@ class ChapterService
$intLifeTime = $intLifeTime;
}
$arrNovel = $this->ChapterModel->findPaginatedWithCache(
$arrChapter = $this->ChapterModel->findPaginatedWithCache(
$arrFilter,
$intPage,
$intLimit,
@@ -197,10 +197,14 @@ class ChapterService
$intLifeTime,
);
$arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel);
$arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrChapter);
$arrPager = $arrChapter;
unset($arrPager['data']);
$arrPager['pager'] = call_user_func([$this, $Func], $arrParams, $arrSort, $arrChapter);
$arrResult = [
'data' => $arrNovel['data'],
'data' => $arrChapter['data'],
'p_data' => $arrPager,
];
@@ -218,7 +222,7 @@ class ChapterService
{
// 小说详情
$arrNovel = $this->NovelModel->getNovelByNId($intNId);
// 章节
$ChapterModel = ChapterModel::getInstance();
$arrFilter = ['n_id' => $intNId, 'c_sort_num' => $intCSortNum, 'c_page' => $intCPage];

View File

@@ -416,8 +416,8 @@ class NovelService
}
}
# n_category_sex_zh filter
if (!empty($strNSex)) {
# key filter
if (!empty($strKey)) {
$strKey = mb_substr($strKey, 0, 30);
$arrFilter['$and'][] = [
@@ -468,7 +468,11 @@ class NovelService
$intLifeTime = $intLifeTime;
}
if (empty($arrFilter['$and'])) {
$arrFilter = [];
}
$arrNovel = $this->NovelModel->findPaginatedWithCache(
$arrFilter,
$intPage,
@@ -478,11 +482,12 @@ class NovelService
$intLifeTime,
);
$arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel);
$arrPager = $arrNovel;
unset($arrPager['data']);
$arrPager['pager'] = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel);
$arrResult = [
'data' => $arrNovel['data'] ?? [],
'pages' => $arrNovel['pages'] ?? 0,
'data' => $arrNovel['data'],
'p_data' => $arrPager,
];