Merge branch 'dev' of ssh://git.bgbg.live:18150/root/SEONexus into dev

This commit is contained in:
make
2025-04-19 16:51:24 +08:00
8 changed files with 312 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; use think\facade\Route;
// Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) { Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) {
// return view($SiteContext->getHomeView()); 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" /} <!-- {site:grm page_code="fdasfadsf" diff="fadsfdsa" num="10" g_key="arrGrm" /}
{php}var_dump($arrGrm);{/php} --> {php}var_dump($arrGrm);{/php} -->
@@ -49,9 +70,9 @@
{/novel:sort} --> {/novel:sort} -->
<!--
{novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /} {novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /}
{$arrNovel01.n_name} {$arrNovel01.n_name} -->
<!-- {$DomainModel->d_domain} --> <!-- {$DomainModel->d_domain} -->
@@ -66,17 +87,3 @@
</li> </li>
{/novel:list} --> {/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

@@ -188,7 +188,7 @@ class ChapterService
$intLifeTime = $intLifeTime; $intLifeTime = $intLifeTime;
} }
$arrNovel = $this->ChapterModel->findPaginatedWithCache( $arrChapter = $this->ChapterModel->findPaginatedWithCache(
$arrFilter, $arrFilter,
$intPage, $intPage,
$intLimit, $intLimit,
@@ -197,10 +197,14 @@ class ChapterService
$intLifeTime, $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 = [ $arrResult = [
'data' => $arrNovel['data'], 'data' => $arrChapter['data'],
'p_data' => $arrPager, 'p_data' => $arrPager,
]; ];

View File

@@ -416,8 +416,8 @@ class NovelService
} }
} }
# n_category_sex_zh filter # key filter
if (!empty($strNSex)) { if (!empty($strKey)) {
$strKey = mb_substr($strKey, 0, 30); $strKey = mb_substr($strKey, 0, 30);
$arrFilter['$and'][] = [ $arrFilter['$and'][] = [
@@ -469,6 +469,10 @@ class NovelService
$intLifeTime = $intLifeTime; $intLifeTime = $intLifeTime;
} }
if (empty($arrFilter['$and'])) {
$arrFilter = [];
}
$arrNovel = $this->NovelModel->findPaginatedWithCache( $arrNovel = $this->NovelModel->findPaginatedWithCache(
$arrFilter, $arrFilter,
$intPage, $intPage,
@@ -478,11 +482,12 @@ class NovelService
$intLifeTime, $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 = [ $arrResult = [
'data' => $arrNovel['data'] ?? [], 'data' => $arrNovel['data'],
'pages' => $arrNovel['pages'] ?? 0,
'p_data' => $arrPager, 'p_data' => $arrPager,
]; ];

View File

@@ -10,10 +10,22 @@ return [
'key' => ['n_name' => 1], 'key' => ['n_name' => 1],
'options' => ['unique' => false] 'options' => ['unique' => false]
], ],
[
'key' => ['n_author' => 1],
'options' => ['unique' => false]
],
[
'key' => ['n_description' => 1],
'options' => ['unique' => false]
],
[ [
'key' => ['n_category' => 1], 'key' => ['n_category' => 1],
'options' => ['unique' => false] 'options' => ['unique' => false]
], ],
[
'key' => ['n_category_sex_en' => 1],
'options' => ['unique' => false]
],
[ [
'key' => ['n_status' => 1], 'key' => ['n_status' => 1],
'options' => ['unique' => false] 'options' => ['unique' => false]

View File

@@ -8,7 +8,8 @@ class Chapter extends TagLib
{ {
protected $tags = [ protected $tags = [
'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val'], 'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val'],
'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val'], 'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,export_name'],
'pagerexp' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
'info' => ['attr' => 'n_id,n_key', 'close' => 0], 'info' => ['attr' => 'n_id,n_key', 'close' => 0],
]; ];
@@ -22,6 +23,19 @@ class Chapter extends TagLib
} }
/**
* pagerexp tag code
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagPagerExp($tag, $content)
{
return $this->tagPager($tag, $content);
}
/** /**
* chapter pager * chapter pager
* *
@@ -42,6 +56,7 @@ class Chapter extends TagLib
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$p_val = $tag['p_val'] ?? 'p_val'; $p_val = $tag['p_val'] ?? 'p_val';
$func = $tag['func']; $func = $tag['func'];
$export_name = $tag['export_name'] ?? '';
$n_id = $this->customBuildVar($n_id); $n_id = $this->customBuildVar($n_id);
$sort_type = $this->customBuildVar($sort_type); $sort_type = $this->customBuildVar($sort_type);
@@ -53,9 +68,11 @@ class Chapter extends TagLib
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$func = $this->customBuildVar($func); $func = $this->customBuildVar($func);
$arrDataName = randomString(5);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrChapter = app(\\app\\services\\ChapterService::class)->getNovelPager([ \${$arrDataName} = app(\\app\\services\\ChapterService::class)->getNovelPager([
'page' => {$page}, 'page' => {$page},
'limit' => {$limit}, 'limit' => {$limit},
'button_num' => {$button_num}, 'button_num' => {$button_num},
@@ -65,19 +82,27 @@ class Chapter extends TagLib
'cache_life' => {$cache_life}, 'cache_life' => {$cache_life},
'func' => {$func}, 'func' => {$func},
]); ]);
EOT;
if (isset(\$arrChapter['data']) && is_array(\$arrChapter['data'])): if (empty($export_name)) {
\${$p_val} = \$arrChapter['p_data'] ?? []; $strParse .= <<<EOT
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrChapter['data'] as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
} else {
$strParse .= <<<EOT
\${$export_name} = \${$arrDataName};
EOT;
}
return $strParse; return $strParse;
} }
@@ -103,11 +128,11 @@ EOT;
$sort_type = $this->customBuildVar($sort_type); $sort_type = $this->customBuildVar($sort_type);
$diff_key = $this->customBuildVar($diff_key); $diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$arrDataName = randomString(5);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrChapter = app(\\app\\services\\ChapterService::class)->getChapterList([ \${$arrDataName} = app(\\app\\services\\ChapterService::class)->getChapterList([
'n_id' => {$n_id}, 'n_id' => {$n_id},
'count' => {$count}, 'count' => {$count},
'sort_type' => {$sort_type}, 'sort_type' => {$sort_type},
@@ -115,12 +140,12 @@ EOT;
'cache_life' => {$cache_life}, 'cache_life' => {$cache_life},
]); ]);
if (!empty(\$arrChapter) && is_array(\$arrChapter)): if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrChapter as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT

View File

@@ -7,8 +7,9 @@ use think\template\TagLib;
class Novel extends TagLib class Novel extends TagLib
{ {
protected $tags = [ protected $tags = [
'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val'], 'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val', 'close' => 1],
'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val'], 'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 1],
'pagerexp' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
'info' => ['attr' => 'n_id,n_key', 'close' => 0], 'info' => ['attr' => 'n_id,n_key', 'close' => 0],
'sort' => ['attr' => 'd_key,d_val'], 'sort' => ['attr' => 'd_key,d_val'],
'status' => ['attr' => 'd_key,d_val'], 'status' => ['attr' => 'd_key,d_val'],
@@ -26,6 +27,14 @@ class Novel extends TagLib
} }
/**
* novel 自定义标签
*/
public function tagPagerExp($tag, $content)
{
return $this->tagPager($tag, $content);
}
/** /**
* novel 自定义标签 * novel 自定义标签
*/ */
@@ -44,7 +53,9 @@ class Novel extends TagLib
$d_key = $tag['d_key'] ?? 'd_key'; $d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$p_val = $tag['p_val'] ?? 'p_val'; $p_val = $tag['p_val'] ?? 'p_val';
$n_num = $tag['n_num'] ?? 'n_num';
$export_name = $tag['export_name'] ?? '';
$func = $tag['func']; $func = $tag['func'];
$page = $this->customBuildVar($page); $page = $this->customBuildVar($page);
@@ -59,9 +70,11 @@ class Novel extends TagLib
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$func = $this->customBuildVar($func); $func = $this->customBuildVar($func);
$arrDataName = randomString(5);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$novelData = app(\\app\\services\\NovelService::class)->getNovelPager([ \${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelPager([
'page' => {$page}, 'page' => {$page},
'limit' => {$limit}, 'limit' => {$limit},
'button_num' => {$button_num}, 'button_num' => {$button_num},
@@ -74,20 +87,30 @@ class Novel extends TagLib
'cache_life' => {$cache_life}, 'cache_life' => {$cache_life},
'func' => {$func}, 'func' => {$func},
]); ]);
EOT;
if (isset(\$novelData['data']) && is_array(\$novelData['data'])):
\${$p_val} = \$novelData['p_data'] ?? []; if (empty($export_name)) {
\${$n_num} = \$novelData['pages'] ?? []; $strParse .= <<<EOT
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$novelData['data'] as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
} else {
$strParse .= <<<EOT
\${$export_name} = \${$arrDataName};
?>
EOT;
}
return $strParse; return $strParse;
} }
@@ -114,9 +137,11 @@ EOT;
$diff_key = $this->customBuildVar($diff_key); $diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$arrDataName = randomString(5);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$novelData = app(\\app\\services\\NovelService::class)->getNovelList([ \${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelList([
'count' => {$count}, 'count' => {$count},
'n_category' => {$n_category}, 'n_category' => {$n_category},
'sort_type' => {$sort_type}, 'sort_type' => {$sort_type},
@@ -126,12 +151,12 @@ EOT;
'cache_life' => {$cache_life} 'cache_life' => {$cache_life}
]); ]);
if (!empty(\$novelData) && is_array(\$novelData)): if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$novelData as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT