From d1cbecfe98ddc4010cd04a38fcdedf26ae92f1b3 Mon Sep 17 00:00:00 2001 From: Agent Date: Wed, 15 Jul 2026 00:00:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=93=BE=E6=8E=A5=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=EF=BC=88=E5=88=A0=E9=99=A4/=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=88=86=E7=B1=BB=EF=BC=89=20-=20=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=20batch-delete=20+=20batch-move=20=E6=8E=A5=E5=8F=A3=20-=20?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=A4=9A=E9=80=89checkbox=20+=20=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=93=8D=E4=BD=9C=E6=A0=8F=20-=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=EF=BC=88=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=EF=BC=89=20-=20=E6=94=AF=E6=8C=81=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E7=A7=BB=E5=8A=A8=E5=88=86=E7=B1=BB=20-=20=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E5=90=8E=E8=87=AA=E5=8A=A8=E6=98=BE=E7=A4=BA=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=A0=8F=EF=BC=8C=E5=8F=96=E6=B6=88=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=94=B6=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/routes/api.js | 25 +++++++++++++++++ frontend/src/api/index.ts | 2 ++ frontend/src/views/admin/Links.vue | 44 +++++++++++++++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/api.js b/backend/src/routes/api.js index 98b6c1e..a077d34 100644 --- a/backend/src/routes/api.js +++ b/backend/src/routes/api.js @@ -196,6 +196,31 @@ const router = (app) => { } }); + // 批量删除链接 + app.post('/api/admin/links/batch-delete', authenticate, async (req, res) => { + try { + const ids = (req.body.ids || []).map(Number).filter(Boolean); + if (ids.length === 0) return res.json({ status: 400, message: '请选择链接' }); + await pool.query(`DELETE FROM links WHERE id IN (${ids.map(() => '?').join(',')})`, ids); + res.json({ status: 200, message: `已删除 ${ids.length} 条链接` }); + } catch { + res.json({ status: 500, message: '删除失败' }); + } + }); + + // 批量移动分类 + app.post('/api/admin/links/batch-move', authenticate, async (req, res) => { + try { + const ids = (req.body.ids || []).map(Number).filter(Boolean); + const categoryId = Number(req.body.categoryId); + if (ids.length === 0 || !categoryId) return res.json({ status: 400, message: '参数不完整' }); + await pool.query(`UPDATE links SET category_id = ? WHERE id IN (${ids.map(() => '?').join(',')})`, [categoryId, ...ids]); + res.json({ status: 200, message: `已移动 ${ids.length} 条链接` }); + } catch { + res.json({ status: 500, message: '移动失败' }); + } + }); + app.get('/api/admin/settings', authenticate, async (req, res) => { try { const [sets] = await pool.query('SELECT * FROM settings'); diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 18a05c0..083ffcb 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -48,6 +48,8 @@ export const adminApi = { updateLink: (id: number, data: any) => request.put(`/admin/links/${id}`, data), deleteLink: (id: number) => request.delete(`/admin/links/${id}`), updateSorts: (sorts: any[]) => request.put('/admin/links/sort', { sorts }), + batchDelete: (ids: number[]) => request.post('/admin/links/batch-delete', { ids }), + batchMove: (ids: number[], categoryId: number) => request.post('/admin/links/batch-move', { ids, categoryId }), getSettings: () => request.get('/admin/settings'), updateSettings: (data: any) => request.put('/admin/settings', data), } diff --git a/frontend/src/views/admin/Links.vue b/frontend/src/views/admin/Links.vue index 1496cd5..5b1d42a 100644 --- a/frontend/src/views/admin/Links.vue +++ b/frontend/src/views/admin/Links.vue @@ -23,7 +23,17 @@
- +
+ 已选 {{ selectedIds.length }} 条 + 批量删除 + + + + 移动 + 取消选择 +
+ +