314507
|
1 |
import{aV as L,d as D,a0 as F,u as J,r as V,A as x,ad as K,a as r,w as N,P,ae as R,o as p,c as m,k as n,B as i,C as w,O as k,F as X,i as j,g as E,D as G,aW as I,K as H,L as M,an as Q,aX as Y,S as Z,V as $,W as ee}from"./index-BP6bNRoi.js";import{u as se,L as C,_ as ae}from"./LoginFormTitle.vue_vue_type_script_setup_true_lang-BdHKqTBo.js";const te={class:"form-cont"},oe=w("br",null,null,-1),le=w("br",null,null,-1),re={key:0},ne={key:1},ie=D({name:"SSOLogin",__name:"SSOLogin",setup(ce){const c=F(),{currentRoute:U}=J(),{getLoginState:T,setLoginState:z}=se(),O=V({name:"",logo:""}),s=x({responseType:"",clientId:"",redirectUri:"",state:"",scopes:[]}),A=K(()=>r(T)===C.SSO),u=x({scopes:[]}),d=V(!1),W=async()=>{if(c.query.client_id===void 0)return;if(s.responseType=c.query.response_type,s.clientId=c.query.client_id,s.redirectUri=c.query.redirect_uri,s.state=c.query.state,c.query.scope&&(s.scopes=c.query.scope.split(" ")),s.scopes.length>0){const e=await q(!0,s.scopes,[]);if(e)return void(location.href=e)}const t=await(a=s.clientId,L.get({url:"/system/oauth2/authorize?clientId="+a}));var a;let o;if(O.value=t.client,s.scopes.length>0){o=[];for(const e of t.scopes)s.scopes.indexOf(e.key)>=0&&o.push(e)}else{o=t.scopes;for(const e of o)s.scopes.push(e.key)}for(const e of o)e.value&&u.scopes.push(e.key)},b=async t=>{let a,o;t?(a=u.scopes,o=s.scopes.filter(e=>a.indexOf(e)===-1)):(a=[],o=s.scopes),d.value=!0;try{const e=await q(!1,a,o);if(!e)return;location.href=e}finally{d.value=!1}},q=(t,a,o)=>((e,_,g,f,y,h,l)=>{const v={};for(const S of h)v[S]=!0;for(const S of l)v[S]=!1;return L.post({url:"/system/oauth2/authorize",headers:{"Content-type":"application/x-www-form-urlencoded"},params:{response_type:e,client_id:_,redirect_uri:g,state:f,auto_approve:y,scope:JSON.stringify(v)}})})(s.responseType,s.clientId,s.redirectUri,s.state,t,a,o),B=t=>{switch(t){case"user.read":return"\u8BBF\u95EE\u4F60\u7684\u4E2A\u4EBA\u4FE1\u606F";case"user.write":return"\u4FEE\u6539\u4F60\u7684\u4E2A\u4EBA\u4FE1\u606F";default:return t}};return N(()=>U.value,t=>{t.name==="SSOLogin"&&(z(C.SSO),W())},{immediate:!0}),(t,a)=>{const o=H,e=M,_=Q,g=Y,f=Z,y=$,h=ee;return P((p(),m("div",te,[n(ae,{style:{width:"100%"}}),n(e,{class:"form",style:{float:"none"},value:"uname"},{default:i(()=>[n(o,{label:r(O).name,name:"uname"},null,8,["label"])]),_:1}),w("div",null,[n(h,{model:r(u),class:"login-form"},{default:i(()=>[k(" \u6B64\u7B2C\u4E09\u65B9\u5E94\u7528\u8BF7\u6C42\u83B7\u5F97\u4EE5\u4E0B\u6743\u9650\uFF1A "),oe,le,n(f,{prop:"scopes"},{default:i(()=>[n(g,{modelValue:r(u).scopes,"onUpdate:modelValue":a[0]||(a[0]=l=>r(u).scopes=l)},{default:i(()=>[(p(!0),m(X,null,j(r(s).scopes,l=>(p(),E(_,{key:l,label:l,style:{display:"block","margin-bottom":"-10px"}},{default:i(()=>[k(G(B(l)),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1}),n(f,{class:"w-1/1"},{default:i(()=>[n(y,{loading:r(d),class:"w-6/10",type:"primary",onClick:a[1]||(a[1]=I(l=>b(!0),["prevent"]))},{default:i(()=>[r(d)?(p(),m("span",ne,"\u6388 \u6743 \u4E2D...")):(p(),m("span",re,"\u540C\u610F\u6388\u6743"))]),_:1},8,["loading"]),n(y,{class:"w-3/10",onClick:a[2]||(a[2]=I(l=>b(!1),["prevent"]))},{default:i(()=>[k("\u62D2\u7EDD")]),_:1})]),_:1})]),_:1},8,["model"])])],512)),[[R,r(A)]])}}});export{ie as default}; |