@@ -26,7 +26,7 @@ import {
2626 useDialog ,
2727 type MessageReactive ,
2828} from " naive-ui" ;
29- import { ref , watch } from " vue" ;
29+ import { h , ref , watch } from " vue" ;
3030import KeyCreateDialog from " ./KeyCreateDialog.vue" ;
3131import KeyDeleteDialog from " ./KeyDeleteDialog.vue" ;
3232
@@ -49,6 +49,7 @@ const pageSize = ref(12);
4949const total = ref (0 );
5050const totalPages = ref (0 );
5151const dialog = useDialog ();
52+ const confirmInput = ref (" " );
5253
5354// 状态过滤选项
5455const statusOptions = [
@@ -65,6 +66,7 @@ const moreOptions = [
6566 { type: " divider" },
6667 { label: " 恢复所有无效密钥" , key: " restoreAll" },
6768 { label: " 清空所有无效密钥" , key: " clearInvalid" , props: { style: { color: " #d03050" } } },
69+ { label: " 清空所有密钥" , key: " clearAll" , props: { style: { color: " red" , fontWeight: " bold" } } },
6870 { type: " divider" },
6971 { label: " 验证所有密钥" , key: " validateAll" },
7072 { label: " 验证有效密钥" , key: " validateActive" },
@@ -163,6 +165,9 @@ function handleMoreAction(key: string) {
163165 case " clearInvalid" :
164166 clearAllInvalid ();
165167 break ;
168+ case " clearAll" :
169+ clearAll ();
170+ break ;
166171 }
167172}
168173
@@ -464,6 +469,71 @@ async function clearAllInvalid() {
464469 });
465470}
466471
472+ async function clearAll() {
473+ if (! props .selectedGroup ?.id || isDeling .value ) {
474+ return ;
475+ }
476+
477+ dialog .warning ({
478+ title: " 清空所有密钥" ,
479+ content: " 此操作将永久删除该分组下的所有密钥,且不可恢复!确定要继续吗?" ,
480+ positiveText: " 确定" ,
481+ negativeText: " 取消" ,
482+ onPositiveClick : () => {
483+ confirmInput .value = " " ; // Reset before opening second dialog
484+ dialog .create ({
485+ title: " 请输入分组名称以确认" ,
486+ content : () =>
487+ h (" div" , null , [
488+ h (" p" , null , [
489+ " 这是一个非常危险的操作,将删除此分组下的" ,
490+ h (" strong" , null , " 所有" ),
491+ " 密钥。为防止误操作,请输入分组名称 " ,
492+ h (
493+ " strong" ,
494+ { style: { color: " #d03050" } },
495+ props .selectedGroup ! .name
496+ ),
497+ " 以确认。" ,
498+ ]),
499+ h (NInput , {
500+ value: confirmInput .value ,
501+ " onUpdate:value" : (v ) => {
502+ confirmInput .value = v ;
503+ },
504+ placeholder: " 请输入分组名称" ,
505+ }),
506+ ]),
507+ positiveText: " 确认清空" ,
508+ negativeText: " 取消" ,
509+ onPositiveClick : async () => {
510+ if (confirmInput .value !== props .selectedGroup ! .name ) {
511+ window .$message .error (" 分组名称输入不正确" );
512+ return false ; // Prevent dialog from closing
513+ }
514+
515+ if (! props .selectedGroup ?.id ) {
516+ return ;
517+ }
518+
519+ isDeling .value = true ;
520+ try {
521+ await keysApi .clearAllKeys (props .selectedGroup .id );
522+ window .$message .success (" 已成功清空所有密钥" );
523+ await loadKeys ();
524+ // Trigger sync operation refresh
525+ triggerSyncOperationRefresh (props .selectedGroup .name , " CLEAR_ALL" );
526+ } catch (_error ) {
527+ console .error (" 清空失败" , _error );
528+ } finally {
529+ isDeling .value = false ;
530+ }
531+ },
532+ });
533+ },
534+ });
535+ }
536+
467537function changePage(page : number ) {
468538 currentPage .value = page ;
469539}
0 commit comments