This commit is contained in:
yanghang
2025-07-09 19:30:54 +08:00
parent d48ae174a7
commit 1ae450bb82
4 changed files with 64 additions and 36 deletions
+4 -2
View File
@@ -23,8 +23,8 @@ function streamRequest(options) {
onError
} = options
headers['Accept'] = 'text/event-stream'
headers['Content-Type'] = 'application/json;charset=UTF-8'
// headers['Accept'] = 'text/event-stream'
headers['Content-Type'] = 'text/event-stream'
headers['summary'] = token
// 创建请求任务
@@ -33,8 +33,10 @@ function streamRequest(options) {
method,
data,
header: headers,
responseType: 'arraybuffer',
...baseConfig,
success: (res) => {
console.log(res.data)
onComplete?.(res)
},
fail: (err) => {
+22 -9
View File
@@ -1,4 +1,4 @@
<!-- type: 0纯文本信息不翻译 1语音回答 2 文本回答 3, 段落信息 4 问题信息 5 统计信息 6: 发送loading状态 -->
<!-- type: 0纯文本信息不翻译 1语音回答 2 文本回答 3, 段落信息 4 问题信息 5 统计信息 6: 发送loading状态 7: 教师反馈文本不翻译 -->
<template>
<view class="ai-answer" v-if="[3,4,5].indexOf(type) >= 0">
<view class="user-info">
@@ -79,6 +79,24 @@
</view>
</view>
</view>
<view class="ai-answer" v-if="[7].indexOf(type) >= 0">
<view class="user-info">
<view class="avatar-box">
<ImagePreview class="img-box" :imgId="dataInfo?.userInfo?.imgAddr"></ImagePreview>
</view>
<view class="ai-name">
{{ dataInfo?.userInfo?.teacherName }}
<view class="ai-name-desc">{{dataInfo?.userInfo?.teacherDesc}}</view>
</view>
</view>
<view :class="['talking-info', [4,7].indexOf(type) >= 0 ? 'talking-info-less':''] ">
<view class="talking-cont">
<view class="talking-text">
{{ showContent }}
</view>
</view>
</view>
</view>
<view class="user-answer" v-else-if="[1, 2].indexOf(type) >= 0">
<view class="user-info">
<view class="avatar-box">
@@ -162,7 +180,6 @@ import ChartThree from "./chartThree.vue"
import common from '@/common/common';
import { getUserInfo } from '@/common/common';
import { useStorageStore } from "@/store/storage.js"
import { demoUsage } from "@/api/arraybuffer.js"
import { onUnload } from '@dcloudio/uni-app'
const storageStore = useStorageStore()
@@ -249,6 +266,7 @@ const audioCacheObj = computed(() => storageStore.audioObj)
else if(props.type === 4) return unref(dataInfo)?.chatContent || unref(dataInfo)?.qnsContent
else if(props.type === 5) return unref(dataInfo)?.chatContent || unref(dataInfo)?.evalContent
else if(props.type === 0) return unref(dataInfo)?.chatContent || unref(dataInfo)?.talkingContent
else return unref(dataInfo)?.chatContent || unref(dataInfo)?.talkingContent
}
})
const showContent = computed(() => {
@@ -256,13 +274,6 @@ const audioCacheObj = computed(() => storageStore.audioObj)
return _str.replace(/\/n/g,"\n")
})
onMounted(()=>{
// demoUsage({
// question: unref(dataInfo)?.pgrphContent,
// streaming: true
// })
// if(props.isTransform){}
})
onUnload(()=>{
pauseVoice()
})
@@ -406,6 +417,7 @@ const audioCacheObj = computed(() => storageStore.audioObj)
.ai-answer{
width: 100%;
overflow: hidden;
margin-bottom: 20rpx;
.user-info{
overflow: hidden;
.avatar-box{
@@ -584,6 +596,7 @@ const audioCacheObj = computed(() => storageStore.audioObj)
.user-answer{
overflow: hidden;
width: 100%;
margin-bottom: 20rpx;
.user-info{
overflow: hidden;
.avatar-box{
+14 -12
View File
@@ -4,6 +4,7 @@
<view class="bot-bg"></view>
<view class="course-center-body">
<view class="body-title">
<!-- @click="test.testApi" -->
<uv-icon class="arrow-icon" name="arrow-left" @click="common.navigateBack()"/>
课程中心
</view>
@@ -112,17 +113,17 @@
</template>
<script setup>
import CourseItem from "@/components/course-item/course-item.vue"
import common from '@/common/common'
import {
getPrdLineTypeListApi,
getTraTagListApi,
getCourseTypeListApi,
queryCrsInfoByCatalogApi,
queryCrsInfoByPrdLineApi,
queryCrsInfoByLastnewApi,
queryCrsInfoByPopularApi,
queryCrsInfoByRecmdApi
import CourseItem from "@/components/course-item/course-item.vue"
import common from '@/common/common'
import {
getPrdLineTypeListApi,
getTraTagListApi,
getCourseTypeListApi,
queryCrsInfoByCatalogApi,
queryCrsInfoByPrdLineApi,
queryCrsInfoByLastnewApi,
queryCrsInfoByPopularApi,
queryCrsInfoByRecmdApi
} from "@/api/course.js"
import { onMounted, ref, computed } from 'vue'
const customStyle = {
@@ -192,7 +193,7 @@ import { onMounted, ref, computed } from 'vue'
const courseListBase = ref([])
const courseList = computed(()=>{
return activeTag.value
?courseListBase.value.filter(t=>t.tagCataList.map(k=>k.tagId).indexOf(activeTag.value)>=0)
?courseListBase.value.filter(t=>(t.tagCataList||[]).map(k=>k.tagId).indexOf(activeTag.value)>=0)
:courseListBase.value
})
// 整理树形
@@ -293,6 +294,7 @@ import { onMounted, ref, computed } from 'vue'
})
</script>
<style lang="scss" scoped>
.course-center{
position: relative;
+24 -13
View File
@@ -148,13 +148,14 @@ const inputRef = ref('')
const flagVal = ref('1')
// 初始化数据
const getData = async (flag) => {
if(flag === flagVal.value){
flagVal.value = '2'
}else{
return
}
// if(flag === flagVal.value){
// flagVal.value = '2'
// }else{
// return
// }
try{
const { body } = await getCourseStudyInfoApi({crsId: crsId.value})
console.log(body)
initsocketTask()
teacherList.value = body.teacheList.map(t=>({
...t,
@@ -280,10 +281,19 @@ const showOrder = ref(0)
const isLastPgrph = ref(false)
// 获取段落
const getGraphInfoUnStudy = () => {
if(isLastPgrph.value){
common.msg('您已学完全部知识点!')
return
}
console.log(isLastPgrph.value)
let _id = new Date().getTime() + 'id'
// if(isLastPgrph.value){
// talkingList.value.push({
// chatContent: '您已学完全部知识点!',
// userInfo: {...choiceTeacherInfo.value},
// type: 7,
// id: _id
// })
// scrollToBottomNow()
// // common.msg('您已学完全部知识点!')
// return
// }
textChartApi({
processType: 'PRGH-STDY',
requestBody: JSON.stringify({
@@ -292,8 +302,8 @@ const getGraphInfoUnStudy = () => {
stdyBatch: unref(stdyBatch)
})
}).then(res=>{
let _id = new Date().getTime() + 'id'
let _body = res.body|| {}
console.log(_body)
if(!_body.chatBody) {
return
}
@@ -480,11 +490,12 @@ onLoad((params) => {
const showTalkingModel = ref(false)
// 录音
onMounted(()=>{
console.log('init/111')
getData('1');
})
onShow(()=>{
getData('2');
})
// onShow(()=>{
// getData('2');
// })
onUnload(()=>{
changePlayItemId()
teacherVoiceObj?.stop?.()