2 lines
3.8 KiB
JavaScript
2 lines
3.8 KiB
JavaScript
import"./base-C_0HtztH.js";import{E as R}from"./el-card-cnxuvbL3.js";import{E as F,a as L,b as M}from"./el-alert-BgJljmz-.js";import{E as U}from"./el-input-nl0Ylqa_.js";import{E as j}from"./el-button-xGNUoXVX.js";import{g as n,y as K,f as z,h as D,i as q,z as G,j as _,p as s,s as t,u as H,o as p,k as m,F as V,x as b,c as J,l as h,m as O,t as Q}from"./vendor-vue-Da_zwKNU.js";import{c as W}from"./auth-CuW_jyJD.js";import{v as X}from"./password-7ryi82gE.js";import{_ as Y}from"./style-CEbARg1o.js";import{E as v}from"./http-BDcxFXLM.js";import"./aria-DLpFpzDe.js";import"./index-D04QrwME.js";import"./vendor-axios-B9ygI19o.js";const Z={class:"auth-wrap"},$={class:"actions"},ee={class:"actions"},oe={key:0,class:"app-muted"},se={__name:"ResetPasswordPage",setup(te){const T=K(),x=H(),r=n(String(T.params.token||"")),l=n(!0),y=n(""),a=z({newPassword:"",confirmPassword:""}),g=n(!1),f=n(""),i=n(0);let d=null;function B(){if(typeof window>"u")return null;const o=window.__APP_INITIAL_STATE__;return!o||typeof o!="object"?null:(window.__APP_INITIAL_STATE__=null,o)}const k=D(()=>!!(l.value&&r.value&&!f.value));function E(){x.push("/login")}function A(){i.value=3,d=window.setInterval(()=>{i.value-=1,i.value<=0&&(window.clearInterval(d),d=null,window.location.href="/login")},1e3)}async function I(){if(!k.value)return;const o=a.newPassword,e=a.confirmPassword,u=X(o);if(!u.ok){v.error(u.message);return}if(o!==e){v.error("两次输入的密码不一致");return}g.value=!0;try{await W({token:r.value,new_password:o}),f.value="密码重置成功!3秒后跳转到登录页面...",v.success("密码重置成功"),A()}catch(c){const w=c?.response?.data;v.error(w?.error||"重置失败")}finally{g.value=!1}}return q(()=>{const o=B();o?.page==="reset_password"?(r.value=String(o?.token||r.value||""),l.value=!!o?.valid,y.value=o?.error_message||(l.value?"":"重置链接无效或已过期,请重新申请密码重置")):r.value||(l.value=!1,y.value="重置链接无效或已过期,请重新申请密码重置")}),G(()=>{d&&window.clearInterval(d)}),(o,e)=>{const u=F,c=j,w=U,S=M,C=L,N=R;return p(),_("div",Z,[s(N,{shadow:"never",class:"auth-card","body-style":{padding:"22px"}},{default:t(()=>[e[5]||(e[5]=m("div",{class:"brand"},[m("div",{class:"brand-title"},"知识管理平台"),m("div",{class:"brand-sub app-muted"},"重置密码")],-1)),l.value?(p(),_(V,{key:1},[f.value?(p(),J(u,{key:0,type:"success",closable:!1,title:"重置成功",description:f.value,"show-icon":"",class:"alert"},null,8,["description"])):h("",!0),s(C,{"label-position":"top"},{default:t(()=>[s(S,{label:"新密码(至少8位且包含字母和数字)"},{default:t(()=>[s(w,{modelValue:a.newPassword,"onUpdate:modelValue":e[0]||(e[0]=P=>a.newPassword=P),type:"password","show-password":"",placeholder:"请输入新密码",autocomplete:"new-password"},null,8,["modelValue"])]),_:1}),s(S,{label:"确认密码"},{default:t(()=>[s(w,{modelValue:a.confirmPassword,"onUpdate:modelValue":e[1]||(e[1]=P=>a.confirmPassword=P),type:"password","show-password":"",placeholder:"请再次输入新密码",autocomplete:"new-password",onKeyup:O(I,["enter"])},null,8,["modelValue"])]),_:1})]),_:1}),s(c,{type:"primary",class:"submit-btn",loading:g.value,disabled:!k.value,onClick:I},{default:t(()=>[...e[3]||(e[3]=[b(" 确认重置 ",-1)])]),_:1},8,["loading","disabled"]),m("div",ee,[s(c,{link:"",type:"primary",onClick:E},{default:t(()=>[...e[4]||(e[4]=[b("返回登录",-1)])]),_:1}),i.value>0?(p(),_("span",oe,Q(i.value)+" 秒后自动跳转…",1)):h("",!0)])],64)):(p(),_(V,{key:0},[s(u,{type:"error",closable:!1,title:"链接已失效",description:y.value,"show-icon":""},null,8,["description"]),m("div",$,[s(c,{type:"primary",onClick:E},{default:t(()=>[...e[2]||(e[2]=[b("返回登录",-1)])]),_:1})])],64))]),_:1})])}}},ve=Y(se,[["__scopeId","data-v-6a8fefa8"]]);export{ve as default};
|