You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
1.0 KiB

import{a as e,i as t}from"./index-DFPdDGyr.js";async function n(n){try{let{data:e}=await t.post(`/auth/login`,n);return r(e)}catch(t){if(e.isAxiosError(t)){let e=t.response?.data,n=e&&typeof e==`object`?e:{},r=(typeof n.message==`string`?n.message:``)||(n.errors&&typeof n.errors==`object`?Object.values(n.errors).flat().join(`
`):``)||t.message;throw Error(r||`登录失败`)}throw t}}function r(e){if(e&&typeof e==`object`){let t=e,n=t.data,r=(typeof t.token==`string`?t.token:void 0)??(typeof t.access_token==`string`?t.access_token:void 0)??(n&&typeof n.token==`string`?n.token:void 0);if(typeof r==`string`)return{token:r,user:t.user??t.admin??n?.user}}throw Error(`登录响应无效`)}async function i(n){try{await t.patch(`/auth/password`,n)}catch(t){if(e.isAxiosError(t)){let e=t.response?.data,n=e&&typeof e==`object`?e:{},r=(typeof n.message==`string`?n.message:``)||(n.errors&&typeof n.errors==`object`?Object.values(n.errors).flat().join(`
`):``)||t.message;throw Error(r||`修改密码失败`)}throw t}}export{i as n,n as t};