fix: 分类管理图标可选项+编辑修复
- 图标默认改为空(可选,占位符标注)
- 编辑时正确解构各字段(避免多余字段干扰)
- 后端 icon 为空时自动回退🔗
- 后端 sort 为 null 时自动回退0
This commit is contained in:
@@ -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: '更新失败' });
|
||||
|
||||
Reference in New Issue
Block a user