debug
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
-->
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
|
||||
@@ -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'][] = [
|
||||
@@ -469,6 +469,10 @@ 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,
|
||||
];
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ class Chapter extends TagLib
|
||||
{
|
||||
protected $tags = [
|
||||
'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],
|
||||
];
|
||||
|
||||
@@ -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
|
||||
*
|
||||
@@ -42,6 +56,7 @@ class Chapter extends TagLib
|
||||
$d_val = $tag['d_val'] ?? 'd_val';
|
||||
$p_val = $tag['p_val'] ?? 'p_val';
|
||||
$func = $tag['func'];
|
||||
$export_name = $tag['export_name'] ?? '';
|
||||
|
||||
$n_id = $this->customBuildVar($n_id);
|
||||
$sort_type = $this->customBuildVar($sort_type);
|
||||
@@ -53,9 +68,11 @@ class Chapter extends TagLib
|
||||
$cache_life = $this->customBuildVar($cache_life);
|
||||
$func = $this->customBuildVar($func);
|
||||
|
||||
$arrDataName = randomString(5);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$arrChapter = app(\\app\\services\\ChapterService::class)->getNovelPager([
|
||||
\${$arrDataName} = app(\\app\\services\\ChapterService::class)->getNovelPager([
|
||||
'page' => {$page},
|
||||
'limit' => {$limit},
|
||||
'button_num' => {$button_num},
|
||||
@@ -65,19 +82,27 @@ class Chapter extends TagLib
|
||||
'cache_life' => {$cache_life},
|
||||
'func' => {$func},
|
||||
]);
|
||||
EOT;
|
||||
|
||||
if (isset(\$arrChapter['data']) && is_array(\$arrChapter['data'])):
|
||||
\${$p_val} = \$arrChapter['p_data'] ?? [];
|
||||
if (empty($export_name)) {
|
||||
$strParse .= <<<EOT
|
||||
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
|
||||
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$arrChapter['data'] as \${$d_key} => \${$d_val}): ?>
|
||||
<?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
EOT;
|
||||
} else {
|
||||
$strParse .= <<<EOT
|
||||
\${$export_name} = \${$arrDataName};
|
||||
EOT;
|
||||
}
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
@@ -103,11 +128,11 @@ EOT;
|
||||
$sort_type = $this->customBuildVar($sort_type);
|
||||
$diff_key = $this->customBuildVar($diff_key);
|
||||
$cache_life = $this->customBuildVar($cache_life);
|
||||
|
||||
$arrDataName = randomString(5);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$arrChapter = app(\\app\\services\\ChapterService::class)->getChapterList([
|
||||
\${$arrDataName} = app(\\app\\services\\ChapterService::class)->getChapterList([
|
||||
'n_id' => {$n_id},
|
||||
'count' => {$count},
|
||||
'sort_type' => {$sort_type},
|
||||
@@ -115,12 +140,12 @@ EOT;
|
||||
'cache_life' => {$cache_life},
|
||||
]);
|
||||
|
||||
if (!empty(\$arrChapter) && is_array(\$arrChapter)):
|
||||
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
|
||||
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$arrChapter as \${$d_key} => \${$d_val}): ?>
|
||||
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
|
||||
@@ -7,8 +7,9 @@ use think\template\TagLib;
|
||||
class Novel extends TagLib
|
||||
{
|
||||
protected $tags = [
|
||||
'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'],
|
||||
'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,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],
|
||||
'sort' => ['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 自定义标签
|
||||
*/
|
||||
@@ -44,7 +53,9 @@ class Novel extends TagLib
|
||||
$d_key = $tag['d_key'] ?? 'd_key';
|
||||
$d_val = $tag['d_val'] ?? 'd_val';
|
||||
$p_val = $tag['p_val'] ?? 'p_val';
|
||||
$n_num = $tag['n_num'] ?? 'n_num';
|
||||
|
||||
$export_name = $tag['export_name'] ?? '';
|
||||
|
||||
$func = $tag['func'];
|
||||
|
||||
$page = $this->customBuildVar($page);
|
||||
@@ -59,9 +70,11 @@ class Novel extends TagLib
|
||||
$cache_life = $this->customBuildVar($cache_life);
|
||||
$func = $this->customBuildVar($func);
|
||||
|
||||
$arrDataName = randomString(5);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$novelData = app(\\app\\services\\NovelService::class)->getNovelPager([
|
||||
\${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelPager([
|
||||
'page' => {$page},
|
||||
'limit' => {$limit},
|
||||
'button_num' => {$button_num},
|
||||
@@ -74,20 +87,30 @@ class Novel extends TagLib
|
||||
'cache_life' => {$cache_life},
|
||||
'func' => {$func},
|
||||
]);
|
||||
EOT;
|
||||
|
||||
if (isset(\$novelData['data']) && is_array(\$novelData['data'])):
|
||||
\${$p_val} = \$novelData['p_data'] ?? [];
|
||||
\${$n_num} = \$novelData['pages'] ?? [];
|
||||
|
||||
if (empty($export_name)) {
|
||||
$strParse .= <<<EOT
|
||||
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
|
||||
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$novelData['data'] as \${$d_key} => \${$d_val}): ?>
|
||||
<?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
EOT;
|
||||
} else {
|
||||
$strParse .= <<<EOT
|
||||
\${$export_name} = \${$arrDataName};
|
||||
?>
|
||||
EOT;
|
||||
}
|
||||
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
@@ -114,9 +137,11 @@ EOT;
|
||||
$diff_key = $this->customBuildVar($diff_key);
|
||||
$cache_life = $this->customBuildVar($cache_life);
|
||||
|
||||
$arrDataName = randomString(5);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$novelData = app(\\app\\services\\NovelService::class)->getNovelList([
|
||||
\${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelList([
|
||||
'count' => {$count},
|
||||
'n_category' => {$n_category},
|
||||
'sort_type' => {$sort_type},
|
||||
@@ -126,12 +151,12 @@ EOT;
|
||||
'cache_life' => {$cache_life}
|
||||
]);
|
||||
|
||||
if (!empty(\$novelData) && is_array(\$novelData)):
|
||||
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
|
||||
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$novelData as \${$d_key} => \${$d_val}): ?>
|
||||
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
|
||||
Reference in New Issue
Block a user