refactor: remove unused base64 conversion function and update voice number generation
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
import { Speak, getDayOfYear } from '../modules/speak-db/speak';
|
||||
import { getText } from '../modules/text';
|
||||
import { Speak, getDayOfYear, getNo } from '../modules/speak-db/speak';
|
||||
import { useSettingStore } from './settingStore';
|
||||
import { queryResources, useResourceStore } from './resourceStore';
|
||||
import { queryApi as flowmeApi } from '@/modules/flowme-api';
|
||||
@@ -65,29 +64,6 @@ const blobToBase64 = (blob: Blob): Promise<string> => {
|
||||
});
|
||||
};
|
||||
|
||||
// 辅助函数:将 base64 字符串转换为 Blob URL
|
||||
const base64ToUrl = (base64: string, mimeType: string = 'audio/wav'): string => {
|
||||
try {
|
||||
// 如果已经是 blob URL,直接返回
|
||||
if (base64.startsWith('blob:')) {
|
||||
return base64;
|
||||
}
|
||||
|
||||
// 将 base64 转换为 ArrayBuffer
|
||||
const binaryString = window.atob(base64);
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
|
||||
// 创建 Blob 和 URL
|
||||
const blob = new Blob([bytes], { type: mimeType });
|
||||
return URL.createObjectURL(blob);
|
||||
} catch (error) {
|
||||
console.error('转换 base64 到 URL 失败:', error);
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
export const useVoiceStore = create<VoiceState>()(
|
||||
devtools(
|
||||
@@ -150,7 +126,7 @@ export const useVoiceStore = create<VoiceState>()(
|
||||
const speakData = {
|
||||
duration: Math.ceil(duration),
|
||||
day: getDayOfYear(),
|
||||
no: 0, // 将由 service 自动生成
|
||||
no: getNo(), // 将由 service 自动生成
|
||||
timestamp: Date.now(),
|
||||
type: 'normal' as const,
|
||||
text: '', // 初始为空
|
||||
|
||||
Reference in New Issue
Block a user