基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-05-03 5852890ac7c6925af4edd70398790d96f8b44284
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
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>WebView Bridge Test</title>
  <style>
    html, body {
      margin: 0;
      width: 100%;
      height: 100%;
      background: transparent;
      color: #f4f7fb;
      font: 14px/1.4 "Segoe UI", sans-serif;
    }
 
    body {
      display: grid;
      place-items: center;
      background: rgba(24, 31, 42, 0.78);
    }
 
    main {
      padding: 16px;
    }
  </style>
</head>
<body>
  <main>
    <strong id="status">Initializing bridge...</strong>
    <div id="details"></div>
  </main>
  <script>
    (async () => {
      const status = document.getElementById("status");
      const details = document.getElementById("details");
      try {
        const runtime = await window.moliDesktop.getRuntimeInfo();
        status.textContent = "Bridge ready";
        details.textContent = `${runtime.pluginId} / ${runtime.hostId}`;
      } catch (error) {
        status.textContent = "Bridge failed";
        details.textContent = error && error.message ? error.message : String(error);
      }
    })();
  </script>
</body>
</html>