fix: resolve ui audit bugs
ci / docker (push) Successful in 3m30s

This commit is contained in:
2026-09-07 09:08:22 +08:00
parent 6f7694c23e
commit ec90e9155e
7 changed files with 119 additions and 16 deletions
+28
View File
@@ -93,3 +93,31 @@ export function calendarModeLabel(mode: string) {
export function shouldToggleRowSwipe(deltaX: number, deltaY: number) {
return deltaX >= 64 && deltaX > Math.abs(deltaY) * 1.5
}
export function nextTotalAfterLocalTaskAdd(total: number) {
return Math.max(0, Number(total) || 0) + 1
}
export function formatApiErrorDetail(detail: unknown): string {
if (typeof detail === 'string') return detail
if (Array.isArray(detail)) {
const messages = detail.map((item) => {
if (item && typeof item === 'object') {
const record = item as Record<string, unknown>
const location = Array.isArray(record.loc)
? record.loc.filter((part) => part !== 'body').join('.')
: ''
const message = typeof record.msg === 'string' ? record.msg : JSON.stringify(record)
return location ? `${location}${message}` : message
}
return String(item)
})
return messages.filter(Boolean).join('') || '请求参数有误'
}
if (detail && typeof detail === 'object') {
const record = detail as Record<string, unknown>
if ('detail' in record) return formatApiErrorDetail(record.detail)
return JSON.stringify(record)
}
return '请求失败'
}