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.

75 lines
1.6 KiB

import type { LoginParams, LoginResult, UserInfo } from './types'
import { defHttp } from '@/utils/http/axios'
import type { ErrorMessageMode } from '@/types/axios'
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
return defHttp.post<LoginResult>({
url: '/deframe-auth/oauth/token',
params: {
username: params.username,
password: params.password,
grant_type: 'captcha',
scope: 'all',
type: 'account',
},
headers: {
'Tenant-Id': params.tenantId,
'Captcha-Key': params.captchaKey,
'Captcha-Code': params.captchaCode,
},
}, {
errorMessageMode: mode,
joinParamsToUrl: true,
isTransformResponse: false,
})
}
export function getUserInfo() {
return defHttp.get<UserInfo>({
url: '/system/permission/get-permission-info',
}, {
errorMessageMode: 'none',
})
}
export interface __MenuItem {
id: string
parentId: string
code: string
name: string
alias: string
path: string
source: string
sort: number
category: number
action: number
children?: __MenuItem[]
}
export function getUserRouters() {
return defHttp.get<__MenuItem[]>({
url: '/deframe-system/menu/routes',
})
}
export function getUserButtons() {
return defHttp.get({
url: '/deframe-system/menu/buttons',
})
}
export function doLogout() {
return defHttp.post({
url: '/auth/logout',
})
}
export function getLoginCaptcha() {
return defHttp.get<{ image: string, key: string }>({
url: '/deframe-auth/oauth/captcha',
}, {
isTransformResponse: false,
withoutAuth: true,
})
}