fix(mobile): handle file picker cancellation
This commit is contained in:
@@ -532,6 +532,7 @@ import { createPageRequestScope, currentAccountKey, type RequestScopeTicket } fr
|
||||
import { createRealtimePracticeController, createRealtimeSession, fetchRealtimePersonas, invokeRealtimeTool, type RealtimePersonaOption } from '@/services/realtime-practice';
|
||||
import { stripInternalCodes } from '@/services/text';
|
||||
import { describeMicrophoneError, microphoneDeniedMessage, requestMicrophonePermission } from '@/utils/microphone';
|
||||
import { isFileSelectionCancelled } from '@/utils/file-selection';
|
||||
import { safeTopPadding } from '@/utils/safe-area';
|
||||
|
||||
type PracticeStatus = 'idle' | 'starting' | 'active' | 'submitting' | 'finished';
|
||||
@@ -913,8 +914,10 @@ const composerPickAudio = async () => {
|
||||
await submitTranscribed(text, asr.audioUrl || '', normalizeOssId(asr.ossId));
|
||||
} catch (error) {
|
||||
if (generation !== transcriptionGeneration) return;
|
||||
const text = error instanceof Error ? error.message : '语音转写失败,请改用文字输入';
|
||||
if (text !== '未选择音频') uni.showToast({ title: text, icon: 'none' });
|
||||
if (!isFileSelectionCancelled(error)) {
|
||||
const text = error instanceof Error ? error.message : '语音转写失败,请改用文字输入';
|
||||
uni.showToast({ title: text, icon: 'none' });
|
||||
}
|
||||
} finally {
|
||||
if (generation === transcriptionGeneration) {
|
||||
abortTranscription = null;
|
||||
@@ -1226,6 +1229,10 @@ const transcribeCapture = async (capture: SpeechCapture, assignmentId?: number)
|
||||
}
|
||||
} catch (error) {
|
||||
if (generation !== transcriptionGeneration) return;
|
||||
if (isFileSelectionCancelled(error)) {
|
||||
message.value = '';
|
||||
return;
|
||||
}
|
||||
handleError(error, '语音转写失败');
|
||||
} finally {
|
||||
if (generation === transcriptionGeneration) {
|
||||
|
||||
Reference in New Issue
Block a user