1 line
6.6 KiB
JavaScript
1 line
6.6 KiB
JavaScript
"use strict";(self["webpackChunkscui"]=self["webpackChunkscui"]||[]).push([[4535],{6244:function(e,t,a){a.r(t),a.d(t,{default:function(){return $}});var i=a(66252),s=a(3577);const n=e=>((0,i.dD)("data-v-1791e133"),e=e(),(0,i.Cn)(),e),o={class:"login_bg"},l=(0,i.uE)('<div class="login_adv" data-v-1791e133><div class="login_adv__title" data-v-1791e133><div class="text" data-v-1791e133><img class="img" src="https://dm-auto.oss-cn-shanghai.aliyuncs.com/xw_cloud/image/login_logo.png" alt="" data-v-1791e133></div></div><div class="login_adv__mask" data-v-1791e133></div></div>',1),c={class:"login_main"},r=n((()=>(0,i._)("div",{class:"loginBack"},null,-1))),d={class:"login-form"},g={class:"loginRight"},u={class:"loginRightMask"},h=n((()=>(0,i._)("div",{class:"handerWelcome"},[(0,i._)("div",{class:"title"},"欢迎登录"),(0,i._)("div",{class:"name"},"麟云系统平台")],-1))),m={class:"login-oauth"},p={class:"qrCodeLogin"},L={class:"msg"},w=n((()=>(0,i._)("br",null,null,-1))),f={key:0,class:"qrCodeLogin-result"};function v(e,t,a,n,v,O){const _=(0,i.up)("password-form"),y=(0,i.up)("el-tab-pane"),S=(0,i.up)("phone-form"),I=(0,i.up)("el-tabs"),$=(0,i.up)("el-divider"),T=(0,i.up)("el-button"),b=(0,i.up)("sc-qr-code"),k=(0,i.up)("el-result"),N=(0,i.up)("el-dialog");return(0,i.wg)(),(0,i.iD)(i.HY,null,[(0,i._)("div",o,[l,(0,i._)("div",c,[r,(0,i._)("div",d,[(0,i._)("div",g,[(0,i._)("div",u,[h,(0,i.Wm)(I,null,{default:(0,i.w5)((()=>[(0,i.Wm)(y,{label:e.$t("login.accountLogin"),lazy:""},{default:(0,i.w5)((()=>[(0,i.Wm)(_)])),_:1},8,["label"]),(0,i.Wm)(y,{label:e.$t("login.mobileLogin"),lazy:""},{default:(0,i.w5)((()=>[(0,i.Wm)(S)])),_:1},8,["label"])])),_:1}),e.$CONFIG.MY_SHOW_LOGIN_OAUTH?((0,i.wg)(),(0,i.iD)(i.HY,{key:0},[(0,i.Wm)($,null,{default:(0,i.w5)((()=>[(0,i.Uk)((0,s.toDisplayString)(e.$t("login.signInOther")),1)])),_:1}),(0,i._)("div",m,[(0,i.Wm)(T,{type:"success",icon:"sc-icon-wechat",circle:"",onClick:O.wechatLogin},null,8,["onClick"])])],64)):(0,i.kq)("",!0),(0,i._)("div",{class:"passKeyLogin",onClick:t[0]||(t[0]=(...e)=>O.passKeyLogin&&O.passKeyLogin(...e))},"PassKey登录")])])])])]),(0,i.Wm)(N,{modelValue:v.showWechatLogin,"onUpdate:modelValue":t[1]||(t[1]=e=>v.showWechatLogin=e),title:e.$t("login.wechatLoginTitle"),width:400,"destroy-on-close":""},{default:(0,i.w5)((()=>[(0,i._)("div",p,[(0,i.Wm)(b,{class:"qrCode",text:v.WechatLoginCode,size:200},null,8,["text"]),(0,i._)("p",L,[(0,i.Uk)((0,s.toDisplayString)(e.$tc("login.wechatLoginMsg",1)),1),w,(0,i.Uk)((0,s.toDisplayString)(e.$tc("login.wechatLoginMsg",2)),1)]),v.isWechatLoginResult?((0,i.wg)(),(0,i.iD)("div",f,[(0,i.Wm)(k,{icon:"success",title:e.$tc("login.wechatLoginResult",1),"sub-title":e.$tc("login.wechatLoginResult",2)},null,8,["title","sub-title"])])):(0,i.kq)("",!0)])])),_:1},8,["modelValue","title"])],64)}a(57658),a(23767),a(8585),a(68696),a(82801);var O=a(54375),_=a(18411),y={components:{passwordForm:O["default"],phoneForm:_["default"]},data(){return{config:{lang:this.$TOOL.data.get("APP_LANG")||this.$CONFIG.LANG},lang:[{name:"简体中文",value:"zh-cn"},{name:"English",value:"en"}],WechatLoginCode:"",showWechatLogin:!1,isWechatLoginResult:!1}},computed:{},watch:{"config.lang"(e){this.$i18n.locale=e,this.$TOOL.data.set("APP_LANG",e)}},created:function(){window.addEventListener("storage",this.storageChange),this.$TOOL.cookie.remove("TOKEN"),this.$TOOL.data.remove("USER_INFO"),this.$TOOL.data.remove("MENU"),this.$TOOL.data.remove("PERMISSIONS"),this.$TOOL.data.remove("grid"),this.$store.commit("clearViewTags"),this.$store.commit("clearKeepLive"),this.$store.commit("clearIframeList"),localStorage.removeItem("bindDingTalk"),localStorage.removeItem("bindWechat")},unmounted(){window.removeEventListener("storage",this.storageChange)},beforeUnmount(){},methods:{configLang(e){this.config.lang=e.value},storageChange(e){let t=localStorage.getItem("bindDingTalk"),a=localStorage.getItem("bindWechat");"DINGTALK_LOGIN_MESSAGE"==e.key&&(1==t&&"string"==typeof e.newValue&&""!=e.newValue&&this.dingTalkLogin(e.newValue),localStorage.removeItem("DINGTALK_LOGIN_MESSAGE")),"WECHAT_LOGIN_MESSAGE"==e.key&&(1==a&&"string"==typeof e.newValue&&""!=e.newValue&&this.wechatLogin(e.newValue),localStorage.removeItem("WECHAT_LOGIN_MESSAGE"))},async bindWechat(){const e=await this.$API.auth.wechatCode.post();if(200==e.code){const t=JSON.parse(JSON.stringify(e.data.redirect));localStorage.setItem("bindWechat","1"),window.open(t)}},async setLoginData(e){this.$TOOL.cookie.set("TOKEN",e.data.token,{expires:0}),this.$TOOL.data.set("USER_INFO",e.data.user);let t=null;if(t=await this.$API.system.menu.myMenus.get(),200!==t.code)return this.$message.warning(t.msg),!1;{if(0===t.data.menu.length)return this.islogin=!1,await this.$alert("当前用户无任何菜单权限,请联系系统管理员","无权限访问",{type:"error",center:!0}),!1;this.$TOOL.setMenu(t.data.menu),this.$TOOL.data.set("MENU",t.data.menu),this.$TOOL.data.set("USER-PERMISSIONS",t.data.permissions);const e=t.data.permissions.data_permissions.reduce(((e,t)=>{for(const a in t)t[a]&&Array.isArray(t[a])&&e.push(...t[a].map((e=>e.actions)));return e}),[]);this.$TOOL.data.set("PERMISSIONS",e)}this.$router.replace({path:"/"})},async wechatLogin(e){let t=JSON.parse(e),a={code:t.code};const i=await this.$API.auth.wechatLogin.post(a);if(200!=i.code)return!1;await this.setLoginData(i)},async bindDingTalk(){const e=await this.$API.auth.dingTalkCode.post();if(200==e.code){const t=JSON.parse(JSON.stringify(e.data.redirect));localStorage.setItem("bindDingTalk","1"),window.open(t)}},async dingTalkLogin(e){let t=JSON.parse(e),a={code:t.code};const i=await this.$API.auth.dingTalkLogin.post(a);if(200!=i.code)return!1;await this.setLoginData(i)},async passKeyLogin(){const e=await this.$API.system.user.generateAuthentication.post();if(200==e.code){const a={challenge:Uint8Array.from(e.data.challenge),timeout:e.data.timeout,rpId:e.data.rpId,userVerification:e.data.userVerification};try{const e=await navigator.credentials.get({publicKey:a});await this.passKeyVerify(e)}catch(t){console.log(t,"您已取消")}}},async passKeyVerify(e){let t={id:e.id,rawId:this.bufferToBase64URL(e.rawId),type:e.type,response:{authenticatorData:this.bufferToBase64URL(e.response.authenticatorData),clientDataJSON:this.bufferToBase64URL(e.response.clientDataJSON),signature:this.bufferToBase64URL(e.response.signature),userHandle:this.bufferToBase64URL(e.response.userHandle)}};const a=await this.$API.system.user.verifyAuthentication.post(t);200==a.code&&await this.setLoginData(a)},bufferToBase64URL(e){return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}}},S=a(83744);const I=(0,S.Z)(y,[["render",v],["__scopeId","data-v-1791e133"]]);var $=I}}]); |