debug
This commit is contained in:
@@ -8,12 +8,29 @@ const popupDataAll = [
|
||||
template: 'videoDadi',
|
||||
},
|
||||
];
|
||||
|
||||
//data
|
||||
const popupData = [
|
||||
{
|
||||
image: 'https://www.test.com/img/video/2025/05/24/13/rou-pu-tuan-zhi-ji-le-bao-jian.webp',
|
||||
title: '3D肉蒲团之极乐宝鉴',// 3d
|
||||
link: 'https://test.com/vod/rou-pu-tuan-zhi-ji-le-bao-jian-106422',
|
||||
image: '/static/img/s-a.png',
|
||||
title: '111;',// 3d
|
||||
link: 'https://test.shop',
|
||||
template: 'videoNuNu',
|
||||
},
|
||||
];
|
||||
const bannerData = [
|
||||
{
|
||||
image: '/static/img/b-a.png',
|
||||
title: '111;',// 3d
|
||||
link: 'https://test.shop',
|
||||
template: 'videoNuNu',
|
||||
},
|
||||
];
|
||||
const topData = [
|
||||
{
|
||||
image: '/static/img/top-a.png',
|
||||
title: '111;',// 3d
|
||||
link: 'https://test.shop',
|
||||
template: 'videoNuNu',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -223,6 +223,12 @@ const strCsHtmlTop = `
|
||||
<h3>{{title}}</h3>
|
||||
</a>
|
||||
`
|
||||
|
||||
const strCsHtmlBanner = `
|
||||
<a href="{{link}}">
|
||||
<img src="{{image}}" style="width:100%; cursor:pointer;display: block;">
|
||||
</a>
|
||||
`
|
||||
function replaceList() {
|
||||
strCsHtml = '';
|
||||
switch (strTemplate) {
|
||||
@@ -263,7 +269,7 @@ function replaceList() {
|
||||
let items = list.querySelectorAll('li');
|
||||
if (items.length > 0) {
|
||||
let randomIndex = Math.floor(Math.random() * items.length);
|
||||
let oldItem = items[randomIndex];
|
||||
let oldItem = items[0];
|
||||
let oldClass = oldItem.className;
|
||||
|
||||
// 创建新元素容器
|
||||
@@ -284,11 +290,43 @@ function replaceList() {
|
||||
|
||||
// top
|
||||
const firstItem = document.querySelector('.movie-tuijian-list > .movei-tuijian-item');
|
||||
if (firstItem && popupData.length > 0) {
|
||||
const randomIndex = Math.floor(Math.random() * popupData.length);
|
||||
const CsData = popupData[randomIndex]
|
||||
firstItem.href = CsData.link;
|
||||
if (firstItem && topData.length > 0) {
|
||||
const randomIndex = Math.floor(Math.random() * topData.length);
|
||||
const CsData = topData[randomIndex];
|
||||
// 1)修改 a 标签链接
|
||||
firstItem.href = CsData.link;
|
||||
// 2)修改封面图(video-cover)
|
||||
const coverImg = firstItem.querySelector('.video-cover');
|
||||
if (coverImg) {
|
||||
if (CsData.image) {
|
||||
coverImg.dataset.src = CsData.image; // lazyload 地址
|
||||
coverImg.src = CsData.image; // 确保立即显示
|
||||
}
|
||||
}
|
||||
// 3)修改标题 <h3>
|
||||
const titleEl = firstItem.querySelector('h3');
|
||||
if (titleEl && CsData.title) {
|
||||
titleEl.textContent = CsData.title;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// banner
|
||||
let listbs = document.querySelectorAll('.cs-list-b');
|
||||
listbs.forEach(item => {
|
||||
const randomIndex = Math.floor(Math.random() * bannerData.length);
|
||||
const CsData = bannerData[randomIndex]
|
||||
|
||||
// 替换模板中的占位符
|
||||
const renderedTemplate = strCsHtmlBanner
|
||||
.replace(/{{image}}/g, CsData.image)
|
||||
.replace(/{{title}}/g, escapeHtml(decodeHtmlEntities(CsData.title))) // 防止XSS
|
||||
.replace(/{{link}}/g, escapeHtml(CsData.link));
|
||||
|
||||
item.innerHTML = renderedTemplate.trim();
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function shouldTrigger(probability = 0.5) {
|
||||
|
||||
BIN
code/public/static/img/b-a.png
Normal file
BIN
code/public/static/img/b-a.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
BIN
code/public/static/img/s-a.png
Normal file
BIN
code/public/static/img/s-a.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
code/public/static/img/top-a.png
Normal file
BIN
code/public/static/img/top-a.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
Reference in New Issue
Block a user