import"./base-xgxQQEpV.js";import{E as l}from"./el-card-CfK866jr.js";import{E as p}from"./el-skeleton-item-CD5Idavp.js";import{g as d,i as _,u as m,j as u,p as i,s as f,o as g,k,t as b}from"./vendor-vue-WbiK4TmU.js";import{s as w}from"./auth-B5cl_nsV.js";import{b as h}from"./settings-Db4PmPGC.js";import{_ as S}from"./style-CEbARg1o.js";import{E as t}from"./http-BoPYlvwK.js";import"./vendor-axios-B9ygI19o.js";const v={class:"callback-wrap"},y={class:"callback-text"},E="zsglpt_social_settings_bind_token",x={__name:"SocialBindCallbackPage",setup(B){const a=m(),c=d("正在完成绑定");return _(async()=>{const o=new URLSearchParams(window.location.search||""),n=String(o.get("provider")||o.get("type")||"").trim(),s=String(o.get("code")||"").trim();if(!n||!s){t.error("快捷登录回调参数不完整"),a.replace("/app/accounts");return}try{const e=await w({provider:n,code:s,mode:"bind"});if(e?.success&&e?.bound){t.success("快捷登录已绑定"),a.replace("/app/accounts");return}if(!e?.bind_token){t.warning("未获取到绑定凭证"),a.replace("/app/accounts");return}try{await h({bind_token:e.bind_token}),t.success("快捷登录已绑定")}catch(r){if(r?.response?.status===401){window.sessionStorage.setItem(E,e.bind_token),t.info("请先登录后完成绑定"),a.replace("/login");return}throw r}a.replace("/app/accounts")}catch(e){const r=e?.response?.data;c.value=r?.error||"快捷登录绑定失败",t.error(c.value),a.replace("/app/accounts")}}),(o,n)=>{const s=p,e=l;return g(),u("div",v,[i(e,{shadow:"never",class:"callback-card"},{default:f(()=>[i(s,{rows:3,animated:""}),k("div",y,b(c.value),1)]),_:1})])}}},D=S(x,[["__scopeId","data-v-2c9ef71e"]]);export{D as default};
