diff --git a/src/app/(main)/cps/page.tsx b/src/app/(main)/cps/page.tsx index 87e18e0..b82f8b4 100644 --- a/src/app/(main)/cps/page.tsx +++ b/src/app/(main)/cps/page.tsx @@ -12,6 +12,7 @@ import { Input, InputNumber, Modal, + Popconfirm, Select, Space, Statistic, @@ -246,6 +247,16 @@ function GroupsTab() { const [createOpen, setCreateOpen] = useState(false); const [linkGroup, setLinkGroup] = useState(null); + const delGroup = async (g: CpsGroup) => { + try { + await api.delete(`/admin/api/cps/groups/${g.id}`); + message.success('已删除群'); + reload(); + } catch (e) { + message.error(errMsg(e)); + } + }; + const columns: ColumnsType = [ { title: 'ID', dataIndex: 'id', width: 60 }, { title: '群名', dataIndex: 'name', width: 160, ellipsis: true }, @@ -268,11 +279,22 @@ function GroupsTab() { title: '操作', key: 'op', fixed: 'right', - width: 150, + width: 200, render: (_, g) => ( e.stopPropagation()}> {canManage && setLinkGroup(g)}>生成链接} {canManage && setEditing(g)}>编辑} + {canManage && ( + delGroup(g)} + > + 删除 + + )} ), }, @@ -308,7 +330,7 @@ function GroupsTab() { showTotal: (t) => `共 ${t} 个群`, onChange, }} - scroll={{ x: 1040 }} + scroll={{ x: 1090 }} /> setCreateOpen(false)} onDone={reload} /> @@ -535,6 +557,16 @@ function ActivitiesTab() { const canManage = canDo(['operator']); const [createOpen, setCreateOpen] = useState(false); + const delActivity = async (a: CpsActivity) => { + try { + await api.delete(`/admin/api/cps/activities/${a.id}`); + message.success('已删除活动'); + reload(); + } catch (e) { + message.error(errMsg(e)); + } + }; + const columns: ColumnsType = [ { title: 'ID', dataIndex: 'id', width: 60 }, { @@ -575,6 +607,27 @@ function ActivitiesTab() { render: (s: string) => {s}, }, { title: '创建时间', dataIndex: 'created_at', width: 150, render: (v: string) => formatUtcTime(v) }, + ...(canManage + ? ([ + { + title: '操作', + key: 'op', + fixed: 'right' as const, + width: 80, + render: (_: unknown, a: CpsActivity) => ( + delActivity(a)} + > + 删除 + + ), + }, + ] as ColumnsType) + : []), ]; return ( @@ -599,7 +652,7 @@ function ActivitiesTab() { showTotal: (t) => `共 ${t} 个活动`, onChange, }} - scroll={{ x: 1080 }} + scroll={{ x: 1160 }} /> setCreateOpen(false)} onDone={reload} />