- 更新API服务配置(api/login.ts) - 优化HTTP服务配置(http/alova.ts, config.ts, handle.ts) - 完善认证状态管理(store/auth.ts) - 优化路由状态管理(store/router/) 加强服务层架构和状态管理机制
85 lines
2.0 KiB
TypeScript
85 lines
2.0 KiB
TypeScript
import { request } from '../http'
|
|
|
|
interface LoginRequest {
|
|
loginName: string
|
|
password: string
|
|
codeKey: string
|
|
securityCode: string
|
|
rememberMe?: boolean
|
|
}
|
|
|
|
interface RegisterRequest {
|
|
loginName: string
|
|
password: string
|
|
userName: string
|
|
codeKey: string
|
|
securityCode: string
|
|
}
|
|
|
|
interface LoginResponse {
|
|
tokenName: string
|
|
tokenValue: string
|
|
}
|
|
|
|
interface CaptchaResponse {
|
|
codeKey: string
|
|
captchaPicture: string
|
|
captchaText?: string
|
|
}
|
|
|
|
export function fetchLogin(data: LoginRequest) {
|
|
const methodInstance = request.Post<Service.ResponseResult<LoginResponse>>('/auth/login', data)
|
|
methodInstance.meta = {
|
|
authRole: null,
|
|
}
|
|
return methodInstance
|
|
}
|
|
|
|
export function fetchLogout() {
|
|
return request.Get<Service.ResponseResult<string>>('/auth/logout')
|
|
}
|
|
|
|
export function fetchRegister(data: RegisterRequest) {
|
|
const methodInstance = request.Post<Service.ResponseResult<string>>('/auth/register', data)
|
|
methodInstance.meta = {
|
|
authRole: null,
|
|
}
|
|
return methodInstance
|
|
}
|
|
|
|
export function fetchUpdateToken(data: any) {
|
|
const method = request.Post<Service.ResponseResult<LoginResponse>>('/updateToken', data)
|
|
method.meta = {
|
|
authRole: 'refreshToken',
|
|
}
|
|
return method
|
|
}
|
|
|
|
export function fetchUserRoutesOld(params: { id: number }) {
|
|
return request.Get<Service.ResponseResult<AppRoute.RowRoute[]>>('/getUserRoutes', { params })
|
|
}
|
|
|
|
export function fetchLoginUserInfo() {
|
|
return request.Get<Service.ResponseResult<Api.Login.Info>>('/coder/sysLoginUser/getLoginUserInformation')
|
|
}
|
|
|
|
// 验证码相关接口
|
|
|
|
// 获取PNG格式验证码
|
|
export function fetchCaptchaPng() {
|
|
const methodInstance = request.Get<Service.ResponseResult<CaptchaResponse>>('/captcha/png')
|
|
methodInstance.meta = {
|
|
authRole: null,
|
|
}
|
|
return methodInstance
|
|
}
|
|
|
|
// 获取GIF格式验证码
|
|
export function fetchCaptchaGif() {
|
|
const methodInstance = request.Get<Service.ResponseResult<CaptchaResponse>>('/captcha/gif')
|
|
methodInstance.meta = {
|
|
authRole: null,
|
|
}
|
|
return methodInstance
|
|
}
|