refactor: vue3 axios api ...

This commit is contained in:
xingyu
2022-07-19 22:33:54 +08:00
parent ba96eef51a
commit 9e2e220b69
121 changed files with 1022 additions and 9700 deletions

View File

@@ -1,6 +1,8 @@
import { defHttp } from '@/config/axios'
import { useAxios } from '@/hooks/web/useAxios'
import { getRefreshToken } from '@/utils/auth'
import type { UserLoginVO, TokenType, UserInfoVO } from './types'
import type { UserLoginVO } from './types'
const request = useAxios()
export interface CodeImgResult {
captchaOnOff: boolean
@@ -18,45 +20,45 @@ export interface SmsLoginVO {
// 获取验证码
export const getCodeImgApi = () => {
return defHttp.get<CodeImgResult>({ url: '/system/captcha/get-image' })
return request.get({ url: '/system/captcha/get-image' })
}
// 登录
export const loginApi = (params: UserLoginVO) => {
return defHttp.post<TokenType>({ url: '/system/auth/login', params })
export const loginApi = (data: UserLoginVO) => {
return request.post({ url: '/system/auth/login', data })
}
// 刷新访问令牌
export const refreshToken = () => {
return defHttp.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() })
return request.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() })
}
// 使用租户名,获得租户编号
export const getTenantIdByNameApi = (name: string) => {
return defHttp.get({ url: '/system/tenant/get-id-by-name?name=' + name })
return request.get({ url: '/system/tenant/get-id-by-name?name=' + name })
}
// 登出
export const loginOutApi = () => {
return defHttp.delete({ url: '/system/auth/logout' })
return request.delete({ url: '/system/auth/logout' })
}
// 获取用户权限信息
export const getInfoApi = () => {
return defHttp.get<UserInfoVO>({ url: '/system/auth/get-permission-info' })
return request.get({ url: '/system/auth/get-permission-info' })
}
// 路由
export const getAsyncRoutesApi = () => {
return defHttp.get({ url: '/system/auth/list-menus' })
return request.get({ url: '/system/auth/list-menus' })
}
//获取登录验证码
export const sendSmsCodeApi = (params: SmsCodeVO) => {
return defHttp.post({ url: '/system/auth/send-sms-code', params })
export const sendSmsCodeApi = (data: SmsCodeVO) => {
return request.post({ url: '/system/auth/send-sms-code', data })
}
// 短信验证码登录
export const smsLoginApi = (params: SmsLoginVO) => {
return defHttp.post({ url: '/system/auth/sms-login', params })
export const smsLoginApi = (data: SmsLoginVO) => {
return request.post({ url: '/system/auth/sms-login', data })
}