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.
106 lines
2.5 KiB
106 lines
2.5 KiB
import { getRefreshToken } from '@/utils/auth' |
|
import { systemServer } from '../../index' |
|
|
|
type UserLoginVO = { |
|
username: string |
|
password: string |
|
captchaVerification: string |
|
socialType?: string |
|
socialCode?: string |
|
socialState?: string |
|
} |
|
|
|
export interface LoginRequestData { |
|
username: string |
|
password: string |
|
// tenantName: string |
|
// captchaVerification: string |
|
// rememberMe: boolean |
|
} |
|
export interface SmsCodeVO { |
|
mobile: string |
|
scene: number |
|
} |
|
|
|
export interface SmsLoginVO { |
|
mobile: string |
|
code: string |
|
} |
|
interface LoginResponse { |
|
accessToken: string |
|
expiresTime: number |
|
refreshToken: string |
|
userId: number |
|
} |
|
|
|
export const getTenantId = (name: string) => |
|
systemServer<number>({ |
|
url: '/tenant/get-id-by-name', |
|
method: 'get', |
|
params: { |
|
name, |
|
}, |
|
}) |
|
|
|
export const login = (data: any) => |
|
systemServer<LoginResponse>({ |
|
method: 'post', |
|
url: '/auth/login', |
|
data, |
|
}) |
|
|
|
// 刷新访问令牌 |
|
export const refreshToken = () => |
|
systemServer({ |
|
url: '/auth/refresh-token?refreshToken=' + getRefreshToken(), |
|
method: 'post', |
|
}) |
|
|
|
// // 使用租户域名,获得租户信息 |
|
// export const getTenantByWebsite = (website: string) => { |
|
// return request.get({ url: '/tenant/get-by-website?website=' + website }) |
|
// } |
|
|
|
// // 登出 |
|
export const loginOut = () => systemServer({ url: '/auth/logout', method: 'post' }) |
|
|
|
export const getInfo = () => |
|
systemServer({ url: '/auth/get-permission-info', method: 'get' }) |
|
|
|
// //获取登录验证码 |
|
export const sendSmsCode = (data: SmsCodeVO) => { |
|
return systemServer({ url: '/auth/send-sms-code', method: 'post', data }) |
|
} |
|
|
|
// // 短信验证码登录 |
|
export const smsLogin = (data: SmsLoginVO) => { |
|
return systemServer({ url: '/auth/sms-login', method: 'post', data }) |
|
} |
|
|
|
// // 社交快捷登录,使用 code 授权码 |
|
// export function socialLogin(type: string, code: string, state: string) { |
|
// return request.post({ |
|
// url: '/auth/social-login', |
|
// data: { |
|
// type, |
|
// code, |
|
// state |
|
// } |
|
// }) |
|
// } |
|
|
|
// // 社交授权的跳转 |
|
// export const socialAuthRedirect = (type: number, redirectUri: string) => { |
|
// return request.get({ |
|
// url: '/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri |
|
// }) |
|
// } |
|
// // 获取验证图片以及 token |
|
// export const getCode = (data) => { |
|
// return request.postOriginal({ url: 'system/captcha/get', data }) |
|
// } |
|
|
|
// // 滑动或者点选验证 |
|
// export const reqCheck = (data) => { |
|
// return request.postOriginal({ url: 'system/captcha/check', data }) |
|
// }
|
|
|