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
@model ScenarioViewModel
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>@Model.DocumentTitle</title>
  <link rel="stylesheet" href="@Model.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">@Html.Raw(Model.SlidesJson)</script>
  <script>
    (function () {
      const SCENARIO_NAME = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.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 = @Model.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 = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(new {
        scenarioId = Model.ScenarioId,
        scenarioName = Model.ScenarioName,
        image = Model.ScenarioImage
      }));
      const cur = readRecent().filter((x) => x.scenarioId !== entry.scenarioId);
      cur.unshift(entry);
      writeRecent(cur);
    })();
  </script>
</body>
</html>