index-DXn6b1dn.js 12 KB

12
  1. const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dingtalkQrCode-DvFxdRVt.js","./logo_dingtalk-CyDPr22R.js","./chat-Bi4P_Zr8.js","./chat-CPrMbCji.css","./dingtalkQrCode-CulsC8mV.css","./larkQrCode-DAs5P3J0.js","./logo_lark-DULIW3z6.js","./wecomQrCode-AOgnQ99x.js","./wecomQrCode-COlSb1E9.css"])))=>i.map(i=>d[i]);
  2. import{cR as Y,gV as F,gT as se,gS as X,fV as k,ft as s,cr as g,h2 as de,g$ as p,cx as w,cw as le,gx as S,fM as d,gs as x,fr as ne,fa as pe,D as me,ac as re,ct as C,cq as i,fT as _e,fS as ce,fX as fe,cP as ve,cs as $,F as G,ab as H,gP as ge,fm as J,fW as he,h0 as ye,gN as b,ef as oe,h1 as we,ff as ke,ca as Ce,bX as ae,w as be,eS as xe,x as Le}from"./chat-Bi4P_Zr8.js";import{_ as Ae,a as $e,d as De}from"./index-bPA-K_7_.js";import{f as W}from"./index-DvMccYap.js";const Oe=Y({__name:"password",setup(V){const h=d(),{chatUser:I}=F(),t=d(!1),T=se(),U=X(),P=()=>I.passwordAuthentication(f.value.password).then(O=>{T.push({name:"chat",params:{accessToken:I.accessToken},query:U.query})}),D=(O,L,o)=>{L===""?o(new Error(x("chat.passwordValidator.errorMessage1"))):P().catch(()=>{o(new Error(x("chat.passwordValidator.errorMessage2")))})},R=()=>{h.value.validate()},u={password:[{required:!0,validator:D,trigger:"manual"}]},f=d({password:""});return(O,L)=>{const o=k("el-input"),B=k("el-form-item"),z=k("el-button"),Q=k("el-form");return s(),g(Q,{ref_key:"FormRef",ref:h,model:f.value,onSubmit:de(R,["prevent"])},{default:p(()=>[w(B,{prop:"value",rules:u.password},{default:p(()=>[w(o,{"show-password":"",modelValue:f.value.password,"onUpdate:modelValue":L[0]||(L[0]=M=>f.value.password=M)},null,8,["modelValue"])]),_:1},8,["rules"]),w(z,{class:"w-full mt-8",type:"primary",onClick:R,loading:t.value},{default:p(()=>[le(S(O.$t("common.confirm")),1)]),_:1},8,["loading"])]),_:1},8,["model"])}}}),qe=768,Ve=()=>{const{common:V}=F(),h=()=>(document.body?.getBoundingClientRect()).width-1<qe;ne(()=>{pe(()=>{h()&&V.toggleDevice(me.Mobile)})})},Ie={},Pe={class:"login-warp flex-center"},Re={class:"login-container w-full h-full"},Se={class:"flex-center w-full h-full"};function Te(V,h){return s(),C("div",Pe,[i("div",Re,[i("div",Se,[_e(V.$slots,"default",{},void 0,!0)])])])}const Ue=re(Ie,[["render",Te],["__scopeId","data-v-e5a94abc"]]),Ee={key:0,class:"text-center"},Me=Y({__name:"QrCodeTab",props:{tabs:{}},setup(V){const{chatUser:h}=F(),I=V,t=d(""),T=d([]),U=d({app_key:"",app_secret:""});async function P(){try{return await h.getQrSource()}catch{return[]}}ne(async()=>{I.tabs.length>0&&(t.value=I.tabs[0].key),T.value=await P(),D(t.value)});const D=u=>{const f=T.value.find(O=>O.auth_type===u);f&&f.config&&(U.value=f.config)},R=u=>{t.value=u,D(u)};return(u,f)=>{const O=k("el-tab-pane"),L=k("el-tabs");return s(),g(L,{modelValue:t.value,"onUpdate:modelValue":f[0]||(f[0]=o=>t.value=o),onTabChange:R},{default:p(()=>[(s(!0),C(G,null,ce(V.tabs,o=>(s(),g(O,{key:o.key,label:o.value,name:o.key},{default:p(()=>[o.key===t.value?(s(),C("div",Ee,[(s(),g(fe(ve(()=>Ae(Object.assign({"./dingtalkQrCode.vue":()=>H(()=>import("./dingtalkQrCode-DvFxdRVt.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url),"./larkQrCode.vue":()=>H(()=>import("./larkQrCode-DAs5P3J0.js"),__vite__mapDeps([5,6,2,3]),import.meta.url),"./wecomQrCode.vue":()=>H(()=>import("./wecomQrCode-AOgnQ99x.js"),__vite__mapDeps([7,2,3,8]),import.meta.url)}),`./${o.key}QrCode.vue`,2))),{config:U.value},null,8,["config"]))])):$("",!0)]),_:2},1032,["label","name"]))),128))]),_:1},8,["modelValue"])}}}),Qe={class:"user-login-container p-24"},Fe={key:0,class:"flex-center",style:{"margin-bottom":"32px"}},Be=["src"],ze={key:1,class:"user-login__header"},je={class:"flex-between"},Ke={class:"flex align-center"},Ne={class:"mr-12 ml-16 flex"},He=["src"],Je=["title"],We={class:"mb-24"},Xe={key:0,class:"mb-24"},Ge={key:1},Ye={class:"mb-24"},Ze={class:"mb-24"},et={key:0,class:"mb-24"},tt={class:"flex-between w-full"},ot=["src"],at={key:2},st={key:3,class:"login-gradient-divider lighter mt-24"},lt={class:"text-center mt-16"},nt=Y({__name:"index",setup(V){Ve();const h=se(),{theme:I,chatUser:t,common:T}=F(),{locale:U}=ge({useScope:"global"}),P=d(!1),D=X(),R=d(""),{params:{accessToken:u},query:{mode:f}}=D,O=Ce(()=>{console.log(T.isMobile());let e="";return!f||f==="pc"?e=T.isMobile()?"mobile":"pc":e=f,console.log(e),e==="pc"}),L=d(),o=d({username:"",password:"",captcha:""}),B=d(1),z=d({username:[{required:!0,message:x("views.login.loginForm.username.requiredMessage"),trigger:"blur"}],password:[{required:!0,message:x("views.login.loginForm.password.requiredMessage"),trigger:"blur"}],captcha:[{required:!1,message:x("views.login.loginForm.captcha.requiredMessage"),trigger:"blur"}]}),Q=()=>{L.value?.validate().then(()=>{if(m.value==="LDAP")t.ldapLogin(o.value).then(e=>{h.push({name:"chat",params:{accessToken:t.accessToken},query:D.query})});else{const e=W.pki.publicKeyFromPem(t?.chat_profile?.rsaKey),a=JSON.stringify(o.value),y=W.util.encodeUtf8(a),r=e.encrypt(y,"RSAES-PKCS1-V1_5"),A=W.util.encode64(r);t.login({encryptedData:A,username:o.value.username}).then(q=>{h.push({name:"chat",params:{accessToken:t.accessToken},query:D.query})}).catch(()=>{M(o.value.username)})}})};function M(e){ae.getCaptcha(e,u).then(a=>{R.value=a.data.captcha})}J(()=>{U.value=t.getLanguage()});const l=d([]),j=d([""]),m=d(""),E=d(!1),Z=d([]);function ie(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const a=Math.random()*16|0;return(e==="x"?a:a&3|8).toString(16)})}function ee(e,a=!1){e==="LDAP"||e===""||e==="password"||ae.getAuthSetting(e,P).then(y=>{if(!y.data||!y.data.config)return;const r=y.data.config,A=new URLSearchParams(D.query).toString();let q=`${r.redirectUrl}`,v=`${r.redirectUrl}/${u}`;A&&(v+=`?${A}`,q+=`&${A}`);let c;if(e==="CAS")c=r.ldpUri,c+=c.indexOf("?")!==-1?`&service=${encodeURIComponent(v)}`:`?service=${encodeURIComponent(v)}`;else if(e==="OIDC"){const _=r.scope||"openid+profile+email";c=`${r.authEndpoint}?client_id=${r.clientId}&redirect_uri=${v}&response_type=code&scope=${_}`,r.state&&(c+=`&state=${r.state}`)}else e==="OAuth2"&&(c=`${r.authEndpoint}?client_id=${r.clientId}&response_type=code&redirect_uri=${q}&state=${ie()}_${u}`,r.scope&&(c+=`&scope=${r.scope}`));c&&(a?be(x("views.login.jump_tip"),"",{confirmButtonText:x("views.login.jump"),cancelButtonText:x("common.cancel"),confirmButtonClass:""}).then(()=>{window.location.href=c}).catch(()=>{}):(console.log("url",c),window.location.href=c))})}function K(e){if(m.value=e==="LDAP"?e:"LOCAL",e!=="LOCAL"&&(m.value=e),e==="QR_CODE"){m.value=e,E.value=!0;return}E.value=!1,o.value={username:"",password:"",captcha:""},ee(e),L.value?.clearValidate()}function ue(e){M(e)}return J(()=>{t.chat_profile?.max_attempts&&(B.value=t.chat_profile.max_attempts),t.chat_profile?.login_value&&(l.value=t.chat_profile.login_value,l.value.includes("LOCAL")?l.value=["LOCAL",...l.value.filter(e=>e!=="LOCAL")]:l.value.includes("LDAP")&&(l.value=["LDAP",...l.value.filter(e=>e!=="LDAP")]),m.value=l.value[0]||"LOCAL",!l.value.includes("LOCAL")&&!l.value.includes("LDAP")&&(m.value=""),l.value.length==1&&["CAS","OIDC","OAuth2"].includes(l.value[0])&&ee(l.value[0]),j.value=l.value.filter(e=>!["CAS","OIDC","OAuth2","LOCAL","LDAP"].includes(e)),l.value=l.value.filter(e=>!["lark","wecom","dingtalk"].includes(e)),j.value.length>0&&(j.value.forEach(e=>{Z.value.push({key:e,value:e==="wecom"?x("views.system.authentication.scanTheQRCode.wecom"):e==="dingtalk"?x("views.system.authentication.scanTheQRCode.dingtalk"):x("views.system.authentication.scanTheQRCode.lark")})}),!l.value.includes("LOCAL")&&!l.value.includes("LDAP")&&(E.value=!0),l.value=["QR_CODE",...l.value]))}),J(()=>{const e=X(),a=d(e.fullPath),y=new URLSearchParams(a.value.split("?")[1]),r=y.get("client"),A=()=>{const v=y.get("corpId");v&&De.runtime.permission.requestAuthCode({corpId:v}).then(c=>{console.log("DingTalk client request success:",c),t.dingOauth2Callback(c.code,u).then(()=>{h.push({name:"chat",params:{accessToken:u},query:e.query})})})},q=()=>{const v=y.get("appId"),c=()=>{window.tt?.requestAuthCode({appId:v,success:_=>{t.larkCallback(_.code,u).then(()=>{h.push({name:"chat",params:{accessToken:u},query:e.query})})},fail:_=>{Le(_)}})};xe("https://lf-scm-cn.feishucdn.com/lark/op/h5-js-sdk-1.5.44.js",{jsId:"lark-sdk",forceReload:!0}).then(()=>{window.tt?window.tt?.requestAccess({appID:v,scopeList:[],success:_=>{t.larkCallback(_.code,u).then(()=>{h.push({name:"chat",params:{accessToken:u},query:e.query})})},fail:_=>{const{errno:N}=_;N===103&&c()}}):c()}).catch(_=>{console.error("SDK 加载失败:",_)})};switch(r){case"dingtalk":A();break;case"lark":q();break}}),(e,a)=>{const y=k("el-avatar"),r=k("LogoIcon"),A=k("el-card"),q=k("el-input"),v=k("el-form-item"),c=k("el-form"),_=k("el-button"),N=he("loading");return P.value?$("",!0):ye((s(),g(Ue,{key:0},{default:p(()=>[i("div",Qe,[O.value?(s(),C("div",Fe,[b(oe)(b(t).chat_profile?.icon)?(s(),g(y,{key:0,shape:"square",size:32,class:"mr-8",style:{background:"none"}},{default:p(()=>[i("img",{src:b(t).chat_profile?.icon,alt:""},null,8,Be)]),_:1})):(s(),g(r,{key:1,height:"32px",class:"mr-8"})),i("h1",null,S(b(t).chat_profile?.application_name),1)])):(s(),C("div",ze,[i("div",je,[i("div",Ke,[i("div",Ne,[b(oe)(b(t).chat_profile?.icon)?(s(),g(y,{key:0,shape:"square",size:32,style:{background:"none"}},{default:p(()=>[i("img",{src:b(t).chat_profile?.icon,alt:""},null,8,He)]),_:1})):(s(),g(r,{key:1,height:"32px"}))]),i("h4",{class:"ellipsis",style:{"max-width":"270px"},title:b(t).chat_profile?.application_name},S(b(t).chat_profile?.application_name),9,Je)])])])),b(t).chat_profile?.authentication_type=="password"?(s(),g(A,{key:2,class:"login-card"},{default:p(()=>[i("h2",We,S(e.$t("views.applicationOverview.appInfo.LimitDialog.authenticationValue")),1),w(Oe)]),_:1})):(s(),g(A,{key:3,class:"login-card",style:{"--el-card-padding":"0"}},{default:p(()=>[!E.value&&(m.value==="LDAP"||m.value==="LOCAL")?(s(),C("h2",Xe,S(m.value=="LOCAL"?e.$t("views.login.title"):m.value),1)):$("",!0),!E.value&&(m.value==="LDAP"||m.value==="LOCAL")?(s(),C("div",Ge,[w(c,{class:"login-form",rules:z.value,model:o.value,ref_key:"loginFormRef",ref:L,onKeyup:we(Q,["enter"])},{default:p(()=>[i("div",Ye,[w(v,{prop:"username"},{default:p(()=>[w(q,{size:"large",class:"input-item",modelValue:o.value.username,"onUpdate:modelValue":a[0]||(a[0]=n=>o.value.username=n),onBlur:a[1]||(a[1]=n=>ue(o.value.username)),placeholder:e.$t("views.login.loginForm.username.placeholder")},null,8,["modelValue","placeholder"])]),_:1})]),i("div",Ze,[w(v,{prop:"password"},{default:p(()=>[w(q,{type:"password",size:"large",class:"input-item",modelValue:o.value.password,"onUpdate:modelValue":a[2]||(a[2]=n=>o.value.password=n),placeholder:e.$t("views.login.loginForm.password.placeholder"),"show-password":""},null,8,["modelValue","placeholder"])]),_:1})]),m.value!=="LDAP"&&R.value?(s(),C("div",et,[w(v,{prop:"captcha"},{default:p(()=>[i("div",tt,[w(q,{size:"large",class:"input-item",modelValue:o.value.captcha,"onUpdate:modelValue":a[3]||(a[3]=n=>o.value.captcha=n),placeholder:e.$t("views.login.loginForm.captcha.placeholder")},null,8,["modelValue","placeholder"]),i("img",{src:R.value,alt:"",height:"38",class:"ml-8 cursor border border-r-6",onClick:a[4]||(a[4]=n=>M(o.value.username))},null,8,ot)])]),_:1})])):$("",!0)]),_:1},8,["rules","model"]),w(_,{size:"large",type:"primary",class:"w-full",onClick:Q,loading:P.value},{default:p(()=>[le(S(e.$t("views.login.buttons.login")),1)]),_:1},8,["loading"])])):$("",!0),E.value?(s(),C("div",at,[w(Me,{tabs:Z.value},null,8,["tabs"])])):$("",!0),l.value.length>1?(s(),C("div",st,[i("span",null,S(e.$t("views.login.moreMethod")),1)])):$("",!0),i("div",lt,[(s(!0),C(G,null,ce(l.value,n=>(s(),C(G,null,[n!=="LOCAL"&&m.value!==n&&n!=="QR_CODE"?(s(),g(_,{circle:"",key:n,class:"login-button-circle color-secondary",onClick:te=>K(n)},{default:p(()=>[i("span",{style:ke({"font-size":n==="OAUTH2"?"8px":"10px",color:b(I).themeInfo?.theme})},S(n),5)]),_:2},1032,["onClick"])):$("",!0),n==="QR_CODE"&&m.value!==n?(s(),g(_,{circle:"",key:n,class:"login-button-circle color-secondary",onClick:a[5]||(a[5]=te=>K("QR_CODE"))},{default:p(()=>[...a[7]||(a[7]=[i("img",{src:$e,width:"25px"},null,-1)])]),_:1})):$("",!0),n==="LOCAL"&&m.value!="LOCAL"?(s(),g(_,{circle:"",key:n,class:"login-button-circle color-secondary",style:{"font-size":"24px"},icon:"UserFilled",onClick:a[6]||(a[6]=te=>K("LOCAL"))})):$("",!0)],64))),256))])]),_:1}))])]),_:1})),[[N,P.value]])}}}),rt=re(nt,[["__scopeId","data-v-991f6ed3"]]),dt=Object.freeze(Object.defineProperty({__proto__:null,default:rt},Symbol.toStringTag,{value:"Module"}));export{dt as _,Oe as a,Ve as u};