@@ -11,6 +11,8 @@ import type { DataTableColumns, PaginationProps } from 'naive-ui';
1111import type { SortState } from ' naive-ui/es/data-table/src/interface' ;
1212import pLimit from ' p-limit' ;
1313import JSON5 from ' json5' ;
14+ import SvgIcon from ' @/components/SvgIcon.vue' ;
15+ import { dialog } from ' @/utils/discrete' ;
1416
1517const router = useRouter ();
1618const { api, origin, serverInfo } = useDeviceApi ();
@@ -137,7 +139,7 @@ const columns: DataTableColumns<Snapshot> = [
137139 key: ` actions ` ,
138140 title: ` 操作 ` ,
139141 fixed: ' right' ,
140- width: ` 120px ` ,
142+ width: ` 180px ` , // 搞宽点要不然装不下
141143 render(row ) {
142144 return (
143145 <NSpace size = " small" >
@@ -148,12 +150,49 @@ const columns: DataTableColumns<Snapshot> = [
148150 >
149151 查看
150152 </NButton >
153+ <NButton
154+ size = " small"
155+ type = " error"
156+ secondary
157+ loading = { deleteSnapshot .loading [row .id ]}
158+ onClick = { () => deleteSnapshot .invoke (row )}
159+ >
160+ { {
161+ icon : () => <SvgIcon name = " delete" />,
162+ default : () => ' 删除' ,
163+ }}
164+ </NButton >
151165 </NSpace >
152166 );
153167 },
154168 },
155169];
156170
171+ const deleteSnapshot = useBatchTask (
172+ async (row : Snapshot ) => {
173+ const confirmed = await new Promise <boolean >((res ) => {
174+ dialog .warning ({
175+ title: ' 删除快照' ,
176+ content: ` 是否确认删除快照 ID: ${row .id }?此操作不可恢复。 ` ,
177+ positiveText: ' 确认删除' ,
178+ negativeText: ' 取消' ,
179+ onPositiveClick : () => res (true ),
180+ onNegativeClick : () => res (false ),
181+ onClose : () => res (false ),
182+ });
183+ });
184+ if (! confirmed ) return ;
185+ await api .deleteSnapshot ({ id: row .id });
186+ await Promise .all ([
187+ snapshotStorage .removeItem (row .id ),
188+ screenshotStorage .removeItem (row .id ),
189+ ]);
190+ snapshots .value = snapshots .value .filter ((s ) => s .id !== row .id );
191+ message .success (' 删除成功' );
192+ },
193+ (r ) => r .id ,
194+ );
195+
157196const pagination = shallowReactive <PaginationProps >({
158197 page: 1 ,
159198 pageSize: 50 ,
0 commit comments