Wire login to /web/auth/login with JSEncrypt, unwrap portal envelopes, and add a direct-JSON db client for weighbridge APIs. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
880 B
TypeScript
40 lines
880 B
TypeScript
import api from '@/utils/http'
|
|
import { buildWebEncryptedLoginBody } from '@/utils/loginRsa'
|
|
|
|
export interface PortalUserInfo {
|
|
id: string
|
|
username: string
|
|
realName?: string
|
|
phone?: string
|
|
role?: string
|
|
avatarUrl?: string | null
|
|
}
|
|
|
|
export interface LoginResult {
|
|
token: string
|
|
refreshToken: string
|
|
expiresIn: number
|
|
userInfo: PortalUserInfo
|
|
}
|
|
|
|
/** 门户 RSA 登录 */
|
|
export async function fetchLogin(username: string, password: string): Promise<LoginResult> {
|
|
const body = await buildWebEncryptedLoginBody(username, password)
|
|
return api.post<LoginResult>({
|
|
url: '/web/auth/login',
|
|
data: body
|
|
})
|
|
}
|
|
|
|
/** 刷新 Token */
|
|
export async function fetchRefreshToken(refreshToken: string) {
|
|
return api.post<{
|
|
token: string
|
|
refreshToken: string
|
|
expiresIn: number
|
|
}>({
|
|
url: '/web/auth/refresh-token',
|
|
data: { refreshToken }
|
|
})
|
|
}
|