This commit is contained in:
74
js/about.js
74
js/about.js
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user