mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-28 05:15:04 +08:00
fix: 统一修改删除操作提示
This commit is contained in:
parent
42a9d34e3d
commit
e45f5e3369
@ -7,7 +7,6 @@ import i18n from '@/lang';
|
||||
* @param {Function} api 操作数据接口的api方法(必传)
|
||||
* @param {Object} params 携带的操作数据参数 {id,params}(必传)
|
||||
* @param {String} message 提示信息(必传)
|
||||
* @param {String} loading 页面loading
|
||||
* @param {String} confirmType icon类型(不必传,默认为 warning)
|
||||
* @return Promise
|
||||
*/
|
||||
@ -15,11 +14,9 @@ export const useDeleteData = <P = any, R = any>(
|
||||
api: (params: P) => Promise<R>,
|
||||
params: Parameters<typeof api>[0],
|
||||
message: string,
|
||||
loading: boolean,
|
||||
confirmType: HandleData.MessageType = 'error',
|
||||
) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
loading = true;
|
||||
ElMessageBox.confirm(i18n.global.t(`${message}`) + '?', i18n.global.t('commons.msg.deleteTitle'), {
|
||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||
@ -35,9 +32,6 @@ export const useDeleteData = <P = any, R = any>(
|
||||
});
|
||||
resolve(true);
|
||||
})
|
||||
.finally(() => {
|
||||
loading = false;
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
};
|
||||
|
@ -60,7 +60,7 @@ export default {
|
||||
interval: '耗时',
|
||||
},
|
||||
msg: {
|
||||
delete: '此操作不可回滚,是否继续',
|
||||
delete: '删除 操作不可回滚,是否继续',
|
||||
deleteTitle: '删除',
|
||||
deleteSuccess: '删除成功',
|
||||
loginSuccess: '登录成功',
|
||||
|
@ -167,7 +167,7 @@ const restore = async () => {
|
||||
};
|
||||
|
||||
const deleteBackup = async (ids: number[]) => {
|
||||
await useDeleteData(DelAppBackups, { ids: ids }, 'commons.msg.delete', loading.value);
|
||||
await useDeleteData(DelAppBackups, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -157,7 +157,7 @@ const batchDelete = async (option: string) => {
|
||||
ids.push(item);
|
||||
}
|
||||
}
|
||||
await useDeleteData(imageRemove, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(imageRemove, { ids: ids }, 'commons.msg.delete');
|
||||
deleteVisiable.value = false;
|
||||
search();
|
||||
};
|
||||
|
@ -111,7 +111,7 @@ const batchDelete = async (row: Container.NetworkInfo | null) => {
|
||||
} else {
|
||||
ids.push(row.id);
|
||||
}
|
||||
await useDeleteData(deleteNetwork, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteNetwork, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -87,7 +87,7 @@ const onBatchDelete = async (row: Container.RepoInfo | null) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
}
|
||||
await useDeleteData(deleteImageRepo, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteImageRepo, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -141,7 +141,7 @@ const onBatchDelete = async (row: Container.RepoInfo | null) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
}
|
||||
await useDeleteData(deleteComposeTemplate, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteComposeTemplate, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -103,7 +103,7 @@ const batchDelete = async (row: Container.VolumeInfo | null) => {
|
||||
} else {
|
||||
ids.push(row.name);
|
||||
}
|
||||
await useDeleteData(deleteVolume, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteVolume, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ const onBatchDelete = async (row: Cronjob.CronjobInfo | null) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
}
|
||||
await useDeleteData(deleteCronjob, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteCronjob, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
const beforeChangeStatus = () => {
|
||||
|
@ -123,7 +123,7 @@ const onBatchDelete = async (row: Backup.RecordInfo | null) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
}
|
||||
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -227,7 +227,7 @@ const onBatchDelete = async (row: Database.MysqlDBInfo | null) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
}
|
||||
await useDeleteData(deleteMysqlDB, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteMysqlDB, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
const buttons = [
|
||||
|
@ -173,7 +173,7 @@ const onBatchDelete = async (row: File.File | null) => {
|
||||
files.push(baseDir + item.name);
|
||||
});
|
||||
}
|
||||
await useDeleteData(BatchDeleteFile, { paths: files, isDir: false }, 'commons.msg.delete', true);
|
||||
await useDeleteData(BatchDeleteFile, { paths: files, isDir: false }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -215,7 +215,7 @@ const onBatchDelete = async (row: Database.FileRecord | null) => {
|
||||
files.push(item.fileDir + '/' + item.fileName);
|
||||
});
|
||||
}
|
||||
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete', true);
|
||||
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete');
|
||||
loadBackupRecords();
|
||||
};
|
||||
const buttons = [
|
||||
|
@ -341,7 +341,7 @@ const handleCreate = (commnad: string) => {
|
||||
};
|
||||
|
||||
const delFile = async (row: File.File | null) => {
|
||||
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete', loading.value);
|
||||
await useDeleteData(DeleteFile, row as File.FileDelete, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -115,7 +115,7 @@ const batchDelete = async (row: Command.CommandInfo | null) => {
|
||||
} else {
|
||||
ids.push(row.id);
|
||||
}
|
||||
await useDeleteData(deleteCommand, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteCommand, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -279,10 +279,10 @@ const onDelete = async (node: Node, data: Tree) => {
|
||||
return;
|
||||
}
|
||||
if (node.level === 1) {
|
||||
await useDeleteData(deleteGroup, data.id - 10000, i18n.global.t('terminal.groupDeleteHelper'), true);
|
||||
await useDeleteData(deleteGroup, data.id - 10000, i18n.global.t('terminal.groupDeleteHelper'));
|
||||
loadGroups();
|
||||
} else {
|
||||
await useDeleteData(deleteHost, data.id, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteHost, data.id, 'commons.msg.delete');
|
||||
}
|
||||
loadHostTree();
|
||||
loadGroups();
|
||||
|
@ -224,7 +224,7 @@ const onBatchDelete = async (row: Backup.BackupInfo | null) => {
|
||||
} else {
|
||||
ids.push(row.id);
|
||||
}
|
||||
await useDeleteData(deleteBackup, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteBackup, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
restForm();
|
||||
};
|
||||
|
@ -72,6 +72,6 @@ function onSave(formEl: FormInstance | undefined, key: string, val: any) {
|
||||
}
|
||||
|
||||
const onClean = async () => {
|
||||
await useDeleteData(cleanMonitors, {}, 'commons.msg.delete', true);
|
||||
await useDeleteData(cleanMonitors, {}, 'commons.msg.delete');
|
||||
};
|
||||
</script>
|
||||
|
@ -71,7 +71,7 @@ const openCreate = () => {
|
||||
};
|
||||
|
||||
const deleteAccount = async (id: number) => {
|
||||
await useDeleteData(DeleteAcmeAccount, id, 'commons.msg.delete', loading.value);
|
||||
await useDeleteData(DeleteAcmeAccount, id, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -87,7 +87,7 @@ const openEdit = (form: WebSite.DnsAccount) => {
|
||||
|
||||
const deleteAccount = async (id: number) => {
|
||||
loading.value = true;
|
||||
await useDeleteData(DeleteDnsAccount, id, 'commons.msg.delete', false);
|
||||
await useDeleteData(DeleteDnsAccount, id, 'commons.msg.delete');
|
||||
loading.value = false;
|
||||
search();
|
||||
};
|
||||
|
@ -124,7 +124,7 @@ const openRenewSSL = (id: number) => {
|
||||
|
||||
const deleteSSL = async (id: number) => {
|
||||
loading.value = true;
|
||||
await useDeleteData(DeleteSSL, id, 'commons.msg.delete', false);
|
||||
await useDeleteData(DeleteSSL, id, 'commons.msg.delete');
|
||||
loading.value = false;
|
||||
search();
|
||||
};
|
||||
|
@ -144,7 +144,7 @@ const onBatchDelete = async (row: Backup.RecordInfo | null) => {
|
||||
ids.push(item.id);
|
||||
});
|
||||
}
|
||||
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete', true);
|
||||
await useDeleteData(deleteBackupRecord, { ids: ids }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
@ -49,7 +49,7 @@ const openCreate = () => {
|
||||
};
|
||||
|
||||
const deleteDoamin = async (domainId: number) => {
|
||||
await useDeleteData(DeleteDomain, domainId, 'commons.msg.delete', loading.value);
|
||||
await useDeleteData(DeleteDomain, domainId, 'commons.msg.delete');
|
||||
search(id.value);
|
||||
};
|
||||
|
||||
|
@ -183,7 +183,7 @@ const onBatchDelete = async (row: File.File | null) => {
|
||||
files.push(baseDir.value + '/' + item.name);
|
||||
});
|
||||
}
|
||||
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete', true);
|
||||
await useDeleteData(BatchDeleteFile, { isDir: false, paths: files }, 'commons.msg.delete');
|
||||
search();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user