mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-09-11 05:03:46 +08:00
2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
import{d as c,p as _,v as u,c as d,o as l,j as o,_ as g,C as y,G as m,a as v,w as x}from"./chunks/framework.abbEBnpT.js";function P(t){window.addEventListener("message",async s=>{var i;const e=s.data,a=e.namespace,p=e.action,r=(i=n==null?void 0:n[a])==null?void 0:i[p];if(r){const f=await r(e.payload);t.postMessage({params:e,result:f},"*")}})}const n={user:{getUserToken:({userId:t})=>"token:"+t}},b={class:"home"},h=c({__name:"Index",setup(t){const s=_(null);return u(()=>{s.value&&s.value.contentWindow&&P(s.value.contentWindow)}),(e,a)=>(l(),d("div",b,[a[0]||(a[0]=o("h2",null,"Home",-1)),o("iframe",{ref_key:"iframeRef",ref:s,src:"/demos/promiseify-post-message/inner",frameborder:"0"},null,512)]))}}),w=g(h,[["__scopeId","data-v-6e7a6b64"]]),M=JSON.parse('{"title":"Promiseify PostMessage","description":"","frontmatter":{"layout":"page","navbar":false,"sidebar":false,"aside":false,"footer":false},"headers":[],"relativePath":"demos/promiseify-post-message/index.md","filePath":"demos/promiseify-post-message/index.md","lastUpdated":1754111533000}'),C={name:"demos/promiseify-post-message/index.md"},B=Object.assign(C,{setup(t){return(s,e)=>{const a=y("ClientOnly");return l(),d("div",null,[e[0]||(e[0]=o("h1",{id:"promiseify-postmessage",tabindex:"-1"},[v("Promiseify PostMessage "),o("a",{class:"header-anchor",href:"#promiseify-postmessage","aria-label":'Permalink to "Promiseify PostMessage"'},"")],-1)),e[1]||(e[1]=o("p",null,"将 postMessage 消息通信 Promise 化",-1)),m(a,null,{default:x(()=>[m(w)]),_:1})])}}});export{M as __pageData,B as default};
|