fix: 修复前端没有input_field_list报错
This commit is contained in:
parent
746f587698
commit
24291493d6
@ -119,12 +119,10 @@
|
|||||||
@click="startChat(item)"
|
@click="startChat(item)"
|
||||||
link
|
link
|
||||||
>继续
|
>继续
|
||||||
</el-button
|
</el-button>
|
||||||
>
|
|
||||||
<el-button type="primary" v-else-if="!item.write_ed" @click="stopChat(item)" link
|
<el-button type="primary" v-else-if="!item.write_ed" @click="stopChat(item)" link
|
||||||
>停止回答
|
>停止回答
|
||||||
</el-button
|
</el-button>
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.write_ed && props.appId && 500 != item.status" class="flex-between">
|
<div v-if="item.write_ed && props.appId && 500 != item.status" class="flex-between">
|
||||||
@ -137,7 +135,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 语音播放 -->
|
<!-- 语音播放 -->
|
||||||
<div style="float: right;" v-if="props.data.tts_model_enable">
|
<div style="float: right" v-if="props.data.tts_model_enable">
|
||||||
<el-button :disabled="!item.write_ed" @click="playAnswerText(item.answer_text)">
|
<el-button :disabled="!item.write_ed" @click="playAnswerText(item.answer_text)">
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<VideoPlay />
|
<VideoPlay />
|
||||||
@ -162,18 +160,12 @@
|
|||||||
@keydown.enter="sendChatHandle($event)"
|
@keydown.enter="sendChatHandle($event)"
|
||||||
/>
|
/>
|
||||||
<div class="operate" v-if="props.data.stt_model_enable">
|
<div class="operate" v-if="props.data.stt_model_enable">
|
||||||
<el-button
|
<el-button v-if="mediaRecorderStatus" @click="startRecording">
|
||||||
v-if="mediaRecorderStatus"
|
|
||||||
@click="startRecording"
|
|
||||||
>
|
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<Microphone />
|
<Microphone />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button v-else @click="stopRecording">
|
||||||
v-else
|
|
||||||
@click="stopRecording"
|
|
||||||
>
|
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<VideoPause />
|
<VideoPause />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@ -231,8 +223,7 @@ const {
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
appId: String, // 仅分享链接有
|
appId: String, // 仅分享链接有
|
||||||
log: Boolean,
|
log: Boolean,
|
||||||
@ -328,12 +319,19 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
function handleInputFieldList() {
|
function handleInputFieldList() {
|
||||||
props.data.work_flow?.nodes?.filter((v: any) => v.id === 'base-node')
|
props.data.work_flow?.nodes
|
||||||
|
?.filter((v: any) => v.id === 'base-node')
|
||||||
.map((v: any) => {
|
.map((v: any) => {
|
||||||
inputFieldList.value = v.properties.input_field_list.map((v: any) => {
|
inputFieldList.value = v.properties.input_field_list
|
||||||
|
? v.properties.input_field_list.map((v: any) => {
|
||||||
switch (v.type) {
|
switch (v.type) {
|
||||||
case 'input':
|
case 'input':
|
||||||
return { field: v.variable, input_type: 'TextInput', label: v.name, required: v.is_required }
|
return {
|
||||||
|
field: v.variable,
|
||||||
|
input_type: 'TextInput',
|
||||||
|
label: v.name,
|
||||||
|
required: v.is_required
|
||||||
|
}
|
||||||
case 'select':
|
case 'select':
|
||||||
return {
|
return {
|
||||||
field: v.variable,
|
field: v.variable,
|
||||||
@ -351,15 +349,16 @@ function handleInputFieldList() {
|
|||||||
label: v.name,
|
label: v.name,
|
||||||
required: v.is_required,
|
required: v.is_required,
|
||||||
attrs: {
|
attrs: {
|
||||||
'format': 'YYYY-MM-DD HH:mm:ss',
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
'value-format': 'YYYY-MM-DD HH:mm:ss',
|
'value-format': 'YYYY-MM-DD HH:mm:ss',
|
||||||
'type': 'datetime'
|
type: 'datetime'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
: []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +711,6 @@ const mediaRecorder = ref<any>(null)
|
|||||||
const audioPlayer = ref<HTMLAudioElement | null>(null)
|
const audioPlayer = ref<HTMLAudioElement | null>(null)
|
||||||
const mediaRecorderStatus = ref(true)
|
const mediaRecorderStatus = ref(true)
|
||||||
|
|
||||||
|
|
||||||
// 开始录音
|
// 开始录音
|
||||||
const startRecording = async () => {
|
const startRecording = async () => {
|
||||||
try {
|
try {
|
||||||
@ -723,11 +721,14 @@ const startRecording = async () => {
|
|||||||
sampleRate: 44100
|
sampleRate: 44100
|
||||||
})
|
})
|
||||||
|
|
||||||
mediaRecorder.value.open(() => {
|
mediaRecorder.value.open(
|
||||||
|
() => {
|
||||||
mediaRecorder.value.start()
|
mediaRecorder.value.start()
|
||||||
}, (err: any) => {
|
},
|
||||||
|
(err: any) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
}
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('无法获取音频权限:', error)
|
console.error('无法获取音频权限:', error)
|
||||||
}
|
}
|
||||||
@ -737,7 +738,8 @@ const startRecording = async () => {
|
|||||||
const stopRecording = () => {
|
const stopRecording = () => {
|
||||||
if (mediaRecorder.value) {
|
if (mediaRecorder.value) {
|
||||||
mediaRecorderStatus.value = true
|
mediaRecorderStatus.value = true
|
||||||
mediaRecorder.value.stop((blob: Blob, duration: number) => {
|
mediaRecorder.value.stop(
|
||||||
|
(blob: Blob, duration: number) => {
|
||||||
// 测试blob是否能正常播放
|
// 测试blob是否能正常播放
|
||||||
// const link = document.createElement('a')
|
// const link = document.createElement('a')
|
||||||
// link.href = window.URL.createObjectURL(blob)
|
// link.href = window.URL.createObjectURL(blob)
|
||||||
@ -745,9 +747,11 @@ const stopRecording = () => {
|
|||||||
// link.click()
|
// link.click()
|
||||||
|
|
||||||
uploadRecording(blob) // 上传录音文件
|
uploadRecording(blob) // 上传录音文件
|
||||||
}, (err: any) => {
|
},
|
||||||
|
(err: any) => {
|
||||||
console.error('录音失败:', err)
|
console.error('录音失败:', err)
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,30 +760,32 @@ const uploadRecording = async (audioBlob: Blob) => {
|
|||||||
try {
|
try {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', audioBlob, 'recording.mp3')
|
formData.append('file', audioBlob, 'recording.mp3')
|
||||||
applicationApi.postSpeechToText(props.data.id as string, formData, loading)
|
applicationApi.postSpeechToText(props.data.id as string, formData, loading).then((response) => {
|
||||||
.then((response) => {
|
|
||||||
console.log('上传成功:', response.data)
|
console.log('上传成功:', response.data)
|
||||||
inputValue.value = response.data
|
inputValue.value = response.data
|
||||||
// chatMessage(null, res.data)
|
// chatMessage(null, res.data)
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('上传失败:', error)
|
console.error('上传失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const playAnswerText = (text: string) => {
|
const playAnswerText = (text: string) => {
|
||||||
if (props.ttsModelOptions?.model_local_provider?.filter((v: any) => v.id === props.data.tts_model_id).length > 0) {
|
if (
|
||||||
|
props.ttsModelOptions?.model_local_provider?.filter(
|
||||||
|
(v: any) => v.id === props.data.tts_model_id
|
||||||
|
).length > 0
|
||||||
|
) {
|
||||||
// 创建一个新的 SpeechSynthesisUtterance 实例
|
// 创建一个新的 SpeechSynthesisUtterance 实例
|
||||||
const utterance = new SpeechSynthesisUtterance(text);
|
const utterance = new SpeechSynthesisUtterance(text)
|
||||||
// 调用浏览器的朗读功能
|
// 调用浏览器的朗读功能
|
||||||
window.speechSynthesis.speak(utterance);
|
window.speechSynthesis.speak(utterance)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationApi.postTextToSpeech(props.data.id as string, { 'text': text }, loading)
|
applicationApi
|
||||||
|
.postTextToSpeech(props.data.id as string, { text: text }, loading)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
|
|
||||||
// 假设我们有一个 MP3 文件的字节数组
|
// 假设我们有一个 MP3 文件的字节数组
|
||||||
// 创建 Blob 对象
|
// 创建 Blob 对象
|
||||||
const blob = new Blob([res], { type: 'audio/mp3' })
|
const blob = new Blob([res], { type: 'audio/mp3' })
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user