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