fix: Memory.vue stats fallback and error handling
This commit is contained in:
@@ -208,11 +208,11 @@ async function loadData() {
|
|||||||
confidenceStats.low = res.data.stats.low || 0
|
confidenceStats.low = res.data.stats.low || 0
|
||||||
confidenceStats.total = res.data.stats.total || 0
|
confidenceStats.total = res.data.stats.total || 0
|
||||||
} else {
|
} else {
|
||||||
// Fallback: compute from current page items
|
// Fallback: stats not available from server, default to 0
|
||||||
confidenceStats.high = items.value.filter(i => i.confidence > 50).length
|
confidenceStats.high = 0
|
||||||
confidenceStats.medium = items.value.filter(i => i.confidence >= 10 && i.confidence <= 50).length
|
confidenceStats.medium = 0
|
||||||
confidenceStats.low = items.value.filter(i => i.confidence < 10).length
|
confidenceStats.low = 0
|
||||||
confidenceStats.total = total.value
|
confidenceStats.total = 0
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
ElMessage.error('加载失败')
|
ElMessage.error('加载失败')
|
||||||
@@ -288,7 +288,9 @@ async function deleteItem(row: any) {
|
|||||||
await api.delete(`/memory/${row.barcode}`)
|
await api.delete(`/memory/${row.barcode}`)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
loadData()
|
loadData()
|
||||||
} catch {}
|
} catch (err: any) {
|
||||||
|
if (err !== 'cancel') ElMessage.error('删除失败')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reimport() {
|
async function reimport() {
|
||||||
|
|||||||
Reference in New Issue
Block a user