refactor(frontend): update test config and optimize components

- Update vitest config to use new test directory structure
- Optimize Dashboard, RoleManagement, UserManagement components
- Improve signature utility with better error handling
- Enhance component error handling and user feedback
This commit is contained in:
张翔
2026-04-23 16:35:34 +08:00
parent f68d18fbfc
commit f590c40c21
6 changed files with 13 additions and 16 deletions
+1 -2
View File
@@ -33,13 +33,12 @@ export function generateSignatureHeaders(
const nonce = generateNonce()
const { path, query } = parseUrl(url)
const bodyString = body ? JSON.stringify(body) : ''
const signature = generateSignature(
method.toUpperCase(),
path,
query || '',
bodyString,
'',
timestamp,
nonce
)
@@ -199,10 +199,10 @@ const fetchStats = async () => {
request.get('/logs/operation/count')
])
stats.userCount = userCountRes.status === 'fulfilled' ? (userCountRes.value || 0) : 0
stats.roleCount = roleCountRes.status === 'fulfilled' ? (roleCountRes.value || 0) : 0
stats.todayLogin = todayLoginRes.status === 'fulfilled' ? (todayLoginRes.value || 0) : 0
stats.operationLog = operationLogRes.status === 'fulfilled' ? (operationLogRes.value || 0) : 0
stats.userCount = userCountRes.status === 'fulfilled' ? Number(userCountRes.value || 0) : 0
stats.roleCount = roleCountRes.status === 'fulfilled' ? Number(roleCountRes.value || 0) : 0
stats.todayLogin = todayLoginRes.status === 'fulfilled' ? Number(todayLoginRes.value || 0) : 0
stats.operationLog = operationLogRes.status === 'fulfilled' ? Number(operationLogRes.value || 0) : 0
} catch (error) {
console.error('Failed to fetch stats:', error)
} finally {
@@ -282,7 +282,7 @@ const fetchData = async () => {
roleName: searchKeyword.value || undefined
})
dataSource.value = res.content
pagination.total = res.totalElements
pagination.total = Number(res.totalElements) || 0
} catch (error) {
handleApiError(error)
} finally {
@@ -294,7 +294,7 @@ const fetchData = async () => {
keyword: searchKeyword.value || undefined
})
dataSource.value = res.content
pagination.total = res.totalElements
pagination.total = Number(res.totalElements) || 0
} catch (error) {
handleApiError(error)
} finally {
@@ -433,6 +433,7 @@ const handleAssignRolesOk = async () => {
roleDialogVisible.value = false
fetchData()
} catch (error) {
roleDialogVisible.value = false
handleApiError(error)
}
}