feat(bx-mobile): finish portal login page and normalize current-user fields

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-08-09 16:06:43 +08:00
1 parent 3f1faeae34
commit a4f04ff297
2 files changed
+19 -5

No files matched your search

+11 -2
View File
@@ -83,13 +83,22 @@ export const useAuthStore = defineStore('auth', () => {
async function fetchUser() {
try {
const res: any = await portalAuthApi.currentUser()
user.value = res.data
const d = res.data || {}
user.value = {
id: String(d.id || d.userId || ''),
username: d.username || d.userName || '',
realName: d.realName || d.username || '',
phone: d.phone,
role: d.role,
roles: d.roles || [],
avatarUrl: d.avatarUrl,
}
const perm: any = await portalAuthApi.menuCodes()
isSuperAdmin.value = !!perm.data?.isSuperAdmin
allMenus.value = !!perm.data?.all
menuCodes.value = perm.data?.menuCodes || []
} catch {
logout()
await logout()
}
}
+8 -3
View File
@@ -59,7 +59,7 @@ import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { showToast } from 'vant'
import { useAuthStore } from '@/stores/auth'
import { BizError } from '@/api/client'
import { PortalError } from '@/api/portalClient'
const router = useRouter()
const auth = useAuthStore()
@@ -81,9 +81,14 @@ async function handleLogin() {
showToast('登录成功')
router.replace('/')
} catch (e: any) {
const detail = e?.response?.data?.detail || e?.response?.data?.msg || ''
const detail =
e?.response?.data?.message ||
e?.response?.data?.msg ||
e?.response?.data?.detail ||
''
errorText.value = detail || e.message || '账号或密码错误'
if (!(e instanceof BizError)) {
// PortalError:拦截器已 toast,避免双提示
if (!(e instanceof PortalError)) {
showToast(errorText.value)
}
} finally {