rewards-website-fixture.ts 1.2 KB

123456789101112131415161718192021222324
  1. // 仅模拟网页对公开 bridge 的消费;不创建 bridge、不伪造 App 鉴权状态。
  2. export const rewardsWebsiteFixture = `<!doctype html>
  3. <html><head><meta charset="utf-8"><title>Rewards bridge fixture</title>
  4. <style>body{margin:0;font-family:sans-serif}main{min-height:2400px;padding:24px;box-sizing:border-box}html[data-theme="dark"]{background:#151515;color:white}</style>
  5. </head><body><main data-embedded="app" data-app-auth="pending"><h1>Rewards bridge fixture</h1><p>Isolated protocol consumer, not production rewards data.</p></main>
  6. <script>
  7. function sync() {
  8. const bridge = window.zcodeBridge;
  9. if (!bridge) return;
  10. const root = document.querySelector('main');
  11. const theme = bridge.getTheme() === 'zai-dark' ? 'dark' : 'light';
  12. root.dataset.theme = theme;
  13. document.documentElement.dataset.theme = theme;
  14. root.dataset.appAuth = bridge.getAuthState()?.status || 'pending';
  15. const lang = bridge.getLang();
  16. if (lang) {
  17. const url = new URL(location.href);
  18. url.pathname = '/' + (lang === 'zh-CN' ? 'cn' : 'en') + '/rewards';
  19. history.replaceState(null, '', url);
  20. }
  21. }
  22. window.addEventListener('zcode-rewards-context', sync);
  23. sync();
  24. </script></body></html>`;