diff --git a/main/manager-web/src/apis/module/admin.js b/main/manager-web/src/apis/module/admin.js
index 1f9ad5d4..fecc5877 100644
--- a/main/manager-web/src/apis/module/admin.js
+++ b/main/manager-web/src/apis/module/admin.js
@@ -115,7 +115,6 @@ export default {
},
// 删除
deleteParam(ids, callback) {
- console.log(4444,ids )
RequestService.sendRequest()
.url(`${getServiceUrl()}/admin/params/delete`)
.method('POST')
diff --git a/main/manager-web/src/apis/module/timbre.js b/main/manager-web/src/apis/module/timbre.js
index 9b48e5c3..91920522 100644
--- a/main/manager-web/src/apis/module/timbre.js
+++ b/main/manager-web/src/apis/module/timbre.js
@@ -1,11 +1,8 @@
-// timbre.js
import {getServiceUrl} from '../api';
import RequestService from '../httpRequest';
export default {
- /**
- * 获取音色数据
- */
+ // 获取音色
getVoiceList(params, callback) {
const queryParams = new URLSearchParams({
ttsModelId: params.ttsModelId,
@@ -28,9 +25,7 @@ export default {
});
}).send();
},
- /**
- * 音色保存
- */
+ // 音色保存
saveVoice(params, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/ttsVoice`)
@@ -54,15 +49,12 @@ export default {
});
}).send();
},
- /**
- * 音色删除
- */
- deleteVoice(id, callback) {
- console.log('尝试删除音色,ID:', id);
+ // 音色删除
+ deleteVoice(ids, callback) {
RequestService.sendRequest()
- .url(`${getServiceUrl()}/ttsVoice`)
- .method('DELETE')
- .data({ ids: [id] })
+ .url(`${getServiceUrl()}/ttsVoice/delete`)
+ .method('POST')
+ .data(ids)
.success((res) => {
RequestService.clearRequestTime()
callback(res);
@@ -70,13 +62,11 @@ export default {
.fail((err) => {
console.error('删除音色失败:', err);
RequestService.reAjaxFun(() => {
- this.deleteVoice(id, callback);
+ this.deleteVoice(ids, callback);
});
}).send();
},
- /**
- * 音色修改
- */
+ // 音色修改
updateVoice(params, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/ttsVoice/${params.id}`)
diff --git a/main/manager-web/src/components/TtsModel.vue b/main/manager-web/src/components/TtsModel.vue
index e60bfbb0..6197b1a8 100644
--- a/main/manager-web/src/components/TtsModel.vue
+++ b/main/manager-web/src/components/TtsModel.vue
@@ -108,7 +108,11 @@
新增
- 删除
+ row.selected))"
+ style="background: red;border:None">删除
+
@@ -419,105 +423,57 @@ export default {
},
deleteRow(row) {
- this.$confirm("确定要删除该音色吗?", "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- Api.timbre.deleteVoice(row.id, (response) => {
- if (response.code === 0) {
- this.$message.success({
- message: "删除成功",
- showClose: true
- });
- this.loadData(); // 刷新数据
- } else {
- this.$message.error({
- message: response.msg || "删除失败",
- showClose: true
- });
+ // 处理单个音色或音色数组
+ const voices = Array.isArray(row) ? row : [row];
+
+ if (Array.isArray(row) && row.length === 0) {
+ this.$message.warning("请先选择需要删除的音色");
+ return;
+ }
+
+
+ const voiceCount = voices.length;
+ this.$confirm(`确定要删除选中的${voiceCount}个音色吗?`, "警告", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ distinguishCancelAndClose: true
+ }).then(() => {
+ const ids = voices.map(voice => voice.id);
+ if (ids.some(id => !id)) {
+ this.$message.error("存在无效的音色ID");
+ return;
}
- });
- })
- .catch(() => {
- this.$message.info("已取消删除");
- });
- },
- batchDelete() {
- const selectedRows = this.filteredTtsModels.filter(row => row.selected);
- if (selectedRows.length === 0) {
- this.$message.warning("请先选择需要删除的音色");
- return;
- }
-
- this.$confirm(`确定要删除选中的${selectedRows.length}个音色吗?`, "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(async () => {
- const loading = this.$loading({
- lock: true,
- text: "正在删除中...",
- spinner: "el-icon-loading",
- background: "rgba(0, 0, 0, 0.7)",
- });
-
- try {
- const results = await Promise.all(
- selectedRows.map((row) => {
- return new Promise((resolve) => {
- Api.timbre.deleteVoice(row.id, (response) => {
- if (response.code === 0) {
- resolve({ success: true, id: row.id });
- } else {
- resolve({
- success: false,
- id: row.id,
- msg: response.msg || '删除失败'
- });
- }
- });
+ Api.timbre.deleteVoice(ids, ({data}) => {
+ if (data.code === 0) {
+ this.$message.success({
+ message: `成功删除${voiceCount}个参数`,
+ showClose: true
});
- })
- );
-
- const successCount = results.filter(r => r.success).length;
- const failCount = results.length - successCount;
-
- if (failCount === 0) {
- this.$message.success({
- message: `成功删除${successCount}个音色`,
- showClose: true
- });
- } else if (successCount === 0) {
- this.$message.error({
- message: '删除失败,请重试',
- showClose: true
- });
+ this.loadData(); // 刷新参数列表
} else {
- this.$message.warning({
- message: `成功删除${successCount}个音色,${failCount}个删除失败`,
- showClose: true
- });
+ this.$message.error({
+ message: data.msg || '删除失败,请重试',
+ showClose: true
+ });
}
-
- this.loadData(); // 刷新数据
- } catch (error) {
- console.error('批量删除出错:', error);
- this.$message.error({
- message: '删除过程中发生错误',
- showClose: true
- });
- } finally {
- loading.close();
- }
- })
- .catch(() => {
- this.$message.info("已取消删除");
});
+ }).catch(action => {
+ if (action === 'cancel') {
+ this.$message({
+ type: 'info',
+ message: '已取消删除操作',
+ duration: 1000
+ });
+ } else {
+ this.$message({
+ type: 'info',
+ message: '操作已关闭',
+ duration: 1000
+ });
+ }
+ });
},
isValidAudioUrl(url) {