style: 强类型大法

This commit is contained in:
手瓜一十雪 committed 2025-02-02 23:22:21 +08:00
1 parent ac193cc94a
commit 15854c605b
191 files changed
+923 -806

No files matched your search

+5 -5
View File
@@ -4,16 +4,16 @@ import { promises as fs } from 'fs';
import { decode } from 'silk-wasm';
import { FFmpegService } from '@/common/ffmpeg';
const out_format = ['mp3' , 'amr' , 'wma' , 'm4a' , 'spx' , 'ogg' , 'wav' , 'flac'];
const out_format = ['mp3', 'amr', 'wma', 'm4a', 'spx', 'ogg', 'wav', 'flac'];
type Payload = {
out_format : string
out_format: string
} & GetFilePayload
export default class GetRecord extends GetFileBase {
actionName = ActionName.GetRecord;
override actionName = ActionName.GetRecord;
async _handle(payload: Payload): Promise<GetFileResponse> {
override async _handle(payload: Payload): Promise<GetFileResponse> {
const res = await super._handle(payload);
if (payload.out_format && typeof payload.out_format === 'string') {
const inputFile = res.file;
@@ -27,7 +27,7 @@ export default class GetRecord extends GetFileBase {
await fs.access(inputFile);
try {
await fs.access(outputFile);
} catch (error) {
} catch {
await this.decodeFile(inputFile, pcmFile);
await FFmpegService.convertFile(pcmFile, outputFile, payload.out_format);
}