增加克隆次数显示 弹框
parent
684e71358c
commit
44f9b6f8ff
|
@ -3,6 +3,12 @@
|
|||
<template #header>
|
||||
<div class="flex justify-between items-center w-full">
|
||||
<span>克隆角色音频</span>
|
||||
<div class="text-sm text-gray-500">
|
||||
剩余克隆次数:
|
||||
<span :class="{ 'text-red-500': character?.remainingCloneCount === 0, 'text-green-500': character?.remainingCloneCount > 0 }">
|
||||
{{ character?.remainingCloneCount || 0 }}
|
||||
</span>
|
||||
</div>
|
||||
<el-button type="primary" link @click="showHistory">
|
||||
<el-icon class="mr-1"><List /></el-icon>
|
||||
克隆历史
|
||||
|
@ -73,7 +79,11 @@ import CloneHistory from "./CloneHistory.vue";
|
|||
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
character: any;
|
||||
character: {
|
||||
id: string;
|
||||
roleName: string;
|
||||
remainingCloneCount?: number;
|
||||
};
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
|
|
@ -50,10 +50,8 @@
|
|||
</div>
|
||||
<div class="flex justify-end">
|
||||
<ElButton @click="handleEdit(item)" type="warning" size="small">编辑</ElButton>
|
||||
<template v-if="!item.activate">
|
||||
<ElButton @click="handleClone(item)" type="primary" size="small" class="ml-2" :disabled="item.remainingCloneCount === 0"> 克隆音频 </ElButton>
|
||||
<ElButton v-if="item.originAudioUrl" @click="handleActivate(item)" type="success" size="small" class="ml-2"> 激活声音 </ElButton>
|
||||
</template>
|
||||
<ElButton @click="handleClone(item)" type="primary" size="small" class="ml-2"> 克隆音频 </ElButton>
|
||||
<ElButton v-if="item.originAudioUrl && !item.activate" @click="handleActivate(item)" type="success" size="small" class="ml-2"> 激活声音 </ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
@ -150,7 +148,7 @@
|
|||
<el-icon><Document /></el-icon>
|
||||
<span>快速导入</span>
|
||||
</div>
|
||||
<el-input v-model="formatJson" type="textarea" :rows="13" placeholder="粘贴格式化的JSON数据" class="format-input" />
|
||||
<el-input v-model="formatJson" type="textarea" :rows="13" placeholder="贴格式化的JSON数据" class="format-input" />
|
||||
<el-button type="primary" class="w-full mt-4" @click="handleAutoFormat">
|
||||
<el-icon><Check /></el-icon>自动填充
|
||||
</el-button>
|
||||
|
@ -394,37 +392,53 @@ const handleRemoveImage = () => {
|
|||
};
|
||||
|
||||
// 修改克隆方法
|
||||
const handleClone = (item: any) => {
|
||||
currentCharacter.value = item;
|
||||
cloneDialogVisible.value = true;
|
||||
const handleClone = async (item: any) => {
|
||||
try {
|
||||
// 先获取最新的角色信息
|
||||
const detail = await getSystemCharterDetailAPI(item.id);
|
||||
currentCharacter.value = {
|
||||
...item,
|
||||
...detail.data,
|
||||
};
|
||||
cloneDialogVisible.value = true;
|
||||
} catch (error) {
|
||||
ElMessage.error("获取角色信息失败");
|
||||
}
|
||||
};
|
||||
|
||||
const showTaskList = () => {
|
||||
taskListVisible.value = true;
|
||||
};
|
||||
|
||||
// 添加激活处理方法
|
||||
// 修改激活处理方法
|
||||
const handleActivate = async (item: any) => {
|
||||
try {
|
||||
await ElMessageBox.confirm("激活后将不能继续克隆,是否确认激活?", "激活确认", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
});
|
||||
// 先获取最新的角色信息
|
||||
const detail = await getSystemCharterDetailAPI(item.id);
|
||||
const character = {
|
||||
...item,
|
||||
...detail.data,
|
||||
};
|
||||
|
||||
const loading = ElLoading.service();
|
||||
try {
|
||||
await activateVoiceAPI(item.id);
|
||||
ElMessage.success("激活成功");
|
||||
// 刷新列表
|
||||
initSystemCharterDataSource();
|
||||
} finally {
|
||||
loading.close();
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== "cancel") {
|
||||
ElMessage.error("激活失败");
|
||||
}
|
||||
// 如果没有源声音,不能激活
|
||||
if (!character.originAudioUrl) {
|
||||
ElMessage.warning("该角色还未克隆声音,无法激活");
|
||||
return;
|
||||
}
|
||||
|
||||
await ElMessageBox.confirm("激活后将不能继续克隆,是否确认激活?", "激活确认", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
});
|
||||
|
||||
const loading = ElLoading.service();
|
||||
try {
|
||||
await activateVoiceAPI(character.id);
|
||||
ElMessage.success("激活成功");
|
||||
// 刷新列表
|
||||
initSystemCharterDataSource();
|
||||
} finally {
|
||||
loading.close();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue