view.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>E2E account</title>
  6. <style>
  7. :root {
  8. color-scheme: light dark;
  9. }
  10. body {
  11. margin: 0;
  12. padding: 16px;
  13. font:
  14. 13px/1.5 system-ui,
  15. sans-serif;
  16. color: var(--color-text-primary, #1f2328);
  17. background: var(--color-background-primary, transparent);
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <h1>E2E account</h1>
  23. <p id="status">ready</p>
  24. <script>
  25. // 页面只经 window.zcode(MCP App 页面层)调视图工具;E2E 在页面里直接调 callTool。
  26. // 注意:window.zcode 是不可配置的全局属性,经典脚本顶层不能再声明同名的 const / let。
  27. const host = window.zcode;
  28. host.subscribe(() => {
  29. const variables = host.hostContext?.styles?.variables ?? {};
  30. for (const [name, value] of Object.entries(variables)) {
  31. if (typeof value === "string") document.documentElement.style.setProperty(name, value);
  32. }
  33. });
  34. host.ready().then(() => {
  35. document.body.dataset.ready = "true";
  36. });
  37. </script>
  38. </body>
  39. </html>