| 1 |
- import{C as r,L as u,A as i,ad as c,a9 as m}from"./index-kIKYd_tc.js";function d(t){return r({url:"/api/auth/v2/login",method:"post",data:t})}function l(t){return r({url:"/api/auth/v2/register",method:"post",data:t})}function f(t){return r({url:`/api/auth/v2/sync?userFlag=${t}`,method:"get"})}function g(){return r({url:"/api/user/user_info",method:"get"})}function h(){return r({url:"/api/user/user_routers",method:"get"})}const k=u("current_user",{persist:{enabled:!0,strategies:[{key:"info",storage:localStorage,paths:["username"]}]},state:()=>({name:"Jack",token_type:"",token:i.get(),username:"",nickname:"",dept:[],roles:[],permissions:[],user:{}}),actions:{updateName(t){this.name=t},toLogin(t){const{username:a,password:s}=t;return new Promise((n,o)=>{d({username:a,password:s}).then(e=>{e.code==200&&e.data.access_token.length?(this.token=e.data.access_token,this.token_type=e.data.token_type,this.username=e.data.username,this.nickname=e.data.nickname,i.set(e.data.access_token),n(e.msg),this.getInfo()):o(e.msg)}).catch(e=>{o(e)})})},async getRoutesList(){const{code:t,data:{routers:a}}=await h();t===200&&await new Promise((s,n)=>{try{c.setItem(JSON.stringify(a)),s()}catch(o){n(o)}})},async getUserInfo(){const{code:t,data:{permissions:a,dept:s,roles:n}}=await g();t===200&&m.setItem(JSON.stringify({permissions:a,dept:s,roles:n}))}}});export{f as a,l as r,k as u};
|