|
46 | 46 | <el-button @click="open = false" :disabled="loading"> |
47 | 47 | {{ $t('commons.button.cancel') }} |
48 | 48 | </el-button> |
49 | | - <el-button type="primary" @click="onConfirm" :disabled="loading"> |
| 49 | + <el-button type="primary" @click="onConfirm" :loading="loading" :disabled="loading"> |
50 | 50 | {{ $t('commons.button.confirm') }} |
51 | 51 | </el-button> |
52 | 52 | </span> |
@@ -101,37 +101,43 @@ const getStatus = async () => { |
101 | 101 | }; |
102 | 102 |
|
103 | 103 | const onConfirm = async () => { |
104 | | - const pros = []; |
105 | | - for (const s of files.value) { |
106 | | - if (s['isDir']) { |
107 | | - if (s['path'].indexOf('.1panel_clash') > -1) { |
108 | | - MsgWarning(i18n.global.t('file.clashDeleteAlert')); |
109 | | - return; |
110 | | - } |
| 104 | + loading.value = true; |
| 105 | + try { |
| 106 | + const pros = []; |
| 107 | + let baseDir = ''; |
| 108 | + if (files.value.some((item) => item['isDir'])) { |
111 | 109 | const pathRes = await loadBaseDir(); |
112 | | - if (s['path'] === pathRes.data) { |
113 | | - MsgWarning(i18n.global.t('file.panelInstallDir')); |
114 | | - return; |
115 | | - } |
| 110 | + baseDir = pathRes.data; |
116 | 111 | } |
117 | | - if (reqNode.value != '') { |
118 | | - pros.push( |
119 | | - deleteFileByNode({ path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value }, reqNode.value), |
120 | | - ); |
121 | | - } else { |
122 | | - pros.push(deleteFile({ path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value })); |
| 112 | + for (const s of files.value) { |
| 113 | + if (s['isDir']) { |
| 114 | + if (s['path'].indexOf('.1panel_clash') > -1) { |
| 115 | + MsgWarning(i18n.global.t('file.clashDeleteAlert')); |
| 116 | + return; |
| 117 | + } |
| 118 | + if (s['path'] === baseDir) { |
| 119 | + MsgWarning(i18n.global.t('file.panelInstallDir')); |
| 120 | + return; |
| 121 | + } |
| 122 | + } |
| 123 | + if (reqNode.value != '') { |
| 124 | + pros.push( |
| 125 | + deleteFileByNode( |
| 126 | + { path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value }, |
| 127 | + reqNode.value, |
| 128 | + ), |
| 129 | + ); |
| 130 | + } else { |
| 131 | + pros.push(deleteFile({ path: s['path'], isDir: s['isDir'], forceDelete: forceDelete.value })); |
| 132 | + } |
123 | 133 | } |
| 134 | + await Promise.all(pros); |
| 135 | + MsgSuccess(i18n.global.t('commons.msg.deleteSuccess')); |
| 136 | + open.value = false; |
| 137 | + em('close'); |
| 138 | + } finally { |
| 139 | + loading.value = false; |
124 | 140 | } |
125 | | - loading.value = true; |
126 | | - Promise.all(pros) |
127 | | - .then(() => { |
128 | | - MsgSuccess(i18n.global.t('commons.msg.deleteSuccess')); |
129 | | - open.value = false; |
130 | | - em('close'); |
131 | | - }) |
132 | | - .finally(() => { |
133 | | - loading.value = false; |
134 | | - }); |
135 | 141 | }; |
136 | 142 |
|
137 | 143 | const getIconName = (extension: string) => { |
|
0 commit comments