From 0cdcb7cf5b57b16b876c22f6074b1b92977b6adc Mon Sep 17 00:00:00 2001 From: Agent Date: Wed, 15 Jul 2026 09:29:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=86=E7=B1=BB=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=8F=AF=E9=80=89=E9=A1=B9+=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E5=A4=8D=20-=20=E5=9B=BE=E6=A0=87=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=94=B9=E4=B8=BA=E7=A9=BA=EF=BC=88=E5=8F=AF=E9=80=89?= =?UTF-8?q?=EF=BC=8C=E5=8D=A0=E4=BD=8D=E7=AC=A6=E6=A0=87=E6=B3=A8=EF=BC=89?= =?UTF-8?q?=20-=20=E7=BC=96=E8=BE=91=E6=97=B6=E6=AD=A3=E7=A1=AE=E8=A7=A3?= =?UTF-8?q?=E6=9E=84=E5=90=84=E5=AD=97=E6=AE=B5=EF=BC=88=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E5=AD=97=E6=AE=B5=E5=B9=B2=E6=89=B0=EF=BC=89?= =?UTF-8?q?=20-=20=E5=90=8E=E7=AB=AF=20icon=20=E4=B8=BA=E7=A9=BA=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=9B=9E=E9=80=80=F0=9F=94=97=20-=20?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=20sort=20=E4=B8=BA=20null=20=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=9B=9E=E9=80=800?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/routes/api.js | 2 +- frontend/src/views/admin/Categories.vue | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/routes/api.js b/backend/src/routes/api.js index a077d34..fa456ab 100644 --- a/backend/src/routes/api.js +++ b/backend/src/routes/api.js @@ -118,7 +118,7 @@ const router = (app) => { app.put('/api/admin/categories/:id', authenticate, async (req, res) => { try { const { name, icon, sort } = req.body; - await pool.query('UPDATE categories SET name = ?, icon = ?, sort = ? WHERE id = ?', [name, icon, sort, Number(req.params.id)]); + await pool.query('UPDATE categories SET name = ?, icon = ?, sort = ? WHERE id = ?', [name, icon || '🔗', sort ?? 0, Number(req.params.id)]); res.json({ status: 200, message: '更新成功' }); } catch { res.json({ status: 500, message: '更新失败' }); diff --git a/frontend/src/views/admin/Categories.vue b/frontend/src/views/admin/Categories.vue index 50ebbd6..6b0bd93 100644 --- a/frontend/src/views/admin/Categories.vue +++ b/frontend/src/views/admin/Categories.vue @@ -26,7 +26,7 @@ - + @@ -52,7 +52,7 @@ import { adminApi } from '@/api' const categories = ref([]) const dialogVisible = ref(false) const editId = ref(null) -const form = ref({ icon: '🔗', name: '', sort: 0 }) +const form = ref({ icon: '', name: '', sort: 0 }) const dialogWidth = computed(() => window.innerWidth < 500 ? '92%' : '420px') async function load() { @@ -61,7 +61,7 @@ async function load() { function openDialog(row?: any) { editId.value = row?.id || null - form.value = row || { icon: '🔗', name: '', sort: 0 } + form.value = row ? { icon: row.icon || '', name: row.name || '', sort: row.sort ?? 0 } : { icon: '', name: '', sort: 0 } dialogVisible.value = true }