|
|
@@ -83,7 +83,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
|
|
|
+import { ref, computed, watch, onMounted, onUnmounted, inject } from 'vue'
|
|
|
import type { DialogueReport, OverallEvaluation, PreviewAIRole, PreviewDialogueState, SessionStartInfo } from '@/types/englishSpeaking'
|
|
|
import { useSpeakingStore } from '@/store/speaking'
|
|
|
import { getSpeakingConfig } from '@/services/speaking'
|
|
|
@@ -108,6 +108,12 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
configId: '',
|
|
|
})
|
|
|
|
|
|
+type SpeakingNotify = (
|
|
|
+ status: 'active' | 'completed',
|
|
|
+ payload: { configId: string; sessionId: string },
|
|
|
+) => void
|
|
|
+const notifySpeakingProgress = inject<SpeakingNotify>('notifySpeakingProgress', () => {})
|
|
|
+
|
|
|
const speakingStore = useSpeakingStore()
|
|
|
|
|
|
// 让组件按 DESIGN_WIDTH 设计宽度等比放大到任意槽位尺寸:
|
|
|
@@ -325,6 +331,10 @@ async function startDialogue() {
|
|
|
currentRound: info.currentRound,
|
|
|
}
|
|
|
dialogueState.value = 'chatting'
|
|
|
+ notifySpeakingProgress('active', {
|
|
|
+ configId: props.configId || '',
|
|
|
+ sessionId: preparedSession.value?.sessionId || '',
|
|
|
+ })
|
|
|
} catch (err: unknown) {
|
|
|
if (err instanceof DialogueApiError) {
|
|
|
sessionError.value = `创建会话失败(${err.status}),请重试`
|
|
|
@@ -414,6 +424,10 @@ async function loadLatestStudentSession(token = nextHistoryLoadToken()) {
|
|
|
}
|
|
|
|
|
|
dialogueState.value = 'chatting'
|
|
|
+ notifySpeakingProgress('active', {
|
|
|
+ configId: props.configId || '',
|
|
|
+ sessionId: preparedSession.value?.sessionId || '',
|
|
|
+ })
|
|
|
} catch (err: unknown) {
|
|
|
if (!isHistoryTokenCurrent(token)) return
|
|
|
console.error('[speaking] load latest session failed:', err)
|
|
|
@@ -435,6 +449,12 @@ function handleDialogueComplete(report: DialogueReport | null) {
|
|
|
else if (report?.status === 'incomplete') reportError.value = '本次练习没有足够的有效回答生成报告。'
|
|
|
else reportError.value = ''
|
|
|
dialogueState.value = 'completed'
|
|
|
+ if (preparedSession.value?.sessionId) {
|
|
|
+ notifySpeakingProgress('completed', {
|
|
|
+ configId: props.configId || '',
|
|
|
+ sessionId: preparedSession.value.sessionId,
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function resetPreview() {
|