fix: 分类管理图标可选项+编辑修复

- 图标默认改为空(可选,占位符标注)
- 编辑时正确解构各字段(避免多余字段干扰)
- 后端 icon 为空时自动回退🔗
- 后端 sort 为 null 时自动回退0
This commit is contained in:
Agent
2026-07-15 09:29:57 +08:00
parent 9590231e21
commit 0cdcb7cf5b
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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: '更新失败' });