import{n as f,m as _,d as g,_ as h}from"./index-e5cf7f43.js";import{i as w,j as p}from"./user-fa22762f.js";import{d as L,e as i,r as v,f as y,w as P,S as C,a2 as x,R as b}from"./vue-c19408e5.js";import{_ as A}from"./_plugin-vue_export-helper-c27b6911.js";import"./naive-ui-64ac446a.js";import"./vueuse-motion-563da5fd.js";const R={class:"iframe-container"},S=L({__name:"index",setup(k){const n=f();_();const a=g(),r=i(()=>a.isLogin);i(()=>{var o;return Number((o=a.globalConfig)==null?void 0:o.wechatSilentLoginStatus)===1});const s=v(null);async function u(){const t=new URLSearchParams(window.location.search).getAll("code");if(!(t.length>0?t[t.length-1]:null)){const c=window.location.href.split("#")[0],l=await p({url:c});l.success&&(window.location.href=l.data)}}async function d(){const t=new URLSearchParams(window.location.search).getAll("code"),e=t.length>0?t[t.length-1]:null;if(e){const c=await w({code:e});c.success&&(a.setToken(c.data),await a.getUserInfo(),a.setLoginDialog(!1),n.replace("/chat"))}}async function m(){window.navigator.userAgent.toLowerCase().includes("micromessenger")&&await u()}return y(async()=>{var t;if(r.value){n.replace("/chat");return}let o=i(()=>{var e;return((e=a.globalConfig)==null?void 0:e.homeHtml)||""});if(o=i(()=>{var e;return`
    ${((e=a.globalConfig)==null?void 0:e.homeHtml)||""}
  `}),s.value){const e=s.value.contentDocument||((t=s.value.contentWindow)==null?void 0:t.document);e&&(e.open(),e.write(o.value),e.close())}h(()=>import("./chat-f5a1bdb4.js"),["./chat-f5a1bdb4.js","./useBasicLayout-18dd2ca5.js","./vue-c19408e5.js","./index-e5cf7f43.js","./naive-ui-64ac446a.js","./vueuse-motion-563da5fd.js","./index-e4921c26.css","./Right-153af9c5.js","./_plugin-vue_export-helper-c27b6911.js","./chat-07fbf5d6.css"],import.meta.url),window.addEventListener("message",async e=>{e.data==="goToChat"&&(await d(),n.replace("/chat")),e.data==="goToLogin"&&a.setLoginDialog(!0)}),await m()}),P(r,o=>{o&&n.replace("/chat")}),(o,t)=>(b(),C("div",R,[x("iframe",{ref_key:"iframe",ref:s,class:"iframe",frameborder:"0"},null,512)]))}});const W=A(S,[["__scopeId","data-v-bc827095"]]);export{W as default};
