|
@@ -12,7 +12,7 @@ import EditClone from './components/EditClone.vue'
|
|
|
|
|
|
|
|
import type { TVoice } from '@/types/voice'
|
|
import type { TVoice } from '@/types/voice'
|
|
|
import { toast } from 'vue-sonner'
|
|
import { toast } from 'vue-sonner'
|
|
|
-import { voiceList, cloneVoice } from '@/api/modules/voice'
|
|
|
|
|
|
|
+import { voiceList, activeVoice } from '@/api/modules/voice'
|
|
|
import { formatDateGeneral } from '@/utils'
|
|
import { formatDateGeneral } from '@/utils'
|
|
|
|
|
|
|
|
const tableRef = ref()
|
|
const tableRef = ref()
|
|
@@ -139,30 +139,6 @@ watch(
|
|
|
{ deep: true }
|
|
{ deep: true }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-const handleUploadSuccess = (res: { code: number, data: { src: string, srcName: string, duration: number } }, file: any) => {
|
|
|
|
|
- console.log(res, file)
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
-
|
|
|
|
|
- currentAudio.value = res.data
|
|
|
|
|
- handleClone(res.data)
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const handleClone = async (res: { src: string, srcName: string, duration: number }) => {
|
|
|
|
|
- cloneLoading.value = true
|
|
|
|
|
- const {code, data} = await cloneVoice({
|
|
|
|
|
- name: res.srcName,
|
|
|
|
|
- audioUrl: res.src,
|
|
|
|
|
- gender: 1
|
|
|
|
|
- })
|
|
|
|
|
- cloneLoading.value = false
|
|
|
|
|
- console.log(code, data)
|
|
|
|
|
- if(code === 0){
|
|
|
|
|
- toast.success('克隆成功')
|
|
|
|
|
- fetchData()
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
const handleEdit = (data: TVoice) => {
|
|
const handleEdit = (data: TVoice) => {
|
|
|
editMode.value = 'edit'
|
|
editMode.value = 'edit'
|
|
@@ -176,6 +152,23 @@ const handleEdit = (data: TVoice) => {
|
|
|
editFormVisible.value = true
|
|
editFormVisible.value = true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const switchLoading = ref(false)
|
|
|
|
|
+const handleActive = async (id: string) => {
|
|
|
|
|
+ switchLoading.value = true
|
|
|
|
|
+ try {
|
|
|
|
|
+ const { code } = await activeVoice({ id })
|
|
|
|
|
+ if(code === 0){
|
|
|
|
|
+ toast.success('激活成功')
|
|
|
|
|
+ fetchData()
|
|
|
|
|
+ }
|
|
|
|
|
+ switchLoading.value = false
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ switchLoading.value = false
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
updateUrlParams(pagination.value.page, pagination.value.size)
|
|
updateUrlParams(pagination.value.page, pagination.value.size)
|
|
|
await fetchData()
|
|
await fetchData()
|
|
@@ -214,6 +207,26 @@ onMounted(async () => {
|
|
|
</ElTableColumn>
|
|
</ElTableColumn>
|
|
|
|
|
|
|
|
<ElTableColumn label="feature" prop="feature" width="280" />
|
|
<ElTableColumn label="feature" prop="feature" width="280" />
|
|
|
|
|
+ <ElTableColumn label="激活状态" prop="status" width="120">
|
|
|
|
|
+ <template #default="{row}">
|
|
|
|
|
+ <ElTag type="success" v-if="row.status === 5">
|
|
|
|
|
+ 已激活
|
|
|
|
|
+ </ElTag>
|
|
|
|
|
+ <ElButton v-else-if="row.status === 3" @click="() => handleActive(row.voiceId)" :disabled="switchLoading">
|
|
|
|
|
+ 激活
|
|
|
|
|
+ </ElButton>
|
|
|
|
|
+ <div v-else>...</div>
|
|
|
|
|
+ <!-- <ElSwitch
|
|
|
|
|
+ v-model="row.status"
|
|
|
|
|
+ :active-value="5"
|
|
|
|
|
+ :inactive-value="3"
|
|
|
|
|
+ :disabled="switchLoading"
|
|
|
|
|
+ @click="() => handleActive(row.voiceId)"
|
|
|
|
|
+ />
|
|
|
|
|
+ 待激活
|
|
|
|
|
+ </div> -->
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ElTableColumn>
|
|
|
<ElTableColumn label="create time" prop="ctime" width="280">
|
|
<ElTableColumn label="create time" prop="ctime" width="280">
|
|
|
<template #default="{row}">
|
|
<template #default="{row}">
|
|
|
{{ formatDateGeneral(row.ctime) }}
|
|
{{ formatDateGeneral(row.ctime) }}
|