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

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

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

View File

@@ -171,14 +171,13 @@
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
{/php}

View File

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

View File

@@ -144,14 +144,13 @@
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
{/php}

View File

@@ -223,14 +223,13 @@
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
{/php}

View File

@@ -258,14 +258,13 @@
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
{/php}

View File

@@ -247,7 +247,6 @@
{$arrGrm[115]|raw}
{/if}
<div class="view-number">
{if empty($Request.route.intForgeId)}
<div class="item">
<div class="label">{site:wz wz="推荐等级" /}</div>
<div class="value">{$arrNovel.n_level}</div>
@@ -260,27 +259,6 @@
<div class="label">{site:wz wz="在看人数" /}</div>
<div class="value">{$arrNovel.arrNovelClicks.total}</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 class="detail-desc">
@@ -312,24 +290,23 @@
{else}
{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
href='{site:nurl n_id="$Novel.n_id" n_py="$Novel.n_name_pinyin" /}'>{$Novel.n_name}</a>&nbsp;&nbsp;
{/novel:list}
{php}
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
}
{/php}
{/if}
@@ -365,7 +342,7 @@
{else}
<div class="work-list">
{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"/}
{/novel:list}
</div>
@@ -374,7 +351,7 @@
{/if}
<div class="work-list">
{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"/}
{/novel:ranklist}
</div>

View File

@@ -203,14 +203,13 @@
$arrRandomForgeNovels = [];
if (isset($arrNovel['n_forge_novel']) && is_array($arrNovel['n_forge_novel'])) {
$forgeNovels = $arrNovel['n_forge_novel'];
if (count($forgeNovels) > 10) {
$randomKeys = array_rand($forgeNovels, 10);
$arrRandomForgeNovels = array_intersect_key($forgeNovels, array_flip($randomKeys));
} else {
$arrRandomForgeNovels = $forgeNovels;
shuffle($arrRandomForgeNovels);
$count = count($forgeNovels);
if ($count > 0) {
$randomKeys = array_rand($forgeNovels, min(10, $count));
foreach ((array) $randomKeys as $key) {
$arrRandomForgeNovels[] = $forgeNovels[$key];
}
}
$arrRandomForgeNovels = array_values($arrRandomForgeNovels);
}
{/php}