8484 <Icon name="ri:arrow-right-s-line " class="ml-2" />
8585 </n-button >
8686 </n-button-group >
87- <object-info ref =" infoRef" />
87+ <object-info ref =" infoRef" @refresh-parent = " handleObjectDeleted " />
8888</template >
8989
9090<script setup lang="ts">
@@ -233,7 +233,7 @@ const columns: DataTableColumns<RowData> = [
233233 title: t (' Actions' ),
234234 key: ' actions' ,
235235 align: ' center' ,
236- width: 100 ,
236+ width: 150 ,
237237 render : (row : RowData ) => {
238238 return h (
239239 NSpace ,
@@ -258,6 +258,37 @@ const columns: DataTableColumns<RowData> = [
258258 ),
259259 }
260260 ),
261+ // 删除按钮 - 文件和文件夹都显示
262+ h (
263+ NPopconfirm ,
264+ { onPositiveClick : () => handleDeleteAllVersions (row ) },
265+ {
266+ default : () =>
267+ h (' div' , [
268+ h (
269+ ' div' ,
270+ { style: ' margin-bottom: 8px;' },
271+ row .type === ' object' ? t (' Delete All Versions Warning' ) : t (' Warning' )
272+ ),
273+ h (
274+ ' div' ,
275+ { style: ' color: #666; font-size: 12px;' },
276+ row .type === ' object'
277+ ? t (' Delete All Versions Description' )
278+ : t (' Are you sure you want to delete this folder and all its contents?' )
279+ ),
280+ ]),
281+ trigger : () =>
282+ h (
283+ NButton ,
284+ { size: ' small' , type: ' error' , secondary: true },
285+ {
286+ default : () => ' ' ,
287+ icon : () => h (Icon , { name: ' ri:delete-bin-5-line' }),
288+ }
289+ ),
290+ }
291+ ),
261292 ],
262293 }
263294 );
@@ -349,6 +380,51 @@ const filteredObjects = computed(() => {
349380 });
350381});
351382
383+ /** ************************************处理对象删除********************************* */
384+ // 处理对象被删除(从版本组件触发)
385+ const handleObjectDeleted = () => {
386+ // 刷新文件列表
387+ salt .value = randomString ();
388+ refresh ();
389+ };
390+
391+ /** ************************************删除所有版本********************************* */
392+ // 删除文件的所有版本或文件夹及其内容
393+ const handleDeleteAllVersions = async (row : RowData ) => {
394+ try {
395+ if (row .type === ' object' ) {
396+ // 删除文件的所有版本
397+ const { deleteAllVersions } = useObject ({ bucket: bucketName .value });
398+ await deleteAllVersions (row .Key );
399+ message .success (t (' Delete All Versions Success' ));
400+ } else if (row .type === ' prefix' ) {
401+ // 删除文件夹及其所有内容
402+ const { mapAllFiles } = useObject ({ bucket: bucketName .value });
403+ const files: string [] = [];
404+
405+ // 递归收集文件夹下的所有文件
406+ await mapAllFiles (bucketName .value , row .Key , (fileKey : string ) => {
407+ files .push (fileKey );
408+ });
409+
410+ if (files .length > 0 ) {
411+ // 使用删除任务管理器删除所有文件
412+ deleteTaskStore .addKeys (files , bucketName .value );
413+ message .success (t (' Delete task created' ));
414+ } else {
415+ message .success (t (' Delete Success' ));
416+ }
417+ }
418+
419+ // 刷新数据
420+ salt .value = randomString ();
421+ refresh ();
422+ } catch (error : any ) {
423+ console .error (' Delete failed:' , error );
424+ message .error (t (' Delete Failed' ));
425+ }
426+ };
427+
352428/** ************************************批量删除********************************* */
353429function rowKey(row : any ): string {
354430 return row .Key || ' ' ;
0 commit comments