<!DOCTYPE html>
|
<html lang="zh-CN">
|
<head>
|
<meta charset="UTF-8" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<title><%= documentTitle %></title>
|
<link rel="stylesheet" href="<%= basePath %>/static/style.css" />
|
</head>
|
<body class="page-view page-view--carousel">
|
<iframe
|
id="boardCarouselFrame"
|
class="embed embed-full"
|
src="about:blank"
|
title=""
|
></iframe>
|
<script type="application/json" id="boardCarouselSlides"><%- slidesJson %></script>
|
<script>
|
(function () {
|
const SCENARIO_NAME = <%- JSON.stringify(scenarioName) %>;
|
const slidesEl = document.getElementById("boardCarouselSlides");
|
let slides = [];
|
try {
|
slides = JSON.parse(slidesEl ? slidesEl.textContent : "[]");
|
} catch {
|
slides = [];
|
}
|
if (!Array.isArray(slides) || !slides.length) {
|
document.body.classList.add("page-view--empty");
|
document.getElementById("boardCarouselFrame").style.display = "none";
|
const p = document.createElement("p");
|
p.className = "view-empty-hint";
|
p.textContent = "该场景下没有可轮播的页面,请在 config/scenarios.config.json 中配置 pages。";
|
document.body.appendChild(p);
|
return;
|
}
|
|
const frame = document.getElementById("boardCarouselFrame");
|
const START = <%= startIndex %>;
|
const i0 = Math.min(START, Math.max(0, slides.length - 1));
|
const s0 = slides[i0];
|
|
if (slides.length === 1) {
|
frame.src = s0.boardUrl;
|
frame.title = s0.title;
|
document.title = s0.title + " — " + SCENARIO_NAME;
|
return;
|
}
|
|
let t = 0;
|
function showAt(i) {
|
const s = slides[i];
|
frame.src = s.boardUrl;
|
frame.title = s.title;
|
document.title = s.title + " — " + SCENARIO_NAME;
|
const sec = Math.max(1, Number(s.staytime) || 30);
|
if (t) {
|
clearTimeout(t);
|
}
|
t = setTimeout(function () {
|
showAt((i + 1) % slides.length);
|
}, sec * 1000);
|
}
|
showAt(i0);
|
})();
|
</script>
|
<script>
|
(function () {
|
const LS_KEY = "board_recent_v2";
|
const MAX = 5;
|
function readRecent() {
|
try {
|
const raw = localStorage.getItem(LS_KEY);
|
const arr = raw ? JSON.parse(raw) : [];
|
return Array.isArray(arr) ? arr : [];
|
} catch {
|
return [];
|
}
|
}
|
function writeRecent(items) {
|
localStorage.setItem(LS_KEY, JSON.stringify(items.slice(0, MAX)));
|
}
|
const entry = <%- JSON.stringify({
|
scenarioId,
|
scenarioName,
|
image: scenarioImage,
|
}) %>;
|
const cur = readRecent().filter(
|
(x) => x.scenarioId !== entry.scenarioId
|
);
|
cur.unshift(entry);
|
writeRecent(cur);
|
})();
|
</script>
|
</body>
|
</html>
|