fix: add error handling to Barcodes, Tasks, Logs, Sync views

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-12 21:41:50 +08:00
parent d94e416202
commit 3f8e34c07f
4 changed files with 13 additions and 5 deletions
+4 -2
View File
@@ -183,7 +183,7 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Search, Refresh, Plus, Connection, Right, Setting } from '@element-plus/icons-vue'
import { Search, Refresh, Connection, Right, Setting } from '@element-plus/icons-vue'
import api from '../api'
import { useDebounce } from '../composables/useDebounce'
@@ -337,7 +337,9 @@ async function deleteItem(row: any) {
await api.delete(`/barcodes/${row.barcode}`)
ElMessage.success('已删除')
loadData()
} catch {}
} catch (err: any) {
if (err !== 'cancel') ElMessage.error('删除失败')
}
}
onMounted(loadData)
+3 -1
View File
@@ -152,7 +152,9 @@ async function loadStats() {
try {
const res = await api.get('/logs/stats')
Object.assign(logStats, res.data)
} catch {}
} catch {
ElMessage.error('加载统计数据失败')
}
}
onMounted(() => {
+3 -1
View File
@@ -123,7 +123,9 @@ async function checkStatus() {
try {
const res = await api.get('/sync/status')
syncStatus.value = res.data
} catch {}
} catch {
ElMessage.error('检查同步状态失败')
}
}
async function doPush() {
+3 -1
View File
@@ -195,7 +195,9 @@ async function loadStats() {
try {
const res = await api.get('/tasks/stats')
Object.assign(taskStats, res.data)
} catch {}
} catch {
ElMessage.error('加载统计数据失败')
}
}
function showDetail(row: any) {