import { nanoid } from "nanoid"; // Speak 类型定义 export type Speak = { id: string; no: number; // 序号, 当天的序号 file?: string; // base64 编码的音频文件 text?: string; // 文字内容,识别的内容 timestamp: number; // 生成时间戳 day: number; // 365天中的第几天 duration: number; // 音频时长,单位秒 url?: string; // 音频文件的 URL 地址 speaker?: string; // 说话人 type?: 'merge' | 'normal'; // 语音类型,默认录制或者合并的 createdAt?: Date; // 创建时间 updatedAt?: Date; // 更新时间 } // 语音类型枚举 export type SpeakType = 'merge' | 'normal'; // 创建 Speak 时的数据类型(排除自动生成的字段) export type CreateSpeakData = Omit; // 更新 Speak 时的数据类型 export type UpdateSpeakData = Partial>; // 获取今天是一年中的第几天 export function getDayOfYear(date: Date = new Date()): number { const start = new Date(date.getFullYear(), 0, 0); const diff = date.getTime() - start.getTime(); const oneDay = 1000 * 60 * 60 * 24; return Math.floor(diff / oneDay); } // 一天是86400秒,获取是当天第几秒 export const getNo = () => { const now = new Date(); const secondsSinceMidnight = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds(); return secondsSinceMidnight; }