wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!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>