Просмотр исходного кода

fix: voice list active voice use id

王晓东 1 месяц назад
Родитель
Сommit
2b7ac2857f

+ 2 - 0
src/constants/voiceTypes.ts

@@ -4,6 +4,7 @@
  * 1、系统音色;2、管理员克隆;3、用户克隆
  */
 export enum EVoiceType {
+  ALL = 0,
   SYSTEM = 1,
   ADMIN_CLONE = 2,
   USER_CLONE = 3
@@ -16,6 +17,7 @@ export type TVoiceTypeValue = `${EVoiceType}`; // 字符串数字类型 "1" | "2
 // 中文映射(用于前端展示)
 // 优化:用 as const 确保 key 是枚举字面量,无需 Record 显式声明,类型更严格
 export const VOICE_TYPE_LABELS = Object.freeze({
+  [EVoiceType.ALL]: '全部',
   [EVoiceType.SYSTEM]: '系统音色',
   [EVoiceType.ADMIN_CLONE]: '管理员克隆',
   [EVoiceType.USER_CLONE]: '用户克隆',

+ 1 - 1
src/views/voice-management/components/SearchForm.vue

@@ -7,7 +7,7 @@ import { VOICE_TYPE_OPTIONS } from '@/constants/voiceTypes'
 
 export type TSearchParams = {
   name: string,
-  type: number
+  type?: number
   gender: number|null
 }
 interface Props {

+ 9 - 4
src/views/voice-management/index.vue

@@ -19,7 +19,7 @@ import { usePagination } from 'vue-request'
 // 搜索参数
 const searchParams = ref<TSearchParams>({
   name: '',
-  type: 1,
+  type: 0,
   gender: null
 })
 const editFormVisible = ref(false)
@@ -40,10 +40,11 @@ const { data, run, loading, current, total, pageSize, changePageSize } = usePagi
 
 async function fetchData(page?: number) {
   const gender = searchParams.value.gender === -1 ? null : searchParams.value.gender
+  const type = searchParams.value.type
   run({
     gender,
     name: searchParams.value.name,
-    type: searchParams.value.type,
+    type: type === 0 ? undefined : type,
     page: page ?? current.value,
     size: pageSize.value,
   })
@@ -130,13 +131,17 @@ onMounted(() => {
           </template>
         </ElTableColumn>
 
-        <ElTableColumn label="feature" prop="feature" width="280" />
+        <ElTableColumn label="feature" prop="feature" width="280">
+          <template #default="{row}">
+              {{ row.feature }}
+          </template>
+        </ElTableColumn>
         <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 v-else-if="row.status === 3"  @click="() => handleActive(row.id)" :disabled="switchLoading">
               激活
             </ElButton>
             <div v-else>...</div>