Files
shanxia2.0/mobile-h5/src/api/authApi.ts
T
zlwuandCursor c3f183cfba feat(mobile-h5): adapt portal RSA login and split db HTTP client
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>
2026-08-03 22:33:46 +08:00

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 }
})
}