mirror of
https://github.com/vastxie/99AI.git
synced 2025-09-23 03:56:38 +08:00
2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
import{g as k,K as E,aQ as b,r as B,k as c,ak as I,w as L,L as S,cx as C,m as F,F as h,aA as f,G as r,Z as D,cy as A,E as g,cz as M}from"./index-2efe4620.js";const W={class:"w-full h-full relative"},G={class:"loading"},N=M('<span class="loading-text-words">内</span><span class="loading-text-words">容</span><span class="loading-text-words">正</span><span class="loading-text-words">在</span><span class="loading-text-words">加</span><span class="loading-text-words">载</span><span class="loading-text-words">中</span>',7),T=[N],U=["src"],j=k({__name:"index",setup(V){const _=E(),l=b(),n=B(!1),i=c(()=>l.iframeUrl),o=I(),u=c(()=>o.theme==="dark");function v(){const e=document.getElementById("iframe");e!=null&&e.addEventListener||e==null||e.attachEvent("onload",d),e==null||e.addEventListener("load",d,!0)}const m=c(()=>o.theme);L(m,e=>{s({type:"theme",data:e})}),S(()=>{if(!i.value)return _.push("/");n.value=!0,v(),window.addEventListener("message",p)});async function p(e){const{type:t,data:a}=e.data;t==="theme"&&o.setTheme(a==="dark"?"dark":"light"),t==="chat"&&w(a)}function w(e){C({prompt:e}).then(t=>{const{code:a,data:y}=t;a===200&&s({type:"chat",data:x(y)})})}function x(e){const t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e.replace(t,"")}function s(e){document.getElementById("iframe").contentWindow.postMessage(e,"*")}function d(){s({type:"theme",data:m.value});const e=A();e&&s({type:"token",data:e}),n.value=!1}return F(()=>{l.updateIframeUrl("");const e=document.getElementById("iframe");e==null||e.removeEventListener("load",d),window.removeEventListener("message",p)}),(e,t)=>(g(),h("div",W,[n.value?(g(),h("div",{key:0,class:f(["main-container absolute left-0 right-0 bottom-0 top-0 backdrop-blur",[u.value?"dark:bg-black/20":"bg-white/80"]])},[r("div",G,[r("div",{class:f(["loading-text ",u.value?"text-[#fff]":"text-[#000]"]),id:"loading-text"},T,2)])],2)):D("",!0),r("iframe",{id:"iframe",src:i.value,style:{width:"100%",height:"100%",border:"none"}},null,8,U)]))}});export{j as default};
|