| 1 |
- import{G as m,W as r,ak as i,at as u}from"./index-CRr91q2n.js";import{l as d,Q as k,b as g}from"./login-CHypfzTa.js";const h=m("current_user",{persist:{enabled:!0,strategies:[{key:"info",storage:localStorage,paths:["username"]}]},state:()=>({name:"Jack",token_type:"",token:r.get(),username:"",nickname:"",dept:[],roles:[],permissions:[],user:{}}),actions:{updateName(t){this.name=t},toLogin(t){const{username:a,password:n}=t;return new Promise((o,s)=>{d({username:a,password:n}).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,r.set(e.data.access_token),o(e.msg),this.getInfo()):s(e.msg)}).catch(e=>{s(e)})})},async getRoutesList(){const{code:t,data:{routers:a}}=await k();if(t===200)return new Promise((n,o)=>{try{i.removeItem(),i.setItem(JSON.stringify(a)),n()}catch(s){o(s)}})},async getUserInfo(){const{code:t,data:{permissions:a,dept:n,roles:o}}=await g();if(t===200)return new Promise((s,e)=>{try{u.setItem(JSON.stringify({permissions:a,dept:n,roles:o})),s()}catch(c){e(c)}})}}});export{h as u};
|