|
@@ -1,6 +1,6 @@
|
|
|
import { create } from "zustand";
|
|
|
|
|
|
-import { TGetMyVoicesParams, TVoiceItem, TPageination } from '@/types/storage'
|
|
|
+import { TGetMyVoicesParams, TVoiceItem, TPageination, TGender } from '@/types/voice'
|
|
|
|
|
|
import {
|
|
|
getVoices as _getVoices,
|
|
@@ -14,10 +14,18 @@ export interface StorageStoreState {
|
|
|
// 初始状态
|
|
|
voices: TVoiceItem[];
|
|
|
myVoices: TVoiceItem[];
|
|
|
- pagination: TPageination
|
|
|
+ maleVoices: TVoiceItem[];
|
|
|
+ femaleVoices: TVoiceItem[];
|
|
|
+ pagination: TPageination;
|
|
|
+ malePagination: TPageination;
|
|
|
+ femalePagination: TPageination;
|
|
|
isLoading: boolean,
|
|
|
getVoices: (params?: TGetMyVoicesParams) => Promise<boolean>;
|
|
|
+ getMaleVoices: (params?: TGetMyVoicesParams) => Promise<boolean>;
|
|
|
+ getFemaleVoices: (params?: TGetMyVoicesParams) => Promise<boolean>;
|
|
|
setPagination: (params:any) => Promise<void>;
|
|
|
+ setMalePagination: (params:any) => Promise<void>;
|
|
|
+ setFemalePagination: (params:any) => Promise<void>;
|
|
|
cloneVoice: (params: {
|
|
|
sourceUrl: string // 源语音地址 ,
|
|
|
voiceText?: string // 录音文案
|
|
@@ -27,6 +35,8 @@ export interface StorageStoreState {
|
|
|
export const useVoiceStore = create<StorageStoreState>((set, get) => ({
|
|
|
voices: [],
|
|
|
myVoices: [],
|
|
|
+ maleVoices: [],
|
|
|
+ femaleVoices: [],
|
|
|
pagination: {
|
|
|
pageIndex: 1,
|
|
|
pageSize: 10,
|
|
@@ -34,7 +44,20 @@ export const useVoiceStore = create<StorageStoreState>((set, get) => ({
|
|
|
searchKey: '',
|
|
|
extData: null,
|
|
|
},
|
|
|
-
|
|
|
+ malePagination: {
|
|
|
+ pageIndex: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ totalCount: 0,
|
|
|
+ searchKey: '',
|
|
|
+ extData: null,
|
|
|
+ },
|
|
|
+ femalePagination: {
|
|
|
+ pageIndex: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ totalCount: 0,
|
|
|
+ searchKey: '',
|
|
|
+ extData: null,
|
|
|
+ },
|
|
|
isLoading: false,
|
|
|
getVoices: async (params = {}) => {
|
|
|
set({ isLoading: true });
|
|
@@ -56,6 +79,40 @@ export const useVoiceStore = create<StorageStoreState>((set, get) => ({
|
|
|
});
|
|
|
return isSuccess(response.status)
|
|
|
},
|
|
|
+ getMaleVoices: async (params = {}) => {
|
|
|
+ set({ isLoading: true });
|
|
|
+ const currentPagination = get().malePagination;
|
|
|
+ const requestParams = { ...currentPagination, ...params, gender: 'male' as TGender };
|
|
|
+
|
|
|
+ const response = await _getVoices(requestParams)
|
|
|
+
|
|
|
+ set({
|
|
|
+ maleVoices: response.data.data,
|
|
|
+ malePagination: {
|
|
|
+ ...requestParams,
|
|
|
+ totalCount: response.data.totalCount,
|
|
|
+ },
|
|
|
+ isLoading: false
|
|
|
+ });
|
|
|
+ return isSuccess(response.status)
|
|
|
+ },
|
|
|
+ getFemaleVoices: async (params = {}) => {
|
|
|
+ set({ isLoading: true });
|
|
|
+ const currentPagination = get().femalePagination;
|
|
|
+ const requestParams = { ...currentPagination, ...params, gender: 'female' as TGender };
|
|
|
+
|
|
|
+ const response = await _getVoices(requestParams)
|
|
|
+
|
|
|
+ set({
|
|
|
+ femaleVoices: response.data.data,
|
|
|
+ femalePagination: {
|
|
|
+ ...requestParams,
|
|
|
+ totalCount: response.data.totalCount,
|
|
|
+ },
|
|
|
+ isLoading: false
|
|
|
+ });
|
|
|
+ return isSuccess(response.status)
|
|
|
+ },
|
|
|
// 更新分页参数
|
|
|
setPagination: async (params:any) => {
|
|
|
set((state) => ({
|
|
@@ -64,6 +121,18 @@ export const useVoiceStore = create<StorageStoreState>((set, get) => ({
|
|
|
// 可选:自动触发请求
|
|
|
get().getVoices();
|
|
|
},
|
|
|
+ setMalePagination: async (params:any) => {
|
|
|
+ set((state) => ({
|
|
|
+ malePagination: { ...state.malePagination, ...params },
|
|
|
+ }));
|
|
|
+ get().getMaleVoices();
|
|
|
+ },
|
|
|
+ setFemalePagination: async (params:any) => {
|
|
|
+ set((state) => ({
|
|
|
+ femalePagination: { ...state.femalePagination, ...params },
|
|
|
+ }));
|
|
|
+ get().getFemaleVoices();
|
|
|
+ },
|
|
|
cloneVoice: async (params) => {
|
|
|
const response = await _cloneVoice(params)
|
|
|
console.log(response,444444)
|