diff --git a/assets/js/front-submit.js b/assets/js/front-submit.js index b9888544..0cb34d25 100644 --- a/assets/js/front-submit.js +++ b/assets/js/front-submit.js @@ -436,10 +436,21 @@ if (t === 'image' && d.url) { html = ''; } else if (t === 'slide' && Array.isArray(d) && d[0] && d[0].url) { + // 与参考主题一致:幻灯片封面渲染真实 swiper,由 auto_fun 里的 new_swiper 初始化。 + var slideImgs = d + .filter(function (item) { return item && item.url; }) + .map(function (item) { + return '
'; + }) + .join(''); html = - ''; + '
' + + '
' + slideImgs + '
' + + '
' + + '
' + + '
' + + '
' + + ''; } else if (t === 'video') { html = '
- +
+
+ + +
+ + +
+
+
+
+
{ + const featured = read('templates/parts/submit/featured.php'); + const js = read('assets/js/front-submit.js'); + + const swiperContract = + /new-swiper scale-height" data-loop="true" data-autoplay="true" data-interval="2000" style="--scale-height:50%;"/; + assert.match(featured, swiperContract); + assert.match(js, swiperContract); + + // Server-rendered slides iterate the saved attachment list. + assert.match(featured, /foreach \(\$data as \$slide\) : \?>/); + assert.match(featured, /
new_swiper) must run for slide covers too. + assert.match(js, /'
<\/div>'/); + assert.match(js, /t === 'video' \|\| t === 'slide'/); + + for (const control of ['swiper-wrapper', 'swiper-button-prev', 'swiper-button-next', 'swiper-pagination']) { + assert.match(featured, new RegExp(`class="${control}"`)); + assert.match(js, new RegExp(`class="${control}"`)); + } + + // The static first-image slide preview is gone. + assert.doesNotMatch(js, /escapeHtml\(d\[0\]\.url\)/); +}); + test('submit.css mirrors the reference visibility matrix for the buttons row', () => { const css = read('assets/css/frontend/pages/submit.css');