修改样式
This commit is contained in:
+257
-9
@@ -165,8 +165,34 @@ const CommonUtil = {
|
||||
$('.topbar__ubadge, .uc-role').text(text);
|
||||
},
|
||||
|
||||
installTopbarUserCenterEntry() {
|
||||
if (typeof document === 'undefined') return;
|
||||
const $ = this.$;
|
||||
$('#loggedInBox').each((index, box) => {
|
||||
const $box = $(box);
|
||||
const $logout = $box.find('.topbar__btn--logout').first();
|
||||
let $actions = $box.find('.topbar__actions').first();
|
||||
if (!$actions.length) {
|
||||
$actions = $('<div>', { class: 'topbar__actions' });
|
||||
if ($logout.length) $actions.insertBefore($logout);
|
||||
else $box.append($actions);
|
||||
}
|
||||
if ($logout.length && !$logout.parent().is($actions)) {
|
||||
$logout.appendTo($actions);
|
||||
}
|
||||
if ($actions.find('.topbar__btn--center').length) return;
|
||||
const $entry = $('<a>', {
|
||||
href: 'usercenter.html',
|
||||
class: 'topbar__btn topbar__btn--center',
|
||||
text: '个人中心',
|
||||
});
|
||||
$actions.prepend($entry);
|
||||
});
|
||||
},
|
||||
|
||||
applyWebConfigs(configs) {
|
||||
const $ = this.$;
|
||||
this.ensureGlobalFooterLayout();
|
||||
if (!configs) return;
|
||||
|
||||
if (!Array.isArray(configs)) {
|
||||
@@ -185,7 +211,11 @@ const CommonUtil = {
|
||||
}));
|
||||
|
||||
const copyrightItems = [];
|
||||
const footerContactItems = [];
|
||||
configs.forEach((item) => {
|
||||
const isFooterContact = this.isFooterContactConfig(item);
|
||||
if (isFooterContact) footerContactItems.push(item);
|
||||
|
||||
if (item.type === 'web_title') {
|
||||
$('#page-title').text(item.content || '');
|
||||
if (item.content) document.title = item.content;
|
||||
@@ -195,12 +225,214 @@ const CommonUtil = {
|
||||
this.setMeta('description', item.content || '');
|
||||
} else if (item.type === 'web_icon') {
|
||||
this.setIcon(item.content || '');
|
||||
} else if (item.type === 'web_copyright') {
|
||||
} else if (item.type === 'web_copyright' && !isFooterContact) {
|
||||
copyrightItems.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
this.applyFooterCopyright(copyrightItems);
|
||||
this.renderFooterContact(footerContactItems);
|
||||
},
|
||||
|
||||
ensureGlobalFooterLayout() {
|
||||
if (typeof document === 'undefined') return;
|
||||
const $ = this.$;
|
||||
$('.site-footer__inner').each((index, footerInner) => {
|
||||
const $inner = $(footerInner);
|
||||
let $layout = $inner.find('.site-footer__layout').first();
|
||||
|
||||
if ($layout.length) {
|
||||
let $brand = $layout.find('.site-footer__brand').first();
|
||||
if (!$brand.length) {
|
||||
$brand = $('<div>', { class: 'site-footer__brand' }).prependTo($layout);
|
||||
}
|
||||
let $contact = $layout.find('.site-footer__contact').first();
|
||||
if (!$contact.length) {
|
||||
$contact = this.buildFooterContactShell($);
|
||||
$layout.append($contact);
|
||||
} else if (!$contact.find('.site-footer__qr-grid').length) {
|
||||
$contact.append($('<div>', { class: 'site-footer__qr-grid' }));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const $desc = $inner.find('#additional-info').first().detach();
|
||||
const $logo = $inner.find('.site-footer__logo').first().detach();
|
||||
const $meta = $inner.find('.site-footer__meta').first().detach();
|
||||
const $copyright = $inner.find('#copyright-info').first().detach();
|
||||
|
||||
const $brand = $('<div>', { class: 'site-footer__brand' });
|
||||
if ($logo.length) {
|
||||
$brand.append($logo);
|
||||
} else {
|
||||
$brand.append($('<img>', {
|
||||
src: '../images/home-logo.png',
|
||||
alt: '神彩算',
|
||||
class: 'site-footer__logo',
|
||||
}));
|
||||
}
|
||||
|
||||
const $legal = $meta.length
|
||||
? $meta.addClass('site-footer__legal')
|
||||
: $('<div>', { class: 'site-footer__legal site-footer__meta' });
|
||||
$brand.append($legal);
|
||||
|
||||
if ($copyright.length) {
|
||||
$brand.append($copyright.addClass('site-footer__copyright'));
|
||||
} else {
|
||||
$brand.append($('<p>', {
|
||||
id: 'copyright-info',
|
||||
class: 'site-footer__copyright',
|
||||
text: '© 2014-2026 神彩算 版权所有',
|
||||
}));
|
||||
}
|
||||
|
||||
if ($desc.length) {
|
||||
$brand.append($desc.addClass('site-footer__desc'));
|
||||
} else {
|
||||
$brand.append($('<p>', {
|
||||
id: 'additional-info',
|
||||
class: 'site-footer__desc',
|
||||
text: '本站内容仅供数据分析参考,不构成任何投注建议',
|
||||
}));
|
||||
}
|
||||
|
||||
$layout = $('<div>', { class: 'site-footer__layout' });
|
||||
$layout.append($brand);
|
||||
$layout.append(this.buildFooterContactShell($));
|
||||
$inner.empty().append($layout);
|
||||
});
|
||||
},
|
||||
|
||||
buildFooterContactShell($) {
|
||||
return $('<div>', { class: 'site-footer__contact' })
|
||||
.append(
|
||||
$('<div>', { class: 'site-footer__contact-head' })
|
||||
.append($('<span>', { class: 'site-footer__contact-kicker', text: 'Contact' }))
|
||||
.append($('<strong>', { text: '联系客服' }))
|
||||
.append($('<span>', { text: '微信 / QQ 扫码咨询' }))
|
||||
)
|
||||
.append(
|
||||
$('<div>', { class: 'site-footer__qr-grid' })
|
||||
.append(
|
||||
$('<div>', { class: 'site-footer__qr-card' })
|
||||
.append($('<img>', { src: '../public/img/kfwx.jpg', alt: '客服微信二维码' }))
|
||||
.append($('<span>', { text: '客服微信' }))
|
||||
)
|
||||
.append(
|
||||
$('<div>', { class: 'site-footer__qr-card' })
|
||||
.append($('<img>', { src: '../public/img/kfqq.jpg', alt: '客服QQ二维码' }))
|
||||
.append($('<span>', { text: '客服QQ' }))
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
isFooterContactConfig(item) {
|
||||
if (!item) return false;
|
||||
const text = [
|
||||
item.type,
|
||||
item.title,
|
||||
item.name,
|
||||
item.label,
|
||||
item.remark,
|
||||
item.content,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
return /(客服|联系|微信|QQ|wechat|weixin|wx|qq|qrcode|qr|二维码)/i.test(text) &&
|
||||
Boolean(this.extractFooterImageUrl(item));
|
||||
},
|
||||
|
||||
extractFooterImageUrl(item) {
|
||||
if (!item) return '';
|
||||
const fields = [
|
||||
'content',
|
||||
'url',
|
||||
'image',
|
||||
'img',
|
||||
'src',
|
||||
'qrCode',
|
||||
'qrcode',
|
||||
'qrCodeUrl',
|
||||
'qrcodeUrl',
|
||||
'wechatQr',
|
||||
'wechatQrcode',
|
||||
'wechatQrCode',
|
||||
'wechatQrCodeUrl',
|
||||
'qqQr',
|
||||
'qqQrcode',
|
||||
'qqQrCode',
|
||||
'qqQrCodeUrl',
|
||||
'ossUrl',
|
||||
'fileUrl',
|
||||
];
|
||||
const values = [];
|
||||
fields.forEach((field) => {
|
||||
if (item[field]) values.push(item[field]);
|
||||
});
|
||||
|
||||
if (typeof item.content === 'string' && item.content.trim().charAt(0) === '{') {
|
||||
try {
|
||||
const parsed = JSON.parse(item.content);
|
||||
fields.forEach((field) => {
|
||||
if (parsed && parsed[field]) values.push(parsed[field]);
|
||||
});
|
||||
} catch (error) {
|
||||
// Non-JSON content is valid for plain image URLs.
|
||||
}
|
||||
}
|
||||
|
||||
return values
|
||||
.map((value) => String(value || '').trim())
|
||||
.find((value) => /^(https?:)?\/\//i.test(value) || /^data:image\//i.test(value) || /\.(png|jpe?g|webp|gif|svg)(\?.*)?$/i.test(value)) || '';
|
||||
},
|
||||
|
||||
renderFooterContact(items) {
|
||||
const $ = this.$;
|
||||
const $contact = $('.site-footer__contact');
|
||||
if (!$contact.length) return;
|
||||
|
||||
const qrItems = [];
|
||||
(Array.isArray(items) ? items : []).forEach((item) => {
|
||||
const src = this.extractFooterImageUrl(item);
|
||||
if (!src) return;
|
||||
const text = [item.type, item.title, item.name, item.label, item.remark, item.content].filter(Boolean).join(' ');
|
||||
const isQQ = /QQ|qq/.test(text);
|
||||
const isWechat = /微信|wechat|weixin|wx/i.test(text);
|
||||
qrItems.push({
|
||||
src,
|
||||
title: isQQ ? '客服QQ' : isWechat ? '客服微信' : '客服二维码',
|
||||
});
|
||||
});
|
||||
|
||||
const uniqueItems = qrItems
|
||||
.filter((item, index, array) => array.findIndex((target) => target.src === item.src) === index)
|
||||
.sort((a, b) => (a.title === '客服微信' ? -1 : 0) - (b.title === '客服微信' ? -1 : 0));
|
||||
const displayItems = uniqueItems.length
|
||||
? uniqueItems.slice(0, 2)
|
||||
: [
|
||||
{
|
||||
src: '../public/img/kfwx.jpg',
|
||||
title: '客服微信',
|
||||
},
|
||||
{
|
||||
src: '../public/img/kfqq.jpg',
|
||||
title: '客服QQ',
|
||||
},
|
||||
];
|
||||
|
||||
const $grid = $contact.find('.site-footer__qr-grid');
|
||||
if (!$grid.length) return;
|
||||
$grid.empty();
|
||||
|
||||
displayItems.forEach((item) => {
|
||||
$('<div>', { class: 'site-footer__qr-card' })
|
||||
.append($('<img>', { src: item.src, alt: item.title + '二维码' }))
|
||||
.append($('<span>', { text: item.title }))
|
||||
.appendTo($grid);
|
||||
});
|
||||
|
||||
$contact.removeClass('is-empty');
|
||||
},
|
||||
|
||||
applyFooterCopyright(items) {
|
||||
@@ -212,15 +444,20 @@ const CommonUtil = {
|
||||
.sort((a, b) => (Number(a.sort) || 0) - (Number(b.sort) || 0));
|
||||
if (!list.length) return;
|
||||
|
||||
const footerInfo = list.find((item) => Number(item.sort) === 3) || list[list.length - 1];
|
||||
if (footerInfo?.content) $('#copyright-info').text(footerInfo.content.trim());
|
||||
const copyrightItem = list.find((item) => /©|版权|copyright/i.test(String(item.content || ''))) || null;
|
||||
const descItem =
|
||||
list.find((item) => /本站|历史数据|数据分析|投注建议|不涉及|仅供/i.test(String(item.content || ''))) ||
|
||||
list.find((item) => item !== copyrightItem && !/ICP备|工信部|公网安备|公安/.test(String(item.content || ''))) ||
|
||||
null;
|
||||
|
||||
const $meta = $('.site-footer__meta');
|
||||
if (copyrightItem?.content) $('#copyright-info').text(copyrightItem.content.trim());
|
||||
if (descItem?.content) $('#additional-info').text(descItem.content.trim());
|
||||
|
||||
const $meta = $('.site-footer__legal, .site-footer__meta').first();
|
||||
if (!$meta.length) return;
|
||||
|
||||
$meta.empty();
|
||||
list
|
||||
.filter((item) => item !== footerInfo)
|
||||
.forEach((item) => {
|
||||
const content = String(item.content || '').trim();
|
||||
if (!content) return;
|
||||
@@ -231,20 +468,21 @@ const CommonUtil = {
|
||||
id: 'beian',
|
||||
href: 'https://beian.miit.gov.cn/',
|
||||
target: '_blank',
|
||||
class: 'index-style-02',
|
||||
text: content,
|
||||
}).appendTo($meta);
|
||||
} else {
|
||||
} else if (isPolice) {
|
||||
$('<span>', {
|
||||
id: isPolice ? 'police-record' : undefined,
|
||||
id: 'police-record',
|
||||
text: content,
|
||||
}).appendTo($meta);
|
||||
}
|
||||
});
|
||||
|
||||
if (!$meta.children().length && footerInfo?.content) {
|
||||
if (!$meta.children().length && descItem?.content) {
|
||||
$('<span>', {
|
||||
id: 'additional-info',
|
||||
text: footerInfo.content.trim(),
|
||||
text: descItem.content.trim(),
|
||||
}).appendTo($meta);
|
||||
}
|
||||
},
|
||||
@@ -296,6 +534,7 @@ const CommonUtil = {
|
||||
loadPageConfig(options = {}) {
|
||||
if (typeof ApiClient === 'undefined') return;
|
||||
this.installUnifiedPagination();
|
||||
this.ensureGlobalFooterLayout();
|
||||
this.installWechatLoginEntry();
|
||||
this.installWechatAccountBindEntry();
|
||||
const loadHomeData = options.home !== false && this.isHomePageDom();
|
||||
@@ -1532,4 +1771,13 @@ if (typeof module !== 'undefined' && module.exports) {
|
||||
} else if (typeof window !== 'undefined') {
|
||||
window.CommonUtil = CommonUtil;
|
||||
CommonUtil.installUnifiedPagination();
|
||||
const installTopbarUserCenterEntry = () => CommonUtil.installTopbarUserCenterEntry();
|
||||
const ensureGlobalFooterLayout = () => CommonUtil.ensureGlobalFooterLayout();
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', installTopbarUserCenterEntry);
|
||||
document.addEventListener('DOMContentLoaded', ensureGlobalFooterLayout);
|
||||
} else {
|
||||
installTopbarUserCenterEntry();
|
||||
ensureGlobalFooterLayout();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user