Files
FileRelay/web/assets/AdminLogin-DALRrCFv.js

2 lines
6.3 KiB
JavaScript

import{d as w,v,o as _,f as l,j as e,I as r,S as y,z as u,u as o,Q as b,P as C,i as M,C as p,D as g,g as i,T as j}from"./index-BhaIiTEj.js";import{_ as B,d as x,a as V,b as z,t as $}from"./Sonner.vue_vue_type_script_setup_true_lang-BwfWndxy.js";import{_ as L}from"./Input.vue_vue_type_script_setup_true_lang-CD5fb2oW.js";import{_ as A}from"./Label.vue_vue_type_script_setup_true_lang-D-_Evs0_.js";import{_ as S}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./useForwardExpose-CRFbVhil.js";const N={class:"min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8"},I={class:"max-w-md w-full space-y-8"},H={class:"mt-1 relative"},D={key:0,class:"h-5 w-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},E={key:1,class:"h-5 w-5 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},P={key:0,class:"absolute left-0 inset-y-0 flex items-center pl-3"},T={key:1,class:"w-5 h-5 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},q={key:0,class:"rounded-md bg-red-50 p-4"},Q={class:"flex"},R={class:"ml-3"},U={class:"text-sm font-medium text-red-800"},F={class:"ml-auto pl-3"},G={class:"-mx-1.5 -my-1.5"},J={class:"text-center"},K=w({__name:"AdminLogin",setup(O){const f=b(),a=v(""),c=v(!1),d=v(!1),n=v(""),k=async()=>{if(!a.value.trim()){n.value="请输入管理员密码";return}d.value=!0,n.value="";try{const s=await j.login(a.value.trim());if(s.data.code===200)localStorage.setItem("admin_token",s.data.data.token),$.success("登录成功!"),f.push("/admin");else throw new Error(s.data.msg||"登录失败")}catch(s){console.error("登录失败:",s),s.response?.status===401?n.value="密码错误,请重新输入":n.value=s.response?.data?.msg||"登录失败,请重试",a.value=""}finally{d.value=!1}},h=()=>{localStorage.getItem("admin_token")&&f.replace("/admin")};return _(()=>{h()}),(s,t)=>(i(),l("div",N,[e("div",I,[t[12]||(t[12]=y('<div data-v-266683e4><div class="mx-auto h-12 w-12 flex items-center justify-center rounded-full bg-indigo-100" data-v-266683e4><svg class="h-8 w-8 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-266683e4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" data-v-266683e4></path></svg></div><h2 class="mt-6 text-center text-3xl font-bold text-gray-900" data-v-266683e4> 管理员登录 </h2><p class="mt-2 text-center text-sm text-gray-600" data-v-266683e4> 请输入管理员密码以访问管理后台 </p></div>',1)),r(o(B),{class:"border-0 shadow-lg"},{default:u(()=>[r(o(z),{class:"pt-6"},{default:u(()=>[e("form",{onSubmit:C(k,["prevent"]),class:"space-y-6"},[e("div",null,[r(o(A),{for:"password",class:"text-sm font-medium text-gray-700"},{default:u(()=>[...t[4]||(t[4]=[p(" 管理员密码 ",-1)])]),_:1}),e("div",H,[r(o(L),{id:"password",name:"password",type:c.value?"text":"password",modelValue:a.value,"onUpdate:modelValue":t[0]||(t[0]=m=>a.value=m),placeholder:"请输入管理员密码",class:"pr-10",required:""},null,8,["type","modelValue"]),e("button",{type:"button",onClick:t[1]||(t[1]=m=>c.value=!c.value),class:"absolute inset-y-0 right-0 pr-3 flex items-center"},[c.value?(i(),l("svg",D,[...t[5]||(t[5]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L6.879 6.879a3 3 0 00-4.243 4.243M9.878 9.878a3 3 0 014.242 4.243M15.121 14.121L18.121 17.121a3 3 0 01-4.243 4.243M12 3c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},null,-1)])])):(i(),l("svg",E,[...t[6]||(t[6]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},null,-1),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},null,-1)])]))])])]),e("div",null,[r(o(x),{type:"submit",disabled:!a.value||d.value,class:"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"},{default:u(()=>[d.value?(i(),l("span",P,[...t[7]||(t[7]=[e("svg",{class:"animate-spin h-5 w-5 text-indigo-300",fill:"none",viewBox:"0 0 24 24"},[e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 0 1 4 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1)])])):(i(),l("svg",T,[...t[8]||(t[8]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},null,-1)])])),p(" "+g(d.value?"登录中...":"登录管理后台"),1)]),_:1},8,["disabled"])]),n.value?(i(),l("div",q,[e("div",Q,[t[10]||(t[10]=e("div",{class:"flex-shrink-0"},[e("svg",{class:"h-5 w-5 text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),e("div",R,[e("p",U,g(n.value),1)]),e("div",F,[e("div",G,[e("button",{onClick:t[2]||(t[2]=m=>n.value=""),class:"inline-flex bg-red-50 rounded-md p-1.5 text-red-500 hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-red-50 focus:ring-red-600"},[...t[9]||(t[9]=[e("svg",{class:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])])])])])):M("",!0)],32)]),_:1})]),_:1}),e("div",J,[r(o(x),{variant:"link",onClick:t[3]||(t[3]=m=>o(f).push("/")),class:"text-sm text-gray-600 hover:text-gray-900"},{default:u(()=>[...t[11]||(t[11]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})],-1),p(" 返回首页 ",-1)])]),_:1})])]),r(o(V))]))}}),se=S(K,[["__scopeId","data-v-266683e4"]]);export{se as default};