feat: refresh-token (#9286)

Co-authored-by: NFish <douxc512@gmail.com>
This commit is contained in:
Wu Tianwei
2024-10-12 23:40:38 +08:00
committed by GitHub
parent 70c5b23089
commit dbfbc56de7
8 changed files with 164 additions and 12 deletions

View File

@@ -38,8 +38,21 @@ import type {
import type { RETRIEVE_METHOD } from '@/types/app'
import type { SystemFeatures } from '@/types/feature'
export const login: Fetcher<CommonResponse & { data: string }, { url: string; body: Record<string, any> }> = ({ url, body }) => {
return post(url, { body }) as Promise<CommonResponse & { data: string }>
type LoginSuccess = {
result: 'success'
data: { access_token: string;refresh_token: string }
}
type LoginFail = {
result: 'fail'
data: string
}
type LoginResponse = LoginSuccess | LoginFail
export const login: Fetcher<LoginResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
return post(url, { body }) as Promise<LoginResponse>
}
export const fetchNewToken: Fetcher<CommonResponse & { data: { access_token: string; refresh_token: string } }, { body: Record<string, any> }> = ({ body }) => {
return post('/refresh-token', { body }) as Promise<CommonResponse & { data: { access_token: string; refresh_token: string } }>
}
export const setup: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {