小说伪造详情页面 代码优化

This commit is contained in:
make
2025-07-29 22:39:17 +08:00
parent 89b32cdb9b
commit 926bdc3ef2
8 changed files with 107 additions and 138 deletions

View File

@@ -276,19 +276,18 @@ $Novel.n_id{extend name="baseH5" /}
{/volist} {/volist}
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels); }
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); }
} {/php}
{/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
<a <a

View File

@@ -168,19 +168,18 @@
<p>相邻推荐: <p>相邻推荐:
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels);
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); }
} }
{/php} {/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
{if !empty($arrGrm[$key+20])} {if !empty($arrGrm[$key+20])}

View File

@@ -246,20 +246,18 @@
<div class="listtop"> <div class="listtop">
<b>书友推荐:</b> <b>书友推荐:</b>
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels); }
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); }
} {/php}
{/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
<a <a
href='{site:nnurl n_id="$arrNovel.n_id" n_py="$arrNovel.n_name_pinyin" n_fid="$ForgeNovel.n_forge_id"/}'>{$ForgeNovel.n_forge_title}</a>&nbsp;&nbsp; href='{site:nnurl n_id="$arrNovel.n_id" n_py="$arrNovel.n_name_pinyin" n_fid="$ForgeNovel.n_forge_id"/}'>{$ForgeNovel.n_forge_title}</a>&nbsp;&nbsp;

View File

@@ -141,19 +141,18 @@
<div id="intro"> <div id="intro">
{$arrNovel.n_description ?? ''}<br /> {$arrNovel.n_description ?? ''}<br />
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels);
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); }
} }
{/php} {/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
<a <a

View File

@@ -220,19 +220,18 @@
</p> </p>
<p class="xianglingtuijian">相邻推荐: <p class="xianglingtuijian">相邻推荐:
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels); }
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); }
} {/php}
{/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}

View File

@@ -257,17 +257,16 @@
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels); }
}
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); {/php}
}
{/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}

View File

@@ -247,7 +247,6 @@
{$arrGrm[115]|raw} {$arrGrm[115]|raw}
{/if} {/if}
<div class="view-number"> <div class="view-number">
{if empty($Request.route.intForgeId)}
<div class="item"> <div class="item">
<div class="label">{site:wz wz="推荐等级" /}</div> <div class="label">{site:wz wz="推荐等级" /}</div>
<div class="value">{$arrNovel.n_level}</div> <div class="value">{$arrNovel.n_level}</div>
@@ -260,27 +259,6 @@
<div class="label">{site:wz wz="在看人数" /}</div> <div class="label">{site:wz wz="在看人数" /}</div>
<div class="value">{$arrNovel.arrNovelClicks.total}</div> <div class="value">{$arrNovel.arrNovelClicks.total}</div>
</div> </div>
{else}
{php}
$min = 1; // 最小值(可根据需要调整)
$max = 10000; // 最大值(可根据需要调整)
$randomNumberR = mt_rand($min, 10); // 生成随机整数
$randomNumberS = mt_rand($min, $max); // 生成随机整数
$randomNumberK = mt_rand($min, $max); // 生成随机整数
{/php}
<div class="item">
<div class="label">{site:wz wz="推荐等级" /}</div>
<div class="value">{$randomNumberR}</div>
</div>
<div class="item">
<div class="label">{site:wz wz="收藏数" /}</div>
<div class="value">{$randomNumberS}</div>
</div>
<div class="item">
<div class="label">{site:wz wz="在看人数" /}</div>
<div class="value">{$randomNumberK}</div>
</div>
{/if}
</div> </div>
<div class="detail-desc"> <div class="detail-desc">
@@ -296,41 +274,40 @@
<span class="value"> <span class="value">
<span class="value-tag"> <span class="value-tag">
{if empty($Request.route.intForgeId)} {if empty($Request.route.intForgeId)}
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$arrRandomForgeNovels = $arrNovel['n_forge_novel']; $arrRandomForgeNovels = $arrNovel['n_forge_novel'];
} }
{/php} {/php}
{volist name='$arrNovel.arrRelateveNovel' id='Novel' key="key"} {volist name='$arrNovel.arrRelateveNovel' id='Novel' key="key"}
{if !empty($arrGrm[$key + 24])} {if !empty($arrGrm[$key + 24])}
{$arrGrm[$key+24]|raw} {$arrGrm[$key+24]|raw}
{/if} {/if}
<a <a
href='{site:nurl n_id="$Novel.n_id" n_py="$Novel.n_name_pinyin" /}'>{$Novel.n_name}</a>&nbsp;&nbsp; href='{site:nurl n_id="$Novel.n_id" n_py="$Novel.n_name_pinyin" /}'>{$Novel.n_name}</a>&nbsp;&nbsp;
{/volist} {/volist}
{else} {else}
{novel:list count="10" n_category="$arrNovel.n_category_pinyin" sort_type="update" {novel:list count="10" n_category="$arrNovel.n_category_pinyin" sort_type="update"
d_key="d_key" d_val="Novel" diff_key="$Request.route.intForgeId" cache_life="1000"} d_key="d_key" d_val="Novel" diff_key="$Request.route.intForgeId" cache_life="3600"}
<a <a
href='{site:nurl n_id="$Novel.n_id" n_py="$Novel.n_name_pinyin" /}'>{$Novel.n_name}</a>&nbsp;&nbsp; href='{site:nurl n_id="$Novel.n_id" n_py="$Novel.n_name_pinyin" /}'>{$Novel.n_name}</a>&nbsp;&nbsp;
{/novel:list} {/novel:list}
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels); }
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); }
} {/php}
{/php}
{/if} {/if}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}
@@ -365,7 +342,7 @@
{else} {else}
<div class="work-list"> <div class="work-list">
{novel:list count="32" n_category="$arrNovel.n_category_pinyin" sort_type="update" d_key="d_key" {novel:list count="32" n_category="$arrNovel.n_category_pinyin" sort_type="update" d_key="d_key"
d_val="Novel" diff_key="$Request.route.intForgeId" cache_life="600"} d_val="Novel" diff_key="$Request.route.intForgeId" cache_life="3600"}
{include file="public/novel-list-flex" start="16"/} {include file="public/novel-list-flex" start="16"/}
{/novel:list} {/novel:list}
</div> </div>
@@ -374,7 +351,7 @@
{/if} {/if}
<div class="work-list"> <div class="work-list">
{novel:ranklist count="32" sort_type="daily" d_key="d_key" {novel:ranklist count="32" sort_type="daily" d_key="d_key"
d_val="Novel" diff_key="$Request.route.intForgeId" cache_life="600"} d_val="Novel" diff_key="$Request.route.intForgeId" cache_life="3600"}
{include file="public/novel-list-flex" start="16"/} {include file="public/novel-list-flex" start="16"/}
{/novel:ranklist} {/novel:ranklist}
</div> </div>

View File

@@ -202,17 +202,16 @@
{php} {php}
$arrRandomForgeNovels = []; $arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) { if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel']; $forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) { $count = count($forgeNovels);
$randomKeys = array_rand($forgeNovels, 10); if ($count > 0) {
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys)); $randomKeys = array_rand($forgeNovels, min(10, $count));
} else { foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels = $forgeNovels; $arrRandomForgeNovels[] = $forgeNovels[$key];
shuffle($arrRandomForgeNovels); }
}
} }
$arrRandomForgeNovels = array_values($arrRandomForgeNovels); {/php}
}
{/php}
{volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"} {volist name='arrRandomForgeNovels' id='ForgeNovel' key="key"}