This commit is contained in:
make
2025-04-21 21:03:24 +08:00
parent 2337ab4f7d
commit 43761001fa
20 changed files with 106 additions and 136 deletions

View File

@@ -7,7 +7,7 @@ use think\template\TagLib;
class Novel extends TagLib
{
protected $tags = [
'list' => ['attr' => 'count,n_category,sort_type,n_status,n_sex,diff_key,cache_life,d_key,d_val', 'close' => 1],
'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],
@@ -15,8 +15,6 @@ class Novel extends TagLib
'status' => ['attr' => 'd_key,d_val'],
'sex' => ['attr' => 'd_key,d_val'],
'category' => ['attr' => 'd_key,d_val,n_sex'],
'ranklist' => ['attr' => 'count,sort_type,n_status,n_sex,diff_key,cache_life,d_key,d_val', 'close' => 1],
];
private function customBuildVar($mixedArgs)
@@ -29,67 +27,8 @@ class Novel extends TagLib
}
/**
* tagRankList
*
* @param array $tag
* @param string $content
* @return void
*/
public function tagRankList($tag, $content)
{
$count = $tag['count'] ?? '10';
$sort_type = $tag['sort_type'] ?? "";
$n_status = $tag['n_status'] ?? "all";
$n_sex = $tag['n_sex'] ?? "all";
$diff_key = $tag['diff_key'] ?? "";
$cache_life = $tag['cache_life'] ?? '0';
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$sort_type = $this->customBuildVar($sort_type);
$n_status = $this->customBuildVar($n_status);
$n_sex = $this->customBuildVar($n_sex);
$diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\NovelService::class)->getRankList([
'count' => {$count},
'sort_type' => {$sort_type},
'n_status' => {$n_status},
'n_sex' => {$n_sex},
'diff_key' => {$diff_key},
'cache_life' => {$cache_life}
]);
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* tagPagerExp
*
* @param array $tag
* @param string $content
* @return void
* novel 自定义标签
*/
public function tagPagerExp($tag, $content)
{
@@ -97,11 +36,7 @@ EOT;
}
/**
* tagPager
*
* @param array $tag
* @param string $content
* @return void
* novel 自定义标签
*/
public function tagPager($tag, $content)
{
@@ -180,11 +115,7 @@ EOT;
}
/**
* tagList
*
* @param array $tag
* @param string $content
* @return void
* novel 自定义标签
*/
public function tagList($tag, $content)
{

View File

@@ -17,7 +17,7 @@ class Site extends TagLib
'nclurl' => ['attr' => 'n_id,n_py,order,page', 'close' => 0],
'nflurl' => ['attr' => 'gender,category,status,order,page', 'close' => 0],
'grm' => ['attr' => 'domain,code,line,diff,start,end,index,type', 'close' => 0],
'replace' => ['attr' => 'code', 'close' => 0],
'replace' => ['attr' => 'code,diff', 'close' => 0],
'forgelist' => ['attr' => 'count,diff_key,cache_life,d_key,d_val', 'close' => 1],
];
@@ -253,10 +253,10 @@ EOD;
*/
public function tagNFLUrl($tag)
{
$strGender = isset($tag['gender']) ? $tag['gender'] : 'all';
$strGender = isset($tag['gender']) ? $tag['gender'] : '';
$strCategory = isset($tag['category']) ? $tag['category'] : 'all';
$strStatus = isset($tag['status']) ? $tag['status'] : 'all';
$strOrder = isset($tag['order']) ? $tag['order'] : 'all';
$strOrder = isset($tag['order']) ? $tag['order'] : '';
$intPage = isset($tag['page']) ? $tag['page'] : 1;
$strGender = $this->customBuildVar($strGender);
@@ -311,10 +311,13 @@ EOD;
public function tagReplace($tag)
{
$strCode = isset($tag['code']) ? $tag['code'] : '';
$strDiff = isset($tag['diff']) ? $tag['diff'] : '0';
// $strCode = $this->customBuildVar($strCode);
$strDiff = $this->customBuildVar($strDiff);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\SiteContext::class)->converterTemplate("{$strCode}");
\$strUrl = app(\\app\\services\\SiteContext::class)->converterTemplate("{$strCode}",{$strDiff});
echo \$strUrl;
?>
EOD;
@@ -322,7 +325,6 @@ EOD;
}
/**
* get grm
*
@@ -341,10 +343,7 @@ EOD;
$page_code = $this->customBuildVar($page_code);
$diff = $this->customBuildVar($diff);
$num = $this->customBuildVar($num);
// var_dump($page_code);
// var_dump($diff);
// var_dump($num);
// exit;
$arrDataName = randomString(5);
$strParse = <<<EOT