74 lines
1.9 KiB
TypeScript
Raw Normal View History

2022-11-03 16:55:01 +08:00
import request from '@/config/axios'
2022-07-18 19:06:37 +08:00
import { getRefreshToken } from '@/utils/auth'
2022-07-19 22:33:54 +08:00
import type { UserLoginVO } from './types'
2022-07-18 19:06:37 +08:00
export interface CodeImgResult {
captchaOnOff: boolean
img: string
uuid: string
}
export interface SmsCodeVO {
mobile: string
scene: number
}
export interface SmsLoginVO {
mobile: string
code: string
}
// 登录
2022-07-19 22:33:54 +08:00
export const loginApi = (data: UserLoginVO) => {
return request.post({ url: '/system/auth/login', data })
2022-07-18 19:06:37 +08:00
}
// 刷新访问令牌
export const refreshToken = () => {
2022-07-19 22:33:54 +08:00
return request.post({ url: '/system/auth/refresh-token?refreshToken=' + getRefreshToken() })
2022-07-18 19:06:37 +08:00
}
// 使用租户名,获得租户编号
export const getTenantIdByNameApi = (name: string) => {
2022-07-19 22:33:54 +08:00
return request.get({ url: '/system/tenant/get-id-by-name?name=' + name })
2022-07-18 19:06:37 +08:00
}
// 登出
export const loginOutApi = () => {
2023-01-16 17:00:48 +08:00
return request.post({ url: '/system/auth/logout' })
2022-07-18 19:06:37 +08:00
}
// 获取用户权限信息
export const getInfoApi = () => {
2022-07-19 22:33:54 +08:00
return request.get({ url: '/system/auth/get-permission-info' })
2022-07-18 19:06:37 +08:00
}
// 路由
export const getAsyncRoutesApi = () => {
2022-07-19 22:33:54 +08:00
return request.get({ url: '/system/auth/list-menus' })
2022-07-18 19:06:37 +08:00
}
//获取登录验证码
2022-07-19 22:33:54 +08:00
export const sendSmsCodeApi = (data: SmsCodeVO) => {
return request.post({ url: '/system/auth/send-sms-code', data })
2022-07-18 19:06:37 +08:00
}
// 短信验证码登录
2022-07-19 22:33:54 +08:00
export const smsLoginApi = (data: SmsLoginVO) => {
return request.post({ url: '/system/auth/sms-login', data })
2022-07-18 19:06:37 +08:00
}
2022-07-21 18:58:52 +08:00
// 社交授权的跳转
2022-12-06 21:30:44 +08:00
export const socialAuthRedirectApi = (type: number, redirectUri: string) => {
2022-07-21 18:58:52 +08:00
return request.get({
url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri
})
}
2022-11-17 10:12:50 +08:00
// 获取验证图片 以及token
export const getCodeApi = (data) => {
return request.postOriginal({ url: 'system/captcha/get', data })
}
// 滑动或者点选验证
export const reqCheckApi = (data) => {
return request.postOriginal({ url: 'system/captcha/check', data })
}