样式修改完成,待测试

This commit is contained in:
rain
2026-07-07 17:07:34 +08:00
parent 0f6ed0cad3
commit 8a6a8acab7
32 changed files with 2097 additions and 505 deletions
+25 -5
View File
@@ -9,6 +9,7 @@
<script src="../utils/ApiClient.js"></script>
<script src="../utils/DateUtil.js"></script>
<script src="../utils/CommonUtil.js"></script>
<script src="../public/js/purify.min.js"></script>
<link rel="stylesheet" href="../public/css/layui/css/layui.css" />
<link rel="stylesheet" href="../public/css/public.css" />
<link rel="stylesheet" href="../public/css/mianfei.css" />
@@ -176,7 +177,11 @@
const $ = layui.$;
const urlParams = new URLSearchParams(window.location.search);
const pathMatch = window.location.pathname.match(/\/mianfei\/([^/]+)\.html$/);
const articleId = urlParams.get("id") || (pathMatch ? decodeURIComponent(pathMatch[1]) : "");
const htmlPathMatch = window.location.pathname.match(/(?:^|\/)mianfei\.html\/([^/?#]+)/i);
const articleId =
urlParams.get("id") ||
(pathMatch ? decodeURIComponent(pathMatch[1]) : "") ||
(htmlPathMatch ? decodeURIComponent(htmlPathMatch[1]) : "");
let isLiked = false;
let isCollected = false;
let articleData = null;
@@ -269,7 +274,11 @@
function renderArticle(data) {
$("#articleTitle").text(data.title || "无标题");
$("#articleAuthor").text(data.issuer || data.nickName || data.author || data.createUserName || "佚名");
$("#articleAuthor").text(
typeof CommonUtil.getFreeArticleIssuer === "function"
? CommonUtil.getFreeArticleIssuer(data)
: data.issuer || data.nickName || data.author || data.createUserName || "佚名",
);
$("#articleTime").text(data.updateTime || data.createTime || data.publishTime || "--");
$("#articleContent").html(scopeArticleContent(data.content || ""));
document.title = "神彩算 - " + (data.title || "免费文章详情");
@@ -289,6 +298,10 @@
return '<p class="cxz-content-empty">暂无内容</p>';
}
if (typeof DOMPurify !== "undefined") {
html = DOMPurify.sanitize(html);
}
var scopedStyles = [];
html = html.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, function (_, css) {
scopedStyles.push(prefixContentCss(css));
@@ -357,7 +370,10 @@
}
function loadRelatedArticles() {
ApiClient.get(ApiClient.API.freeArticleRelated(articleId))
ApiClient.get(ApiClient.API.freeArticleRelated(articleId), {
limit: 12,
articleCount: 12,
})
.then(function (res) {
if (!ApiClient.isSuccess(res)) return;
var data = ApiClient.pickData(res, {}) || {};
@@ -370,14 +386,17 @@
renderFreeArticleList("#freeRelatedList", rows.filter(function (item) {
var id = item && (item.id || item.articleId || item.freeArticleId);
return id && String(id) !== String(articleId);
}).slice(0, 8));
}).slice(0, 12));
})
.catch(function () {});
loadFreeArticleLatest();
}
function loadFreeArticleLatest() {
ApiClient.get(ApiClient.API.freeArticleLatest, { articleCount: 8 })
ApiClient.get(ApiClient.API.freeArticleLatest, {
limit: 12,
articleCount: 12,
})
.then(function (res) {
if (!ApiClient.isSuccess(res)) return;
renderFreeArticleList("#freeLatestList", ApiClient.asArray(ApiClient.pickData(res, [])));
@@ -394,6 +413,7 @@
return;
}
$.each(list, function (_, item) {
if (_ >= 12) return false;
var id = item.id || item.articleId || item.freeArticleId;
if (!id) return;
var title = item.title || item.articleTitle || item.name || "无标题";