You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import axios from 'axios' ;
import {
getTokenParams ,
getLinkParams ,
UserState ,
LoginRes ,
authParams
} from '@/api/interface' ;
// 修复window is not defined错误, 确保只在浏览器环境中访问window对象
const defaultReqData : authParams = typeof window !== 'undefined' ? {
domain : window.location.hostname ,
path : '/'
} : {
domain : 'localhost' ,
path : '/'
} ;
const urlPrefix = '/api/v1/bpms-workbench' ;
export function getToken ( params : getTokenParams ) {
return axios . get < LoginRes > ( ` ${ urlPrefix } /sessions/callback ` , {
params : { . . . params , . . . defaultReqData }
} ) ;
}
export function getAuthLink ( params : getLinkParams ) {
return axios . get < string > ( ` ${ urlPrefix } /sessions/auth/url ` , {
params
} ) ;
}
export function getUserInfo() {
return axios . get < UserState > ( ` ${ urlPrefix } /sessions/info ` ) ;
}
export function logout() {
return axios . get < LoginRes > ( ` ${ urlPrefix } /sessions/logout ` , {
params : defaultReqData
} ) ;
}
export function getUserToken() {
return axios . get < LoginRes > ( ` ${ urlPrefix } /sessions/validate ` , { } ) ;
}