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>
This commit is contained in:
1 parent
a4b13fa2bc
commit
c3f183cfba
6 files changed
+208
-95
No files matched your search
@@ -0,0 +1,39 @@
|
||||
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 }
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user