1 line
7.8 KiB
JavaScript
1 line
7.8 KiB
JavaScript
import{$ as e,B as t,C as n,Ht as r,J as i,Lt as a,M as o,Q as s,R as c,T as l,U as u,V as d,_ as f,b as p,gt as m,it as h,lt as g,t as _,ut as v,v as y,w as b,wt as x,x as S,y as C,zt as w}from"./_plugin-vue_export-helper-Ktpf6lZe.js";import{h as T,m as E}from"./useApi-CROJJdhE-BKbQ20nt.js";import{n as D}from"./app-BeHz6434.js";import{D as O,J as k,U as A,_ as j,g as M,t as N,y as P}from"./ui-BhP3ZSBa.js";import{n as F,t as I}from"./key-round-ClmJfynH.js";import{n as L,r as R,t as z}from"./user-D5GR1UC5.js";import{i as B,l as V}from"./api-BHfsXASe.js";x(),o(),h();var H=_({__name:`SliderCaptcha`,props:{modelValue:{type:Boolean,default:!1},text:{type:String,default:`请按住滑块拖动`},successText:{type:String,default:`验证通过`},disabled:{type:Boolean,default:!1}},emits:[`update:modelValue`,`success`,`start`,`move`,`end`],setup(e,{expose:n,emit:i}){let o=e,l=i,f=v(null),p=v(null),h=v(null),g=v(!1),_=v(!1),b=v(0),x=v(0),T=v(!1),E=v(`0`),D=v(`0`);s(()=>o.modelValue,e=>{e!==_.value&&(_.value=!!e)}),s(_,e=>{e&&l(`success`,{isPassing:!0})});function O(e){return`pageX`in e?e.pageX:`touches`in e&&e.touches[0]?e.touches[0].pageX:0}function j(){let e=f.value,t=p.value;if(!e||!t)return{actionWidth:40,offset:0,wrapperWidth:220};let n=e.offsetWidth,r=t.offsetWidth;return{actionWidth:r,offset:n-r-6,wrapperWidth:n}}function M(e){if(_.value||o.disabled)return;b.value=O(e);let t=Number.parseInt(E.value||`0`,10);x.value=b.value-t,g.value=!0,l(`start`,e)}function N(e){if(!g.value||_.value)return;let t=p.value,n=h.value;if(!t||!n)return;let{actionWidth:r,offset:i,wrapperWidth:a}=j(),o=O(e)-x.value;l(`move`,{event:e,moveDistance:x.value,moveX:o}),o>=i-2?(E.value=`${a-r}px`,D.value=`${a-r/2}px`,I()):o>0?(E.value=`${o}px`,D.value=`${o+r/2}px`):(E.value=`0`,D.value=`0`)}function P(e){g.value&&F(e)}function F(e){if(!g.value||_.value)return;l(`end`,e);let t=p.value,n=h.value;if(!t||!n)return;let{actionWidth:r,offset:i,wrapperWidth:a}=j();O(e)-x.value>=i-2?(E.value=`${a-r}px`,D.value=`${a-r/2}px`,I()):L(),g.value=!1}function I(){_.value=!0,g.value=!1,l(`update:modelValue`,!0)}function L(){g.value=!1,_.value=!1,x.value=0,l(`update:modelValue`,!1),T.value=!0,c(()=>{E.value=`0`,D.value=`0`,setTimeout(()=>{T.value=!1},300)})}return d(()=>{document.addEventListener(`mouseup`,P),document.addEventListener(`touchend`,P)}),t(()=>{document.removeEventListener(`mouseup`,P),document.removeEventListener(`touchend`,P)}),n({resume:L}),(t,n)=>(u(),S(`div`,{ref_key:`wrapperRef`,ref:f,class:a([`scaptcha`,{"scaptcha--disabled":e.disabled,"scaptcha--passed":_.value}]),onMousemove:N,onTouchmove:N},[y(`div`,{ref_key:`barRef`,ref:h,class:a([`scaptcha__bar`,{"scaptcha__bar--left":T.value,"scaptcha__bar--passed":_.value}]),style:w({width:D.value})},null,6),y(`div`,{class:a([`scaptcha__text`,{"scaptcha__text--passed":_.value}])},r(_.value?e.successText:e.text),3),y(`div`,{ref_key:`actionRef`,ref:p,class:a([`scaptcha__action`,{"scaptcha__action--left":T.value,"scaptcha__action--disabled":e.disabled,"scaptcha__action--passed":_.value}]),style:w({left:E.value}),onMousedown:M,onTouchstart:M},[_.value?(u(),C(m(k),{key:1,size:16})):(u(),C(m(A),{key:0,size:16}))],38)],34))}},[[`__scopeId`,`data-v-f1216faa`]]);o(),x(),h();var U={class:`login-page`},W={class:`login-actions`},G={class:`login-body`},K={class:`login-right`},q={class:`login-card`},J={key:0,class:`login-hint`,role:`alert`},Y=_({__name:`index`,setup(t){let a=T(),o=E(),s=V(),c=D(),h=f(()=>{let e=String(o.query.reason||``);return e===`session-replaced`?`账号已在其他设备登录,请重新登录`:e===`expired`?`登录已过期,请重新登录`:``}),_=g({orgId:``,account:``,password:``,captcha:!1}),x={orgId:[{required:!0,message:`请输入机构码`}],account:[{required:!0,message:`请输入账号`}],captcha:[{validator:e=>e===!0,message:`请完成滑块验证`}]},w=v(!1),k=v(null),A=f(()=>c.darkMode);function Y(){c.toggleDarkMode()}let X=v(`zh-CN`);function Z(){X.value=X.value===`zh-CN`?`en-US`:`zh-CN`,N.info(`语言切换待接入 i18n 后生效`)}d(()=>{_.orgId=s.userInfo.orgId||``,_.account=s.userInfo.account||``,_.password=``,document.querySelector(`#orgId input`)?.focus()});async function Q(e){w.value=!0;try{let t=await B(e.orgId,e.account,e.password??``);s.setSession({token:t.data.token,user:{...t.data.user}},t.data.orgid??e.orgId),s.saveLastLogin(e.orgId,e.account),N.success(`登录成功`),a.replace(String(o.query.redirect||`/dashboard`))}catch(e){e?.toasted||N.error(e.message||`登录失败,请稍后重试`),k.value?.resume?.()}finally{w.value=!1}}function $(){N.warning(`请填写完整的登录信息`)}return(t,a)=>(u(),S(`div`,U,[a[9]||=y(`div`,{class:`login-brand`},[y(`img`,{src:`/favicon.svg`,alt:`FMS`,class:`login-logo__img`}),y(`span`,{class:`login-brand__name`},`FMS 企业管理系统`)],-1),y(`div`,W,[l(m(O),{type:`ghost`,size:`small`,class:`login-action-btn`,onClick:Z},{default:e(()=>[b(r(X.value===`zh-CN`?`中`:`EN`),1)]),_:1}),l(m(O),{type:`ghost`,size:`small`,class:`login-action-btn`,onClick:Y},{default:e(()=>[(u(),C(i(A.value?m(L):m(R)),{size:16}))]),_:1})]),y(`div`,G,[a[8]||=n(`<div class="login-left" data-v-9ee69368><div class="login-left__inner" data-v-9ee69368><div class="login-left__graphic" aria-hidden="true" data-v-9ee69368><svg viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg" class="login-left__svg" data-v-9ee69368><defs data-v-9ee69368><linearGradient id="lg1" x1="0%" y1="0%" x2="100%" y2="100%" data-v-9ee69368><stop offset="0%" stop-color="var(--fms-primary)" stop-opacity="0.08" data-v-9ee69368></stop><stop offset="100%" stop-color="var(--fms-primary)" stop-opacity="0.02" data-v-9ee69368></stop></linearGradient></defs><circle cx="120" cy="120" r="80" fill="var(--fms-primary)" opacity="0.06" data-v-9ee69368></circle><circle cx="480" cy="180" r="120" fill="var(--fms-primary)" opacity="0.04" data-v-9ee69368></circle><rect x="50" y="350" width="200" height="200" rx="30" fill="url(#lg1)" data-v-9ee69368></rect><rect x="350" y="400" width="160" height="160" rx="20" fill="var(--fms-primary)" opacity="0.04" data-v-9ee69368></rect><path d="M300 80 L420 200 L300 320 L180 200 Z" fill="var(--fms-primary)" opacity="0.05" data-v-9ee69368></path></svg></div><p class="login-left__text" data-v-9ee69368>企业管理系统</p></div></div>`,1),y(`div`,K,[y(`div`,q,[a[5]||=y(`h1`,{class:`login-card__title`},`登录`,-1),a[6]||=y(`p`,{class:`login-card__subtitle`},`欢迎回来,请输入您的账号信息`,-1),h.value?(u(),S(`div`,J,r(h.value),1)):p(``,!0),l(m(P),{class:`login-form`,model:_,rules:x,layout:`vertical`,gap:20,onSubmit:Q,onSubmitFailed:$},{default:e(()=>[l(m(j),{name:`orgId`,label:`机构码`},{default:e(()=>[l(m(M),{id:`orgId`,modelValue:_.orgId,"onUpdate:modelValue":a[0]||=e=>_.orgId=e,placeholder:`请输入机构码`,disabled:w.value},{prefix:e(()=>[l(m(F))]),_:1},8,[`modelValue`,`disabled`])]),_:1}),l(m(j),{name:`account`,label:`账号`},{default:e(()=>[l(m(M),{id:`account`,modelValue:_.account,"onUpdate:modelValue":a[1]||=e=>_.account=e,autocomplete:`username`,placeholder:`请输入账号`,disabled:w.value},{prefix:e(()=>[l(m(z))]),_:1},8,[`modelValue`,`disabled`])]),_:1}),l(m(j),{name:`password`,label:`密码`},{default:e(()=>[l(m(M),{id:`password`,modelValue:_.password,"onUpdate:modelValue":a[2]||=e=>_.password=e,type:`password`,autocomplete:`current-password`,placeholder:`请输入密码`,disabled:w.value},{prefix:e(()=>[l(m(I))]),_:1},8,[`modelValue`,`disabled`])]),_:1}),l(m(j),{name:`captcha`},{default:e(()=>[l(H,{ref_key:`captchaRef`,ref:k,modelValue:_.captcha,"onUpdate:modelValue":a[3]||=e=>_.captcha=e,disabled:w.value},null,8,[`modelValue`,`disabled`])]),_:1}),l(m(O),{type:`primary`,block:``,loading:w.value,"html-type":`submit`,class:`login-submit`},{default:e(()=>[...a[4]||=[b(` 登录 `,-1)]]),_:1},8,[`loading`])]),_:1},8,[`model`]),a[7]||=y(`p`,{class:`login-footer`},`© 2026 FMS · 企业管理系统`,-1)])])])]))}},[[`__scopeId`,`data-v-9ee69368`]]);export{Y as default}; |