格式化

This commit is contained in:
2025-07-17 15:22:56 +08:00
parent 6f1b660b5d
commit b599790f9a

View File

@@ -42,7 +42,8 @@
<div class="nhlpapp-search">
<div class="nhlpappshtop">
<div class="nhlpapp-shdiv">
<input class="nhlp-ipt" id="search-input" placeholder="{:lang_i18n('请输入搜索关键字,如安装赛博云空间,影视库')}" autocomplete="off">
<input class="nhlp-ipt" id="search-input" placeholder="{:lang_i18n('请输入搜索关键字,如安装赛博云空间,影视库')}"
autocomplete="off">
<img src="__IMAGES__/ssapp.png" class="searchimg">
</div>
<span class="closetx">{:lang_i18n('取消')}</span>
@@ -52,7 +53,7 @@
<div class="dropdown" id="dropdown"></div>
</div>
<!-- 分类文章目录 -->
<div class="nhlpapp-pagescate" {:style(['display' => $Request.get.view == 'more' ? 'block' : 'none'])}>
<div class="nhlpapp-pagescate" {:style(['display'=> $Request.get.view == 'more' ? 'block' : 'none'])}>
<div class="nars-hlpdt-ml">
{notempty name="article_categorys"}
<div class="nav-tree">
@@ -60,14 +61,16 @@
<div class="categoryhelp">
<div class="categoryhelp-title">
<div>
<img src="__IMAGES__/nars-jt.png" class="arrow {if condition='$ac.id == $Request.get.cid'}rotate{/if}">
<img src="__IMAGES__/nars-jt.png"
class="arrow {if condition='$ac.id == $Request.get.cid'}rotate{/if}">
</div>
<span>{$ac.name}</span>
</div>
<ul class="sub-list" {if condition='$ac.id == $Request.get.cid'}style="display: block;"{/if}>
<ul class="sub-list" {if condition='$ac.id == $Request.get.cid' }style="display: block;" {/if}>
{volist name="ac.article" id="ar"}
<li>
<a href="{:url('/index/topic/nas/help_detail', ['cid' => $ac.id , 'id' => $ar.id])}" style="padding-top: 6px;">
<a href="{:url('/index/topic/nas/help_detail', ['cid' => $ac.id , 'id' => $ar.id])}"
style="padding-top: 6px;">
{$ar.title}
</a>
</li>
@@ -134,10 +137,10 @@
$('.nhlpapp-search').hide();
});
// 顶部国家选择
$('.top-country-toggle').click(function(){
$('.top-country-toggle').click(function () {
$(".mask,.action-sheet").show();
})
$('.top-country .close-icon').click(function(){
$('.top-country .close-icon').click(function () {
$(".mask,.action-sheet").hide();
})
// 搜索
@@ -172,22 +175,19 @@
})
}, 300);
});
// 英文截断
// 处理 #rendered-content 内的内容
$('#rendered-content').html(function(i, html) {
// 英文截断处理
$('#rendered-content').html(function (i, html) {
// 1. 先保护真正的空行(只包含&nbsp;的标签)
html = html.replace(/<(p|h[1-6])>(<strong>)?(&nbsp;| )*(<\/strong>)?<\/\1>/g, function(match) {
html = html.replace(/<(p|h[1-6])>(<strong>)?(&nbsp;| )*(<\/strong>)?<\/\1>/g, function (match) {
// 统一空行格式为 <p>&nbsp;</p> 或 <h2>&nbsp;</h2> 形式
return match.replace(/(<p>|<h[1-6]>)\s*(<strong>)?\s*(&nbsp;| )*\s*(<\/strong>)?\s*(<\/p>|<\/h[1-6]>)/,
function(m) {
function (m) {
var tag = m.match(/<(p|h[1-6])>/)[1];
return '<' + tag + '>&nbsp;</' + tag + '>';
});
});
// 2. 替换其他&nbsp;为普通空格(保留单词间的空格)
html = html.replace(/&nbsp;(?=\w)/g, ' ');
return html;
});
@@ -200,7 +200,7 @@
});
// 优化英文单词间的空格处理
$('#rendered-content').find('p, h1, h2, h3, h4, h5, h6').each(function() {
$('#rendered-content').find('p, h1, h2, h3, h4, h5, h6').each(function () {
var $el = $(this);
// 只处理非空行
if ($el.html().trim() !== '&nbsp;') {