Files
machartaa_admin_dist/dist/assets/index-fd017da7.js
T

2 lines
13 KiB
JavaScript
Raw Normal View History

2026-08-23 14:52:55 +03:30
import{_ as V}from"./button.vue_vue_type_style_index_0_lang-29638cb6.js";import{_ as Q}from"./BasicInput.vue_vue_type_style_index_0_lang-5a31e25c.js";import{O as j,g as ee,i as O,d as D,u as M,B as E,h as R,o as m,c as I,b as c,e as p,w as f,k as S,l as a,y as ne,s as N,W as z,X as te,E as F,Y as U,a as W,Z as q,r as H,G as T,x as se,$ as oe,a0 as ae,n as x,p as le,F as ue,q as ie,f as re}from"./index-a28be152.js";import{n as de}from"./phone-6ff17ec0.js";import{u as ce,I as pe}from"./Icon-c8a211f1.js";import{F as A,_ as B}from"./index-85ba3ddf.js";import{S as P}from"./index-dd708aca.js";import{_ as L,T as me}from"./index-96443f0e.js";import"./index-3bdda65d.js";import"./_plugin-vue_export-helper-f8ecc290.js";import"./usePrice-bc935b83.js";import"./index-f317ca53.js";import"./SearchOutlined-4a5562a8.js";import"./omit-8084e33b.js";import"./vnode-4742fc96.js";import"./FormItemContext-e50ee5a3.js";import"./isPlainObject-450bf3c7.js";import"./index-5222fc6e.js";import"./isSymbol-25ca88cb.js";import"./_flatRest-08328244.js";import"./Col-86738adb.js";import"./styleChecker-8c6ff79a.js";import"./toArray-bdec6b87.js";import"./index-4a3fe357.js";import"./shallowequal-4c00a664.js";import"./useState-277534ff.js";import"./useRefs-e22a3bf7.js";import"./isMobile-e2e89480.js";const fe="/assets/logo-dd2a3541.png",ve=async e=>{const o=de(e.username),l=o.includes("@")?o:`${o}@example.com`;return await j.post("/auth/login-admin",{username:l,password:e.password})},ye=async e=>await j.post("/auth/login",e),he=async e=>await j.post("/auth/verify",e),G=ee("login",()=>{const e=O(""),o=O(null);return{mobile:e,id:o,setMobile:s=>{e.value=s},setId:s=>{o.value=s}}}),ge={class:"grid grid-cols-1 md:grid-cols-12 h-full bg-gradient"},_e={class:"md:col-span-3 flex justify-center items-center"},Oe={class:"min-h-[300px]"},we={key:1},be={key:1},Ie=c("div",{class:"md:col-span-9 md:flex md:justify-center md:items-center hidden"},[c("img",{src:fe,alt:"machartaa logo",class:"w-40vw"})],-1),ke=D({__name:"Panel",emits:["verify"],setup(e,{emit:o}){const l=O(0),t=O(!1),s=M(),v=E(),{prefixCls:g}=ce("login"),w=G(),u=R({username:"",password:""}),b=async i=>{var n,d,_,y;try{if(t.value=!0,i.username&&i.password){const h={...i,provider:"user"};console.log("Login payload:",h);const $=await ve(h);if(console.log("Login response:",$),(n=$==null?void 0:$.session)!=null&&n.access_token){await z($.session.access_token);try{await v.getMyInfo()}catch{te(),F.error("شما دسترسی ادمین ندارید");return}U(v.routePermissionKeys,s,v.isSuperAdmin);const r=W();await q(s,H(r.routes))}else F.error("توکن دریافتی نامعتبر است")}else F.error("وارد کردن تمامی فیلدها الزامی است")}catch(h){console.log("Login error:",h),console.log("Error response:",(d=h==null?void 0:h.response)==null?void 0:d.data),F.error(((y=(_=h==null?void 0:h.response)==null?void 0:_.data)==null?void 0:y.message)||"خطا در ورود به پنل کاربری")}finally{t.value=!1}},k=async i=>{try{if(t.value=!0,i.username!==""){w.setMobile(i.username);let n=await ye({...i,provider:"user"});w.setId(n.id),o("verify",!0)}else F.error("وارد کردن تمامی فیلدها الزامی است")}catch(n){console.log(n),F.error("خطا در ورود به پنل کاربری")}finally{t.value=!1}};return(i,n)=>{const d=Q,_=V;return m(),I("div",{class:N(["h-screen bg-image overflow-hidden",[`${a(g)}`]])},[c("div",ge,[c("div",_e,[c("div",Oe,[p(a(me),{activeKey:a(l),"onUpdate:activeKey":n[3]||(n[3]=y=>ne(l)?l.value=y:null)},{default:f(()=>[(m(),S(a(L),{tab:"ورود با شماره تلفن",key:0,"force-render":""},{default:f(()=>[p(a(A),{model:a(u),onFinish:b},{default:f(()=>[p(a(B),{label:"شماره تلفن",name:"username"},{default:f(()=>[p(d,{"place-holder":"مثال: 09123456789",value:a(u).username,"onUpdate:value":n[0]||(n[0]=y=>a(u).username=y)},null,8,["value"])]),_:1}),p(a(B),{label:"کلمه عبور",name:"password"},{default:f(()=>[p(d,{"is-password":"","place-holder":"کلمه عبور",value:a(u).password,"onUpdate:value":n[1]||(n[1]=y=>a(u).passwo