东方大厦
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
yiqiu
2025-11-22 01:14:47 +08:00
parent 095ff222a1
commit 51fd1035aa
8 changed files with 299 additions and 483 deletions

View File

@@ -20,54 +20,12 @@ $(function () {
viewer.show();
});
// 获取通用配置信息(关于页:用插件覆盖 honor/partner
function getCommentInfo() {
$.ajax({
url: "/console/v1/common",
method: "get",
headers: {
Authorization: "Bearer" + " " + localStorage.jwt,
},
success: function (res) {
if (!res || res.status !== 200 || !res.data) {
return;
}
var baseData = res.data || {};
$.ajax({
url: "/console/v1/theme/config",
method: "get",
headers: {
Authorization: "Bearer" + " " + localStorage.jwt,
},
success: function (pluginRes) {
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
var cfg = pluginRes.data || {};
if (cfg.honor) {
baseData.honor = cfg.honor;
}
if (cfg.partner) {
baseData.partner = cfg.partner;
}
}
sessionStorage.commentData = JSON.stringify(baseData);
setIndexData();
},
error: function () {
sessionStorage.commentData = JSON.stringify(baseData);
setIndexData();
},
});
},
});
}
// 获取首页数据
getCommentInfo();
// 设置首页函数
function setIndexData() {
const commentObj = JSON.parse(sessionStorage.commentData);
if (commentObj.honor.length > 0) {
const commentObj = window.__themeCommon
? window.__themeCommon
: (sessionStorage.commentData ? JSON.parse(sessionStorage.commentData) : {});
if (Array.isArray(commentObj.honor) && commentObj.honor.length > 0) {
commentObj.honor.forEach((item) => {
$("#honor-box").append(`
<div class="box-item">
@@ -77,14 +35,18 @@ $(function () {
`);
});
}
commentObj.partner.forEach((item) => {
$("#partner-box").append(`
<div class="box-item">
<img src="${item.img}" alt="">
<h4 class="mt-30">${item.name}</h4>
<p class="mt-20">${item.description}</p>
</div>
`);
});
}
if (Array.isArray(commentObj.partner)) {
commentObj.partner.forEach((item) => {
$("#partner-box").append(`
<div class="box-item">
<img src="${item.img}" alt="">
<h4 class="mt-30">${item.name}</h4>
<p class="mt-20">${item.description}</p>
</div>
`);
});
}
}
// 直接使用服务端注入的数据渲染关于页
setIndexData();
});

View File

@@ -1,7 +1,12 @@
$(function () {
const setIndexData = () => {
const commentObj = JSON.parse(sessionStorage.commentData);
commentObj.feedback_type.forEach((item, index) => {
const setIndexData = () => {
const commentObj = window.__themeCommon
? window.__themeCommon
: (sessionStorage.commentData ? JSON.parse(sessionStorage.commentData) : {});
const types = Array.isArray(commentObj.feedback_type)
? commentObj.feedback_type
: [];
types.forEach((item, index) => {
$("#radioBox").append(`
<div class="radio">
<input type="radio" name="radioId" id="ptionsRadios${index}" value=${item.id} />
@@ -65,43 +70,6 @@ $(function () {
input.attr("style", "border: 1px solid #E6EAED;");
return true;
}
// 获取通用配置信息(反馈页:用插件覆盖 feedback_type
function getCommentInfo() {
$.ajax({
url: "/console/v1/common",
method: "get",
headers: {
Authorization: "Bearer" + " " + localStorage.jwt,
},
success: function (res) {
if (!res || res.status !== 200 || !res.data) {
return;
}
var baseData = res.data || {};
$.ajax({
url: "/console/v1/theme/config",
method: "get",
headers: {
Authorization: "Bearer" + " " + localStorage.jwt,
},
success: function (pluginRes) {
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
var cfg = pluginRes.data || {};
if (cfg.feedback_type) {
baseData.feedback_type = cfg.feedback_type;
}
}
sessionStorage.commentData = JSON.stringify(baseData);
setIndexData();
},
error: function () {
sessionStorage.commentData = JSON.stringify(baseData);
setIndexData();
},
});
},
});
}
getCommentInfo();
// 反馈页直接使用服务端注入的反馈类型渲染单选项
setIndexData();
});

View File

@@ -106,13 +106,15 @@ $(function () {
}, 5000);
};
// 设置首页函数
// 设置首页函数:直接使用服务端注入的 window.__themeCommonSSR 数据),避免再次请求配置
function setIndexData() {
const commentObj = JSON.parse(sessionStorage.commentData);
const commentObj = window.__themeCommon
? window.__themeCommon
: (sessionStorage.commentData ? JSON.parse(sessionStorage.commentData) : {});
bannerData = commentObj.banner || [];
// 仅轮播文案
startBannerTextLoop();
if (commentObj.honor.length > 0) {
if (Array.isArray(commentObj.honor) && commentObj.honor.length > 0) {
commentObj.honor.forEach((item) => {
$("#certBox").append(`<div class="cert-item">
<img src=${item.img} alt="">
@@ -120,7 +122,7 @@ $(function () {
</div>`);
});
}
if (commentObj.partner.length > 0 && commentObj.partner.length <= 3) {
if (Array.isArray(commentObj.partner) && commentObj.partner.length > 0 && commentObj.partner.length <= 3) {
commentObj.partner.forEach((item) => {
$("#practiceBox").append(`<div class="practice-box">
<img src="${item.img}" alt="">
@@ -128,7 +130,7 @@ $(function () {
<p class="tr font-grey mt-20 font12">${item.name}</p>
</div>`);
});
} else if (commentObj.partner.length > 3) {
} else if (Array.isArray(commentObj.partner) && commentObj.partner.length > 3) {
const arr1 = commentObj.partner.slice(0, 3);
const arr2 = commentObj.partner.slice(3);
arr1.forEach((item) => {
@@ -146,56 +148,8 @@ $(function () {
});
}
}
// 获取通用配置信息(首页:先用 /console/v1/common再用插件配置覆盖后渲染荣誉/合作伙伴)
function getCommentInfo() {
$.ajax({
url: "/console/v1/common",
method: "get",
headers: {
Authorization: "Bearer" + " " + localStorage.jwt,
},
success: function (res) {
if (!res || res.status !== 200 || !res.data) {
return;
}
var baseData = res.data || {};
$.ajax({
url: "/console/v1/theme/config",
method: "get",
headers: {
Authorization: "Bearer" + " " + localStorage.jwt,
},
success: function (pluginRes) {
if (pluginRes && pluginRes.status === 200 && pluginRes.data) {
var cfg = pluginRes.data || {};
// 仅覆盖首页会用到的字段honor/partner/banner/friendly_link 等
if (cfg.honor) {
baseData.honor = cfg.honor;
}
if (cfg.partner) {
baseData.partner = cfg.partner;
}
if (cfg.banner) {
baseData.banner = cfg.banner;
}
if (cfg.friendly_link) {
baseData.friendly_link = cfg.friendly_link;
}
}
sessionStorage.commentData = JSON.stringify(baseData);
setIndexData();
},
error: function () {
sessionStorage.commentData = JSON.stringify(baseData);
setIndexData();
},
});
},
});
}
// 获取首页数据
getCommentInfo();
// 首页直接使用服务端注入的数据渲染SSR不再请求 /console/v1/common 或 /console/v1/theme/config
setIndexData();
var viewer = new Viewer(document.getElementById("viewer"), {
button: true,
inline: false,