SanHQin 11 mesiacov pred
rodič
commit
358aaa1d02

BIN
src/assets/icon/course/ai.png


+ 5 - 1
src/common/axios.config.js

@@ -17,7 +17,11 @@ axios.interceptors.request.use((config) => {
     }
     if (config.url === 'https://gpt.cocorobo.cn/chat' || config.url === 'https://gpt4.cocorobo.cn/imageAnalyse' || config.url === 'https://gpt4.cocorobo.cn/create_free_assistants' || config.url === 'https://gpt4.cocorobo.cn/assistants_completion_response') {
         config.data = config.data //序列化post 参数
-    } else if (config.data && config.data[0].post == '1' && config.method === 'post') {
+    }else if(config.url.indexOf('https://gpt4.cocorobo.cn/')!=-1){
+			config.headers = {
+				'Content-Type': 'application/json',
+		}
+	 } else if (config.data && config.data[0].post == '1' && config.method === 'post') {
         config.data = 'mode=' + (Object.values(config.data[0]).join(',')) //序列化post 参数
     } else if (config.method === 'post') {
 

+ 1200 - 760
src/components/classRoomHelper/component/dialogArea.vue

@@ -1,87 +1,157 @@
 <template>
-	<div class="dialog">
-		<div v-show="cardType == 0">
-			<div class="d_top" ref="chatRef">
-				<div class="d_t_chat" v-for="(item,index) in chatList" :key="index">
-					<div class="d_t_c_user" v-if="item.role =='user'">
-						<div class="d_t_c_u_left">
-							<div class="d_t_c_u_l_content">{{item.content}}</div>
-							<div class="d_t_c_u_l_time">{{item.time}}</div>
-						</div>
-						<div class="d_t_c_u_right">
-							<span>我</span>
-						</div>
-					</div>
+  <div class="dialog">
+    <div v-show="cardType == 0">
+      <div class="d_top" ref="chatRef">
+        <div class="d_t_chat" v-for="(item, index) in chatList" :key="index">
+          <div class="d_t_c_user" v-if="item.content">
+            <div class="d_t_c_u_left">
+              <div class="d_t_c_u_l_content">{{ item.content }}</div>
+              <div class="d_t_c_u_l_time">{{ item.createtime }}</div>
+            </div>
+            <div class="d_t_c_u_right">
+              <span>我</span>
+            </div>
+          </div>
 
-					<div class="d_t_c_ai" v-if="item.role =='ai'">
-						<div class="d_t_c_a_left">
-							<span>Ai</span>
-						</div>
-						<div class="d_t_c_a_right">
-							<div class="d_t_c_a_r_content"  v-loading="loading && index==chatList.length-1">{{ item.content }}</div>
-							<div class="d_t_c_a_r_time">{{item.time}}</div>
-						</div>
-						
-					</div>
-				</div>
-				
-			</div>
-			<div class="d_bottom">
-				<div class="d_b_btnArea">
-					<div class="d_b_ba-item" @click.stop="choiceRole()">
-						<img style="width: 20px;" src="../../../assets/icon/course/role.png" alt="">
-						选择角色
-					</div>
-				</div>
-				<div class="d_b_inputArea">
-					<!-- <div class="d_b_tape" @click="goTape()"></div> -->
-					<div class="d_b_input">
-						<el-input :disabled="loading" @keyup.enter.native="send()" class="d_b_i_left" v-model="text"></el-input>
-						<!-- <div class="d_b_i_right" @click="sendFile()">
+          <div class="d_t_c_ai">
+            <div class="d_t_c_a_left">
+              <el-avatar v-if="item.filename" :src="item.filename"></el-avatar>
+              <span v-else>Ai</span>
+            </div>
+            <div class="d_t_c_a_right">
+              <div
+                class="d_t_c_a_r_content"
+                v-loading="item.loading"
+                v-html="item.aiContent"
+              ></div>
+              <div class="d_t_c_a_r_time">{{ item.createtime }}</div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <div class="d_bottom">
+        <div class="d_b_btnArea">
+          <div class="d_b_ba-item" @click.stop="choiceRole()">
+            <img
+              style="width: 20px;"
+              src="../../../assets/icon/course/role.png"
+              alt=""
+            />
+            选择角色
+          </div>
+        </div>
+        <div class="d_b_inputArea">
+          <!-- <div class="d_b_tape" @click="goTape()"></div> -->
+          <div class="d_b_input">
+            <el-input
+              :disabled="loading || chatLoading"
+              v-loading="loading || chatLoading"
+              @keyup.enter.native="send()"
+              class="d_b_i_left"
+              v-model="text"
+            ></el-input>
+            <!-- <div class="d_b_i_right" @click="sendFile()">
 							<span></span>
 						</div> -->
-					</div>
-					<div class="d_b_btn" @click="send()">
-						<span></span>
-					</div>
-				</div>
-			</div>
-		</div>
-		<div class="" v-show="cardType == 1">
-			<div class="choiceTop">
-				<div class="choiceRoleHeader">
-					<div>切换角色:</div>
-					<span>您希望以下哪个角色回答您的问题,请选择:</span>
-				</div>
-				<div class="choiceSelect">
-					<el-button class="option" :style="{background:sortOption == 0?'#36A9FC':'',color:sortOption==0?'#fff':''}" @click="optBtn(0)" plain>我的</el-button>
-					<el-button class="option" :style="{background:sortOption == 1?'#36A9FC':'',color:sortOption==1?'#fff':''}" @click="optBtn(1)" plain>社区</el-button>
-				</div>
-				<div class="characterBlock" v-if="sortOption==0" v-for="(item,index) in roleList" :key="item.id" @click.stop="roleType=index">
-					<div class="imgLeft">
-						<div class="img">
-							<img style="width: 100%;height: 100%;" :src="item.avatar">
-						</div>
-					</div>
-					<div class="txtRight">
-						<div class="bir">{{ item.bir }}</div>
-						<div :style="{color: '#fff',display: roleType ==index?'block':'none'  }">已选择</div>
-						<!-- <span></span> -->
-					</div>
-				</div>
-				<div class="characterBlock" v-if="sortOption==1" v-for="(item,index) in roleList2" :key="item.id" @click.stop="roleType=index">
-					<div class="imgLeft">
-						<div class="img">
-							<img style="width: 100%;height: 100%;" :src="item.avatar">
-						</div>
-					</div>
-					<div class="txtRight">
-						<div class="bir">{{ item.bir }}</div>
-						<div :style="{color: '#fff',display: roleType ==index?'block':'none'  }">已选择</div>
-						<!-- <span></span> -->
-					</div>
-				</div>
-				<!-- <div class="characterBlock" @click="addCharacter">
+          </div>
+          <div class="d_b_btn" @click="send()">
+            <span></span>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="" v-show="cardType == 1">
+      <div class="choiceTop">
+        <div class="choiceRoleHeader">
+          <div>切换角色:</div>
+          <span>您希望以下哪个角色回答您的问题,请选择:</span>
+        </div>
+        <div class="choiceSelect">
+          <el-button
+            class="option"
+            :style="{
+              background: sortOption == 0 ? '#36A9FC' : '',
+              color: sortOption == 0 ? '#fff' : ''
+            }"
+            @click="optBtn(0)"
+            plain
+            >我的</el-button
+          >
+          <el-button
+            class="option"
+            :style="{
+              background: sortOption == 1 ? '#36A9FC' : '',
+              color: sortOption == 1 ? '#fff' : ''
+            }"
+            @click="optBtn(1)"
+            plain
+            >社区</el-button
+          >
+        </div>
+        <div
+          class="characterBlock"
+          v-if="sortOption == 0"
+          v-for="(item, index) in roleList"
+          :key="item.id"
+          @click.stop="choseRole(item)"
+        >
+          <div class="imgLeft">
+            <div class="img">
+              <img style="width: 100%;height: 100%;" :src="item.avatar" />
+            </div>
+          </div>
+          <div class="txtRight">
+            <div class="bir">{{ item.assistantName }}</div>
+            <div
+              :style="{
+                color: '#fff',
+                display:
+                  choseRoleItem.assistant_id == item.assistant_id
+                    ? 'block'
+                    : 'none'
+              }"
+            >
+              已选择
+            </div>
+            <!-- <span></span> -->
+          </div>
+        </div>
+        <div
+          class="characterBlock"
+          v-if="sortOption == 1"
+          v-for="(item, index) in roleList2"
+          :key="item.id"
+          @click.stop="choseRole(item)"
+        >
+          <div class="imgLeft">
+            <div class="img">
+              <img
+                style="width: 100%;height: 100%;"
+                :src="
+                  item.headUrl
+                    ? item.headUrl
+                    : require('../../../assets/icon/course/ai.png')
+                "
+              />
+            </div>
+          </div>
+          <div class="txtRight">
+            <div class="bir">{{ item.assistantName }}</div>
+            <div
+              :style="{
+                color: '#fff',
+                display:
+                  choseRoleItem.assistant_id == item.assistant_id
+                    ? 'block'
+                    : 'none'
+              }"
+            >
+              已选择
+            </div>
+            <!-- <span></span> -->
+          </div>
+        </div>
+        <!-- <div class="characterBlock" @click="addCharacter">
 					<div class="imgLeft">
 						<div class="img2">
 							<img style="width: 100%;height: 100%;" src="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/basil_add-outline1715564539170.png">
@@ -92,7 +162,7 @@
 					</div>
 				</div> -->
 
-				<!-- <div class="filterSubjects">
+        <!-- <div class="filterSubjects">
 					<div class="fs_title">筛选科目</div>
 					<div class="fs_box">
 						<div :class="['fs_b_item',subjectsType==index?'fs_b_itemActive':'']" v-for="(item,index) in subjectsList" :key="index" @click="subjectsType = index">{{ item }}</div>
@@ -108,702 +178,1072 @@
 						</div>
 					</div>
 				</div> -->
-			</div>
-			<div class="choiceBottom">
-				<el-button class="cb_btn" size="mini" @click="noChangeRole()">取消</el-button>
-				<el-button class="cb_btn" size="mini" type="primary"  @click="changeRole()">确定</el-button>
-			</div>
-		</div>
-	</div>
+      </div>
+      <div class="choiceBottom">
+        <el-button class="cb_btn" size="mini" @click="noChangeRole()"
+          >取消</el-button
+        >
+        <el-button
+          class="cb_btn"
+          size="mini"
+          type="primary"
+          @click="changeRole()"
+          >确定</el-button
+        >
+      </div>
+    </div>
+  </div>
 </template>
 
 <script>
-	export default {
-		data(){
-			return{
-				cardType:0,//0-对话 1-选角色
-				text:"",
-				sortOption: 0, //切换角色 0我的 1 社区
-				subjectsList:['语文',"数学","英语","科学","信息","历史","地理","政治","生物","化学","物理","其他"],
-				subjectsType:-1,
-				rightSubjects:-1,
-				roleType:-1,
-				rightRole:-1,
-				loading:false,
-				roleList2:[
-					{id:3,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"莱昂纳多·达芬奇",bir:'我是莱昂纳多·达芬奇'},
-					{id:4,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"列文虎克",bir:'我是列文虎克'},
-					{id:5,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特",bir:'我是詹姆斯·瓦特'},
-					{id:6,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"瑞秋·卡森",bir:'我是瑞秋·卡森'},
-					{id:7,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"尼古拉·特斯拉",bir:'我是尼古拉·特斯拉'},
-					{id:8,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰·穆尔",bir:'我是约翰·穆尔'}
-				],
-				roleList:[
-					{id:0,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"爱因斯坦",bir:'我是爱因斯坦'},
-					{id:1,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"居里夫人",bir:'我是居里夫人'},
-					{id:2,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"达尔文",bir:'我是达尔文'},
-					// {id:3,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"莱昂纳多·达芬奇"},
-					// {id:4,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"列文虎克"},
-					// {id:5,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
-					// {id:6,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"瑞秋·卡森"},
-					// {id:7,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"尼古拉·特斯拉"},
-					// {id:8,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰·穆尔"},
-					// {id:9,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"艾萨克·牛顿"},
-					// {id:10,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"伽利略"},
-					// {id:11,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"格雷戈尔·孟德尔"},
-					// {id:12,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"张衡"},
-					// {id:13,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"李时珍"},
-					// {id:14,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"钱学森"},
-					// {id:15,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿基米德"},
-					// {id:16,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"霍金"},
-					// {id:17,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"蔡伦"},
-					// {id:18,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
-					// {id:19,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"路易·巴斯德"},
-					// {id:20,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿尔弗雷德·诺贝尔"},
-					// {id:21,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·麦克斯韦"},
-					// {id:22,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"亚历山大·格拉汉姆·贝尔"},
-					// {id:23,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰内斯·开普勒"},
-					// {id:24,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"安德烈·安培"},
-				],
-				chatList:[
-					{
-						role:"ai",
-						content:`您好,有什么可以帮助您的吗?`,
-						time:new Date().toLocaleString().replace(/\//ig,'-')
-					},
-				],
-			}
-		},
-		methods: {
-			// addCharacter(){
-			// 	this.$message.info("点击了添加新角色")
-			// },
-			optBtn(val){
-				this.sortOption=val
-			},
-			choiceRole(){
-				if(this.loading)return this.$message.info("请稍等")
-				this.cardType = 1;
-			},
-			sendFile(){
-				if(this.loading)return this.$message.info("请稍等")
-				this.$message.info("点击了附件")
-			},
-			goTape(){
-				if(this.loading)return this.$message.info("请稍等")
-				this.$message.info(`点击了语音`)
-			},
-			send(){
-				if (this.loading) return this.$message.info("请稍等");
-				if(this.text.trim().length==0)return this.$message.info("请输入内容")
-				this.loading = true;
-				this.chatList.push({
-					role:"user",
-					content:this.text,
-					time:new Date().toLocaleString().replace(/\//ig,'-')
-				})
-				
-				this.chatList.push({
-					role:"ai",
-					content:"",//这里需要调用接口
-					time:new Date().toLocaleString().replace(/\//ig,'-')
-				})
-				this.$nextTick(() => {
-				  	this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-					});;
-				setTimeout(()=>{
-					let aiContent="对不起,这个问题我回答不了。"
-					switch(this.text){
-						case "为什么要进行垃圾分类?":
-							aiContent=`想象一下,我们的家里如果有很多东西乱丢一团,找东西的时候会很麻烦对吧?而且如果不清理,家里会变得很脏,还可能招来小虫子。垃圾也是一样的,如果我们把所有的垃圾都扔在一起,不仅会污染环境,还会浪费很多可以再利用的资源。
-垃圾分类就是把不同类型的垃圾分开扔。比如,有的垃圾是可以再回收利用的,像纸张、塑料瓶、玻璃瓶等,这些如果分开收集,就可以送到特殊的地方去重新处理,变成新的东西再次使用。还有一些垃圾是厨余垃圾,比如剩饭剩菜,这种可以做成肥料帮助植物生长。而其他一些不能回收的垃圾,就需要另外处理,确保它们不会对环境造成伤害。
-通过垃圾分类,我们可以减少污染,节约资源,让我们的城市更干净,也保护了我们的地球。所以,学会正确的垃圾分类,是每个人都应该做的一件重要的事情哦!`
-							break;
-						case "玻璃是可回收垃圾吗?为什么?":
-							aiContent=`是的,玻璃是可以回收的垃圾。因为玻璃可以被融化后重新制成新的玻璃制品,比如瓶子和罐子。这样做可以减少我们从自然中取材料来制造新玻璃,也可以减少垃圾的数量,保护我们的环境。所以,当我们用完玻璃制品后,应该把它们放到回收箱里,而不是扔到普通垃圾桶里。这样我们就可以帮助地球更健康。`
-							break;
-					}
-					if(this.rightRole==1){
-						switch(this.text){
-							case "为什么要进行垃圾分类":
-								aiContent=`
-								尊敬的小朋友们,今天我们要探讨一个非常重要的话题——为什么我们要进行垃圾分类。我是居里夫人,虽然我的主要研究领域是放射性元素,但我一直相信科学可以改善我们的生活环境和保护我们的地球。
-首先,我们要知道地球是我们共同的家,保护环境就是保护我们自己的家园。在我的研究生涯中,我发现了镭和钋这样的放射性元素,这些发现不仅推动了科学的进步,也让我们更加意识到科学研究与环境保护之间的联系。
-垃圾分类,简单来说,就是将垃圾分成几类,比如可回收物、有害垃圾、湿垃圾(厨余垃圾)和干垃圾。这样做的目的是让垃圾能够更有效地被回收和处理,减少对环境的污染。
-想象一下,如果我们把所有的垃圾都混在一起,那么回收和处理这些垃圾就会变得非常困难。有些有害垃圾可能会释放出有毒物质,污染土壤和水源,这对我们的健康是非常不利的。而且,混合的垃圾很难进行有效的资源回收,这意味着更多的资源会被浪费。
-通过垃圾分类,我们可以将可回收的材料如纸张、塑料、金属和玻璃分开收集,这些材料可以被再利用,制成新的产品。这不仅可以减少对自然资源的开采,还可以减少能源消耗和碳排放,帮助我们对抗全球变暖。
-此外,有害垃圾如废电池和废药品需要特殊处理,防止它们对环境造成伤害。通过正确分类,我们可以确保这些有害物质得到安全处理,保护我们的地球。
-我在研究放射性元素时,深刻体会到科学与环境之间的密切关系。每一次实验,我都尽可能地减少对环境的影响。这种对环境负责的态度,也是我们进行垃圾分类的原因之一。
-亲爱的小朋友们,通过垃圾分类,我们不仅可以保护环境,还可以学习到责任感和科学的方法。希望你们从小培养保护环境的意识,用实际行动为保护我们的地球贡献自己的力量。记住,每一个小小的行动,都是对未来的投资。
-								`
-								break;
-						}
-					}
-					// this.chatList.push({
-					// 	role:"ai",
-					// 	content:aiContent,//这里需要调用接口
-					// 	time:new Date().toLocaleString().replace(/\//ig,'-')
-					// })
-					this.chatList[this.chatList.length - 1].content = aiContent;
-          this.chatList[
-            this.chatList.length - 1
-          ].time = new Date().toLocaleString().replace(/\//gi, "-");
-					this.loading = false;
-					this.$nextTick(() => {
-				  	this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-					});
-					this.text = "";
-					
-				},5000)
-				// this.chatList.push({
-				// 	role:"user",
-				// 	content:this.text,
-				// 	time:"2023-11-11 11:10:11"
-				// },{
-				// 	role:"ai",
-				// 	content:`小朋友,你真棒!`,//这里需要调用接口
-				// 	time:"2023-11-11 11:10:11"
-				// })
-				// this.text = "";
-				// // 元素滚动条触底
-				
-			},
-			changeRole(){
-				this.loading = true;
-				this.cardType = 0;
-				this.rightSubjects = this.subjectsType;
-				this.rightRole = this.roleType;
-				this.chatList = [];
-				this.chatList.push({
-					role:"ai",
-					content:"",//这里需要调用接口
-					time:new Date().toLocaleString().replace(/\//ig,'-')
-				})
-				setTimeout(()=>{
-					let aiContent = "你好";
-					switch(this.rightRole){
-						case 0:
-							aiContent = "你好,我是爱因斯坦,相对论的提出者,相信科学的力量可以揭示宇宙的奥秘。"
-							break;
-						case 1:
-							aiContent = "你好,我是居里夫人,放射性研究的先驱,第一位获得两次诺贝尔奖的女性。"
-							break;
-						case 2:
-							aiContent = "你好,我是查尔斯·达尔文,进化论的创立者,相信物种通过自然选择不断进化。"
-							break;
-						case 3:
-							aiContent = "你好,我是达芬奇,文艺复兴的象征,艺术与科学的多面手。"
-							break;
-						case 4:
-							aiContent = "你好,我是列文虎克,通过我的简单显微镜,开启了微生物学的大门。"
-							break;
-						case 5:
-							aiContent = "你好,我是詹姆斯·瓦特,改良了蒸汽机,为工业革命提供了动力。"
-							break;
-						case 6:
-							aiContent = "你好,我是瑞秋·卡森,环保运动的先驱,通过《寂静的春天》提醒世界关注环境保护。"
-							break;
-						case 7:
-							aiContent = "你好,我是特斯拉,交流电的推广者,致力于无线电和电力传输的研究。"
-							break;
-						case 8:
-							aiContent = "你好,我是约翰·穆尔,自然保护的倡导者,努力保护美国的森林和野生地区。"
-							break;
-						case 9:
-							aiContent = "你好,我是牛顿,万有引力和三大运动定律的发现者,为现代物理学奠定了基础。"
-							break;
-						case 10:
-							aiContent = "你好,我是伽利略,通过望远镜观测支持了日心说,被誉为现代观测天文学之父。"
-							break;
-						case 11:
-							aiContent = "你好,我是孟德尔,遗传学的奠基人,通过豌豆实验发现了遗传的基本规律。"
-							break;
-						case 12:
-							aiContent = "你好,我是张衡,东汉杰出的天文学家和科学家,发明了地动仪。"
-							break;
-						case 13:
-							aiContent = "你好,我是李时珍,中国古代著名的医学家,编纂了《本草纲目》。"
-							break;
-						case 14:
-							aiContent = "你好,我是钱学森,现代火箭科学的奠基人之一,被誉为“中国航天之父”。"
-							break;
-						case 15:
-							aiContent = "你好,我是阿基米德,古希腊的数学家和物理学家,提出了浮力原理。"
-							break;
-						case 16:
-							aiContent = "你好,我是斯蒂芬·霍金,研究黑洞和宇宙起源,致力于解释宇宙的奥秘。"
-							break;
-						case 17:
-							aiContent = "你好,我是蔡伦,东汉时期改进了造纸术,使纸张更加广泛地应用于社会。"
-							break;
-						case 18:
-							aiContent = "你好,我是詹姆斯·瓦特,改良了蒸汽机,为工业革命提供了动力。"
-							break;
-						case 19:
-							aiContent = "你好,我是路易·巴斯德,微生物学的奠基人,发现了疫苗和巴斯德消毒法。"
-							break;
-						case 20:
-							aiContent = "你好,我是诺贝尔,发明了炸药,为和平与科学的贡献设立了诺贝尔奖。"
-							break;
-						case 21:
-							aiContent = "你好,我是麦克斯韦,统一了电磁理论,提出了麦克斯韦方程组。"
-							break;
-						case 22:
-							aiContent = "你好,我是贝尔,电话的发明者,致力于通信技术的发展和听力障碍人士的教育。"
-							break;
-						case 23:
-							aiContent = "你好,我是开普勒,行星运动三大定律的发现者,为天文学和物理学的发展做出了重要贡献。"
-							break;
-						case 24:
-							aiContent = "你好,我是安培,电磁学的先驱之一,提出了电流的磁效应。"
-							break;
-					}
-					this.chatList[this.chatList.length - 1].content = aiContent;
-          this.chatList[
-            this.chatList.length - 1
-          ].time = new Date().toLocaleString().replace(/\//gi, "-");
-					this.loading = false;
-				},2000)
-
-			},
-			noChangeRole(){
-				this.cardType = 0;
-				this.subjectsType = this.rightSubjects;
-				this.roleType = this.rightRole;
-			}
-		},
-	}
+import { v4 as uuidv4 } from "uuid";
+import MarkdownIt from "markdown-it";
+export default {
+  data() {
+    return {
+      cardType: 0, //0-对话 1-选角色
+      userid: this.$route.query.userid,
+      courseId: this.$route.query.courseId,
+      org: this.$route.query.org,
+      choseRoleItem: {},
+      text: "",
+      sortOption: 0, //切换角色 0我的 1 社区
+      subjectsList: [
+        "语文",
+        "数学",
+        "英语",
+        "科学",
+        "信息",
+        "历史",
+        "地理",
+        "政治",
+        "生物",
+        "化学",
+        "物理",
+        "其他"
+      ],
+      subjectsType: -1,
+      rightSubjects: -1,
+      roleType: -1,
+      rightRole: -1,
+      loading: false,
+      chatLoading: false,
+      roleList2: [
+        {
+          id: 3,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "莱昂纳多·达芬奇",
+          bir: "我是莱昂纳多·达芬奇"
+        },
+        {
+          id: 4,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "列文虎克",
+          bir: "我是列文虎克"
+        },
+        {
+          id: 5,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "詹姆斯·瓦特",
+          bir: "我是詹姆斯·瓦特"
+        },
+        {
+          id: 6,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "瑞秋·卡森",
+          bir: "我是瑞秋·卡森"
+        },
+        {
+          id: 7,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "尼古拉·特斯拉",
+          bir: "我是尼古拉·特斯拉"
+        },
+        {
+          id: 8,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "约翰·穆尔",
+          bir: "我是约翰·穆尔"
+        }
+      ],
+      roleList: [
+        {
+          id: 0,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "爱因斯坦",
+          bir: "我是爱因斯坦"
+        },
+        {
+          id: 1,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "居里夫人",
+          bir: "我是居里夫人"
+        },
+        {
+          id: 2,
+          avatar: require("../../../assets/icon/course/aiAvatar.png"),
+          name: "达尔文",
+          bir: "我是达尔文"
+        }
+        // {id:3,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"莱昂纳多·达芬奇"},
+        // {id:4,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"列文虎克"},
+        // {id:5,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
+        // {id:6,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"瑞秋·卡森"},
+        // {id:7,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"尼古拉·特斯拉"},
+        // {id:8,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰·穆尔"},
+        // {id:9,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"艾萨克·牛顿"},
+        // {id:10,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"伽利略"},
+        // {id:11,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"格雷戈尔·孟德尔"},
+        // {id:12,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"张衡"},
+        // {id:13,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"李时珍"},
+        // {id:14,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"钱学森"},
+        // {id:15,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿基米德"},
+        // {id:16,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"霍金"},
+        // {id:17,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"蔡伦"},
+        // {id:18,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
+        // {id:19,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"路易·巴斯德"},
+        // {id:20,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿尔弗雷德·诺贝尔"},
+        // {id:21,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·麦克斯韦"},
+        // {id:22,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"亚历山大·格拉汉姆·贝尔"},
+        // {id:23,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰内斯·开普勒"},
+        // {id:24,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"安德烈·安培"},
+      ],
+      chatList: []
+    };
+  },
+  methods: {
+    // addCharacter(){
+    // 	this.$message.info("点击了添加新角色")
+    // },
+    optBtn(val) {
+      this.sortOption = val;
+    },
+    choiceRole() {
+      if (this.loading) return this.$message.info("请稍等");
+      this.cardType = 1;
+    },
+    sendFile() {
+      if (this.loading) return this.$message.info("请稍等");
+      this.$message.info("点击了附件");
+    },
+    goTape() {
+      if (this.loading) return this.$message.info("请稍等");
+      this.$message.info(`点击了语音`);
+    },
+    send(_text = this.text) {
+      if (this.loading || this.chatLoading) return this.$message.info("请稍等");
+      if (_text.trim().length == 0) return this.$message.info("请输入内容");
+      this.chatLoading = true;
+      if (this.choseRoleItem.assistant_id) {
+        let _uid = uuidv4();
+        let _item = this.choseRoleItem;
+        this.chatList.push({
+          loading: true,
+          role: "user",
+          content: `${_text}`,
+          uid: _uid,
+          AI: "AI",
+          aiContent: "",
+          oldContent: "",
+          isShowSynchronization: false,
+          filename: _item.headUrl,
+          index: this.chatList.length,
+          is_mind_map: false,
+          fileid: _item.assistantName
+          // createtime: new Date().toLocaleString().replaceAll("/", "-")
+        });
+        this.text = "";
+        let params = {
+          assistant_id: this.choseRoleItem.assistant_id,
+          userId: this.userid,
+          message: _text,
+          session_name: `${this.courseId}-studyStudent-dialog`,
+          uid: _uid,
+          file_ids: []
+        };
+        this.ajax
+          .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", params)
+          .then(res => {
+            if (res.data.FunctionResponse.result == "发送成功") {
+            } else {
+              this.chatLoading = false;
+              this.$message.warning(res.data.FunctionResponse.result);
+            }
+          })
+          .catch(err => {
+            this.chatLoading = false;
+            console.log(err);
+          });
+        this.getAtAuContent(_uid);
+      } else {
+        let _uuid = uuidv4();
+        this.chatList.push({
+          role: "user",
+          content: `${_text}`,
+          uid: _uuid,
+          AI: "AI",
+          aiContent: "",
+          oldContent: "",
+          isShowSynchronization: false,
+          filename: "",
+          index: this.chatList.length,
+          is_mind_map: false,
+          loading: true
+        });
+        this.scrollBottom();
+        let params = {
+          model: "gpt-3.5-turbo",
+          temperature: 0,
+          max_tokens: 4096,
+          top_p: 1,
+          frequency_penalty: 0,
+          presence_penalty: 0,
+          messages: [{ role: "user", content: _text }],
+          uid: _uuid,
+          mind_map_question: ""
+        };
+        this.text = "";
+
+        this.ajax
+          .post("https://gpt4.cocorobo.cn/chat", params)
+          .then(res => {
+            if (res.data.FunctionResponse.result == "发送成功") {
+            } else {
+              this.chatLoading = false;
+              this.$message.warning(res.data.FunctionResponse.result);
+            }
+          })
+          .catch(e => {
+            this.chatLoading = false;
+            console.log(e);
+          });
+        this.getAiContent(_uuid);
+      }
+    },
+    // 获取ai对话
+    getAiContent(_uid) {
+      let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
+      let _allText = "";
+      let _mdText = "";
+      const md = new MarkdownIt();
+      _source.onmessage = _e => {
+        if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
+          //对话已经完成
+          _mdText = _mdText.replace("_", "");
+          _source.close();
+          this.scrollBottom();
+          this.chatLoading = false;
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).isalltext = true;
+          this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          // 这里保存对话
+          this.insertChat(_uid);
+          return;
+        } else {
+          //对话还在继续
+          let _text = "";
+          _text = _e.data.replaceAll("'", "");
+          if (_allText == "") {
+            _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
+          } else {
+            _allText += _text;
+          }
+          _mdText = _allText + "_";
+          _mdText = _mdText.replace(/\\n/g, "\n");
+          _mdText = _mdText.replace(/\\/g, "");
+          if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
+          //转化返回的回复流数据
+          _mdText = md.render(_mdText);
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          this.scrollBottom();
+          // 处理流数据
+        }
+      };
+    },
+    getAtAuContent(_uid) {
+      let _source = new EventSource(
+        `https://gpt4.cocorobo.cn/question/${_uid}`
+      ); //http://gpt4.cocorobo.cn:8011/question/   https://gpt4.cocorobo.cn/question/
+      let _allText = "";
+      let _mdText = "";
+      const md = new MarkdownIt();
+      _source.onmessage = _e => {
+        let _eData = JSON.parse(_e.data);
+        if (_eData.content.replace("'", "").replace("'", "") == "[DONE]") {
+          let _result = [];
+          if ("result" in _eData) {
+            _result = _eData.result;
+            for (let i = 0; i < _result.length; i++) {
+              _mdText = _mdText.replace(_result[i].text, _result[i].fileName);
+            }
+          }
+          _mdText = _mdText.replace("_", "");
+          this.chatLoading = false;
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).isalltext = true;
+          this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+
+          this.insertChat(_uid);
+        } else {
+          let _text = _eData.content.replace("'", "").replace("'", "");
+          if (_allText == "") {
+            _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
+          } else {
+            _allText += _text;
+          }
+          _mdText = _allText + "_";
+          _mdText = _mdText.replace(/\\n/g, "\n");
+          _mdText = _mdText.replace(/\\/g, "");
+          if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
+          //转化返回的回复流数据
+          _mdText = md.render(_mdText);
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          this.$nextTick(() => {
+            this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
+          });
+          // 处理流数据
+        }
+      };
+    },
+    //保存消息
+    insertChat(_uid) {
+      let _data = this.chatList.find(i => i.uid == _uid);
+      if (!_data) return;
+      let params = {
+        userId: this.userid,
+        userName: "qgt",
+        groupId: "602def61-005d-11ee-91d8-005056b8q12w",
+        answer: _data.aiContent,
+        problem: _data.content,
+        file_id: _data.fileid ? _data.fileid : "",
+        alltext: _data.aiContent,
+        type: "chat",
+        filename: _data.filename,
+        session_name: `${this.courseId}-studyStudent` //这是对话记录位置
+      };
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/insert_chat", params)
+        .then(res => {});
+    },
+    // 获取对应的聊天记录
+    getChatList() {
+      return new Promise((resolve, reject) => {
+        if (this.loading) return this.$message.info("请稍等...");
+        this.chatList = [];
+        this.loading = true;
+        this.chatLoading = true;
+        let params = {
+          userid: this.userid,
+          groupid: "602def61-005d-11ee-91d8-005056b8q12w",
+          // session_name:``
+          session_name: `${this.courseId}-studyStudent`
+        };
+        this.ajax
+          .post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
+          .then(res => {
+            let _data = JSON.parse(res.data.FunctionResponse);
+            if (_data.length > 0) {
+              let _chatList = [];
+              for (let i = 0; i < _data.length; i++) {
+                _chatList.push({
+                  loading: false,
+                  role: "user",
+                  content: _data[i].problem,
+                  uid: _data[i].id,
+                  AI: "AI",
+                  aiContent: _data[i].answer,
+                  oldContent: _data[i].answer,
+                  isShowSynchronization: false,
+                  filename: _data[i].filename,
+                  index: i,
+                  is_mind_map: false,
+                  fileid: _data[i].fileid
+                });
+              }
+              this.chatList = _chatList;
+              this.loading = false;
+              this.chatLoading = false;
+            } else {
+              //没有对话记录
+              this.chatLoading = false;
+              this.loading = false;
+            }
+            resolve();
+          })
+          .catch(err => {
+            console.log(err);
+            this.$message.error("获取对话记录失败");
+            this.loading = false;
+            this.chatLoading = false;
+            resolve();
+          });
+      });
+    },
+    getRoleList() {
+      this.roleList = [];
+      let params = {
+        userId: this.userid
+      };
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/get_ai_agent_assistant_list", params)
+        .then(res => {
+          let _data = res.data.FunctionResponse.result;
+          if (_data.length == 0) return;
+          if (_data) {
+            this.roleList = JSON.parse(_data);
+          }
+        })
+        .catch(e => {
+          console.log("获取角色列表失败");
+          this.roleList = [];
+        });
+    },
+    getPublicRoleList() {
+      this.roleList2 = [];
+      let params = {
+        userId: this.userid,
+        // organizeid: this.org,
+        organizeid: "45facc0a-1211-11ec-80ad-005056b86db5"
+      };
+      this.ajax
+        .post(
+          "https://gpt4.cocorobo.cn/get_ai_agent_assistant_share_list",
+          params
+        )
+        .then(res => {
+          let _data = res.data.FunctionResponse.result;
+          if (_data.length == 0) return;
+          if (_data) {
+            this.roleList2 = JSON.parse(_data);
+          }
+        })
+        .catch(e => {
+          this.roleList2 = [];
+          console.log("获取公共角色失败", e);
+        });
+    },
+    changeRole() {
+      this.cardType = 0;
+      // this.rightSubjects = this.subjectsType;
+      // this.rightRole = this.roleType;
+      if (this.choseRoleItem.assistant_id) {
+        this.chatList = [];
+        let _uuid = uuidv4();
+        this.chatList.push({
+          role: "user",
+          content: `您好,${this.choseRoleItem.assistantName}`,
+          uid: _uuid,
+          AI: "AI",
+          aiContent: this.choseRoleItem.prologue
+            ? this.choseRoleItem.prologue
+            : "您好,有什么需要我帮忙的吗?",
+          oldContent: "",
+          isShowSynchronization: false,
+          filename: this.choseRoleItem.headUrl,
+          index: this.chatList.length,
+          is_mind_map: false,
+          loading: false
+        });
+        this.scrollBottom();
+      }
+
+      // let params = {
+      //   model: "gpt-3.5-turbo",
+      //   temperature: 0,
+      //   max_tokens: 4096,
+      //   top_p: 1,
+      //   frequency_penalty: 0,
+      //   presence_penalty: 0,
+      //   messages: [{ role: "user", content: `你好,${_text}` }],
+      //   uid: _uuid,
+      //   mind_map_question: ""
+      // };
+      // this.text = "";
+
+      // this.ajax
+      //   .post("https://gpt4.cocorobo.cn/chat", params)
+      //   .then(res => {
+      //     if (res.data.FunctionResponse.result == "发送成功") {
+      //     } else {
+      //       this.$message.warning(res.data.FunctionResponse.result);
+      //     }
+      //   })
+      //   .catch(e => {
+      //     console.log(e);
+      //   });
+      // this.getAiContent(_uuid);
+      // this.chatList.push({
+      //   role: "ai",
+      //   content: "", //这里需要调用接口
+      //   time: new Date().toLocaleString().replace(/\//gi, "-")
+      // });
+      // setTimeout(() => {
+      //   let aiContent = "你好";
+      //   switch (this.rightRole) {
+      //     case 0:
+      //       aiContent =
+      //         "你好,我是爱因斯坦,相对论的提出者,相信科学的力量可以揭示宇宙的奥秘。";
+      //       break;
+      //     case 1:
+      //       aiContent =
+      //         "你好,我是居里夫人,放射性研究的先驱,第一位获得两次诺贝尔奖的女性。";
+      //       break;
+      //     case 2:
+      //       aiContent =
+      //         "你好,我是查尔斯·达尔文,进化论的创立者,相信物种通过自然选择不断进化。";
+      //       break;
+      //     case 3:
+      //       aiContent =
+      //         "你好,我是达芬奇,文艺复兴的象征,艺术与科学的多面手。";
+      //       break;
+      //     case 4:
+      //       aiContent =
+      //         "你好,我是列文虎克,通过我的简单显微镜,开启了微生物学的大门。";
+      //       break;
+      //     case 5:
+      //       aiContent =
+      //         "你好,我是詹姆斯·瓦特,改良了蒸汽机,为工业革命提供了动力。";
+      //       break;
+      //     case 6:
+      //       aiContent =
+      //         "你好,我是瑞秋·卡森,环保运动的先驱,通过《寂静的春天》提醒世界关注环境保护。";
+      //       break;
+      //     case 7:
+      //       aiContent =
+      //         "你好,我是特斯拉,交流电的推广者,致力于无线电和电力传输的研究。";
+      //       break;
+      //     case 8:
+      //       aiContent =
+      //         "你好,我是约翰·穆尔,自然保护的倡导者,努力保护美国的森林和野生地区。";
+      //       break;
+      //     case 9:
+      //       aiContent =
+      //         "你好,我是牛顿,万有引力和三大运动定律的发现者,为现代物理学奠定了基础。";
+      //       break;
+      //     case 10:
+      //       aiContent =
+      //         "你好,我是伽利略,通过望远镜观测支持了日心说,被誉为现代观测天文学之父。";
+      //       break;
+      //     case 11:
+      //       aiContent =
+      //         "你好,我是孟德尔,遗传学的奠基人,通过豌豆实验发现了遗传的基本规律。";
+      //       break;
+      //     case 12:
+      //       aiContent =
+      //         "你好,我是张衡,东汉杰出的天文学家和科学家,发明了地动仪。";
+      //       break;
+      //     case 13:
+      //       aiContent =
+      //         "你好,我是李时珍,中国古代著名的医学家,编纂了《本草纲目》。";
+      //       break;
+      //     case 14:
+      //       aiContent =
+      //         "你好,我是钱学森,现代火箭科学的奠基人之一,被誉为“中国航天之父”。";
+      //       break;
+      //     case 15:
+      //       aiContent =
+      //         "你好,我是阿基米德,古希腊的数学家和物理学家,提出了浮力原理。";
+      //       break;
+      //     case 16:
+      //       aiContent =
+      //         "你好,我是斯蒂芬·霍金,研究黑洞和宇宙起源,致力于解释宇宙的奥秘。";
+      //       break;
+      //     case 17:
+      //       aiContent =
+      //         "你好,我是蔡伦,东汉时期改进了造纸术,使纸张更加广泛地应用于社会。";
+      //       break;
+      //     case 18:
+      //       aiContent =
+      //         "你好,我是詹姆斯·瓦特,改良了蒸汽机,为工业革命提供了动力。";
+      //       break;
+      //     case 19:
+      //       aiContent =
+      //         "你好,我是路易·巴斯德,微生物学的奠基人,发现了疫苗和巴斯德消毒法。";
+      //       break;
+      //     case 20:
+      //       aiContent =
+      //         "你好,我是诺贝尔,发明了炸药,为和平与科学的贡献设立了诺贝尔奖。";
+      //       break;
+      //     case 21:
+      //       aiContent =
+      //         "你好,我是麦克斯韦,统一了电磁理论,提出了麦克斯韦方程组。";
+      //       break;
+      //     case 22:
+      //       aiContent =
+      //         "你好,我是贝尔,电话的发明者,致力于通信技术的发展和听力障碍人士的教育。";
+      //       break;
+      //     case 23:
+      //       aiContent =
+      //         "你好,我是开普勒,行星运动三大定律的发现者,为天文学和物理学的发展做出了重要贡献。";
+      //       break;
+      //     case 24:
+      //       aiContent =
+      //         "你好,我是安培,电磁学的先驱之一,提出了电流的磁效应。";
+      //       break;
+      //   }
+      //   this.chatList[this.chatList.length - 1].content = aiContent;
+      //   this.chatList[
+      //     this.chatList.length - 1
+      //   ].time = new Date().toLocaleString().replace(/\//gi, "-");
+      //   this.loading = false;
+      // }, 2000);
+    },
+    choseRole(item) {
+      this.choseRoleItem = item;
+    },
+    noChangeRole() {
+      this.cardType = 0;
+      // this.subjectsType = this.rightSubjects;
+      // this.roleType = this.rightRole;
+    },
+    scrollBottom() {
+      this.$nextTick(() => {
+        this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
+      });
+    }
+  },
+  mounted() {
+    this.getRoleList();
+    this.getPublicRoleList();
+    this.getChatList().then(_ => {
+      this.scrollBottom();
+    });
+  }
+};
 </script>
 
 <style scoped>
-.dialog{
-	width: 100%;
-	height: 100%;
-	box-sizing: border-box;
-}
-
-.dialog>div{
-	width: 100%;
-	height: 100%;
-}
-
-.characterBlock{
-	display: flex;
-	background: rgba(54, 169, 252, 1);
-	width: 100%;
-	height: 80px;
-	margin: 0 auto;
-	border-radius: 10px;
-	margin-bottom: 15px;
-	cursor: pointer;
-}
-.characterBlock > .imgLeft{
-	width: 100px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-}
-.characterBlock > .imgLeft > .img{
-	width: 60px;
-	height: 60px;
-	overflow: hidden;
-	border-radius: 50%;	
-}
-.characterBlock > .imgLeft > .img2{
-	width: 70px;
-	height: 70px;
-	overflow: hidden;
-	border-radius: 50%;	
-}
-.characterBlock > .txtRight{
-	flex: 1;
-	display: flex;
-	justify-content: flex-start;
-	align-items: center;
-}
-.characterBlock > .txtRight > .bir{
-	width: 180px;
-	height: 35px;
-	display: flex;
-	align-items: center;
-	background-color: #fff;
-	border-radius: 10px;
-	box-sizing: border-box;
-	padding: 5px 10px;
-	box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
-	margin-right: 10px;
-}
-
-.d_top{
-	width: 100%;
-	height: calc(100% - 90px);
-	overflow: auto;
-	box-sizing: border-box;
-	padding: 20px 0;
-}
-
-.d_t_chat{
-	width: 100%;
-	display: flex;
-	box-sizing: border-box;
-	padding: 10px;
-}
-
-.d_t_chat>div{
-	display: flex;
-	align-items: flex-start;
-	width: 100%;
-}
-
-.d_t_c_user{
-	box-sizing: border-box;
-	padding-left: 35px;
-}
-
-.d_t_c_u_left{
-	width: 90%;
-	height: auto;
-}
-
-.d_t_c_u_l_content{
-	width: auto;
-	max-width: 100%;
-	height: auto;
-	box-sizing: border-box;
-	padding: 10px;
-	color: white;
-	background-color: #3681FC;
-	border-radius: 8px 2px 8px 8px;
-  white-space: pre-line
-}
-
-.d_t_c_u_l_time{
-	width: 100%;
-	display: flex;
-	justify-content: flex-end;
-	font-size: 12px;
-	color: #9F9F9F;
-	margin-top: 5px;
-}
-
-.d_t_c_u_right{
-	width: 35px;
-	height: 35px;
-	display: flex;
-	justify-content: center;
-	margin-left: 5px
-}
-
-.d_t_c_u_right>span{
-	width: 32px;
-	height: 32px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	color: white;
-	background-color: #3681FC;
-	border-radius: 50%;;
-}
-
-.d_t_c_ai{
-	box-sizing: border-box;
-	padding-right: 35px;
-}
-
-.d_t_c_a_right{
-	min-width: 90%;
-	height: auto;
-}
-
-.d_t_c_a_r_content{
-	width: auto;
-	max-width: 100%;
-	height: auto;
-	box-sizing: border-box;
-	padding: 10px;
-	background-color: #F6F8FF;
-	border-radius: 2px 8px 8px 8px;
+.dialog {
+  width: 100%;
+  height: 100%;
+  box-sizing: border-box;
+}
+
+.dialog > div {
+  width: 100%;
+  height: 100%;
+}
+
+.characterBlock {
+  display: flex;
+  background: rgba(54, 169, 252, 1);
+  width: 100%;
+  height: 80px;
+  margin: 0 auto;
+  border-radius: 10px;
+  margin-bottom: 15px;
+  cursor: pointer;
+}
+.characterBlock > .imgLeft {
+  width: 100px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.characterBlock > .imgLeft > .img {
+  width: 60px;
+  height: 60px;
+  overflow: hidden;
+  border-radius: 50%;
+}
+.characterBlock > .imgLeft > .img2 {
+  width: 70px;
+  height: 70px;
+  overflow: hidden;
+  border-radius: 50%;
+}
+.characterBlock > .txtRight {
+  flex: 1;
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+}
+.characterBlock > .txtRight > .bir {
+  width: 180px;
+  height: 35px;
+  display: flex;
+  align-items: center;
+  background-color: #fff;
+  border-radius: 10px;
+  box-sizing: border-box;
+  padding: 5px 10px;
+  box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
+  margin-right: 10px;
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+}
+
+.d_top {
+  width: 100%;
+  height: calc(100% - 90px);
+  overflow: auto;
+  box-sizing: border-box;
+  padding: 20px 0;
+}
+
+.d_t_chat {
+  width: 100%;
+  display: flex;
+  box-sizing: border-box;
+  padding: 10px;
+  flex-direction: column;
+}
+
+.d_t_chat > div {
+  display: flex;
+  align-items: flex-start;
+  width: 100%;
+}
+
+.d_t_c_user {
+  box-sizing: border-box;
+  padding-left: 35px;
+}
+
+.d_t_c_u_left {
+  width: 90%;
+  height: auto;
+}
+
+.d_t_c_u_l_content {
+  width: auto;
+  max-width: 100%;
+  height: auto;
+  box-sizing: border-box;
+  padding: 10px;
+  color: white;
+  background-color: #3681fc;
+  border-radius: 8px 2px 8px 8px;
   white-space: pre-line;
-	word-break: break-all;
-}
-
-.d_t_c_a_r_time{
-	width: 100%;
-	display: flex;
-	justify-content: flex-start;
-	font-size: 12px;
-	color: #9F9F9F;
-	margin-top: 5px;
-}
-
-.d_t_c_a_left{
-	width: 35px;
-	height: 35px;
-	display: flex;
-	justify-content: center;
-	margin-right: 5px
-}
-
-.d_t_c_a_left>span{
-	width: 32px;
-	height: 32px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	color: white;
-	background-color: #3681FC;
-	border-radius: 50%;
-}
-
-.d_bottom{
-	width: 100%;
-	height: 90px;
-	display: flex;
-	flex-direction: column;
-	justify-content: space-between;
-}
-
-.d_b_btnArea{
-	width: 100%;
-	height: 30px;
-	display: flex;
-	align-items: center;
-	box-sizing: border-box;
-	padding: 0 10px;
-}
-
-.d_b_ba-item{
-	width: auto;
-	box-sizing: border-box;
-	padding: 0 10px;
-	height: 25px;
-	background-color: white;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	/* 阴影 */
-	box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.363);
-	border-radius: 15px;
-	font-size: 14px;
-	cursor: pointer;
-}
-
-
-.d_b_inputArea{
-	width: 100%;
-	height: 55px;
-	box-sizing: border-box;
-	border-top: solid 1px #EDEDED;
-	display: flex;
-	justify-content: space-between;
-	padding-right: 10px;
-	align-items: center;
-}
-
-.d_b_tape{
-	width: 35px;
-	height: 35px;
-	background: url("../../../assets/icon/course/tape.png") no-repeat;
-	background-size: 50% 60%;
-	background-position: center;
-	cursor: pointer;
-}
-
-.d_b_input{
-	/* width: 75%; */
-	flex: 1;
-	height: 45px;
-	background-color: #F3F3F3;
-	border-radius: 50px;
-	margin: 0 10px;
-	display: flex;
-	overflow: hidden;
-	align-items: center;
-}
-
-.d_b_i_left{
-	width: 100%;
-	line-height: 45px;
-	height: 100%;
-}
-
-.d_b_i_left>>>.el-input__inner{
-	border: none;
-	background-color: #F3F3F3;
-	outline: none;
-	border-radius: 50px 0 0 50px;
-}
-
-
-.d_b_i_right{
-	width: 45px;
-	height: 45px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-}
-
-.d_b_i_right>span{
-	width: 35px;
-	height: 35px;
-	background: url("../../../assets/icon/course/file.png") no-repeat;
-	background-size: 50% 60%;
-	background-position: center;
-	cursor: pointer;
-}
-
-.d_b_btn{
-	width: 40px;
-	height: 40px;
-	background-color: #3681FC;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	border-radius: 50%;
-	cursor: pointer;
-}
-
-.d_b_btn>span{
-	width: 30px;
-	height: 30px;
-	background: url("../../../assets/icon/course/send.png") no-repeat;
-	background-size: 70% 70%;
-	background-position: center;
-	
-}
-
-.choiceTop{
-	width: 100%;
-	height: 95%;
-	overflow-x: hidden;
-	box-sizing: border-box;
-	padding: 10px;
-}
-
-.choiceBottom{
-	width: 100%;
-	height: 5%;
-	display: flex;
-	align-items: center;
-	justify-content: flex-end;
-}
-
-.cb_btn{
-	margin: 0 10px;
-}
-
-.choiceRoleHeader{
-	width: 100%;
-	/* margin: 10px; */
-	margin-bottom: 20px;
-}
-
-.choiceRoleHeader>div{
-	font-size: 16px;
-	font-weight: bold;
-}
-
-.choiceRoleHeader>span{
-	font-size: 14px;
 }
-.choiceSelect{
-	width: 100%;
-	display: flex;
-	height: 35px;
-	justify-content: flex-start;
-	align-items: center;
-	margin: 15px 0;
+
+.d_t_c_u_l_time {
+  width: 100%;
+  display: flex;
+  justify-content: flex-end;
+  font-size: 12px;
+  color: #9f9f9f;
+  margin-top: 5px;
 }
-.choiceSelect > .option{
-	width: 80px;
-	height: 100%;
-	border-radius: 5px;
-	margin-right: 10px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	cursor: pointer;
+
+.d_t_c_u_right {
+  width: 35px;
+  height: 35px;
+  display: flex;
+  justify-content: center;
+  margin-left: 5px;
 }
-.filterSubjects{
-	margin: 10px;
-	width: 100%;
-	height: auto;
+
+.d_t_c_u_right > span {
+  width: 32px;
+  height: 32px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: white;
+  background-color: #3681fc;
+  border-radius: 50%;
 }
 
-.fs_box{
-	width: 100%;
-	display: flex;
-	flex-wrap: wrap;
-	margin-top: 10px;
-}
-
-.fs_b_item{
-	width: auto;
-	height: 35px;
-	font-size: 14px;
-	box-sizing: border-box;
-	padding: 0 9px;
-	background-color: #F3F7FD;
-	border: solid 1px #F3F7FD;
-	border-radius: 5px;
-	margin-right:8px;
-	margin-bottom: 8px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	cursor: pointer;
-}
-
-.fs_b_itemActive{
-	border: solid 1px #4D8FFC;
-	color: #4D8FFC;
-	background-color: #F3F7FD;
+.d_t_c_ai {
+  box-sizing: border-box;
+  padding-right: 35px;
+  margin-top: 10px;
 }
 
-.roleList{
-	width: 100%;
-	height: auto;
-	margin: 10px;
+.d_t_c_a_right {
+  min-width: 90%;
+  height: auto;
+}
+
+.d_t_c_a_r_content {
+  width: auto;
+  max-width: 100%;
+  height: auto;
+  box-sizing: border-box;
+  padding: 10px;
+  background-color: #f6f8ff;
+  border-radius: 2px 8px 8px 8px;
+  white-space: pre-line;
+  word-break: break-all;
 }
 
-.r_box{
-	width: 100%;
-	height: auto;
-	display: flex;
-	flex-wrap: wrap;
+.d_t_c_a_r_time {
+  width: 100%;
+  display: flex;
+  justify-content: flex-start;
+  font-size: 12px;
+  color: #9f9f9f;
+  margin-top: 5px;
 }
 
-.r_b_item{
-	height: 40px;
-	font-size: 14px;
-	display: flex;
-	/* justify-content: center; */
-	align-items: center;
-	background-color: #F0F2F5;
-	border-radius: 5px;
-	margin: 5px;
-	cursor: pointer;
-	box-sizing: border-box;
-	padding: 0 4px;
-	border: solid 1px #F0F2F5;
+.d_t_c_a_left {
+  width: 35px;
+  height: 35px;
+  display: flex;
+  justify-content: center;
+  margin-right: 5px;
 }
 
-.r_b_itemActive{
-	box-sizing: border-box;
-	border: solid 1px #AECCFE;
-	color: #4D8FFB;
-}
-
-.r_b_item>img{
-	min-width: 24px;
-	min-height: 24px;
-	width: 24px;
-	height: 24px;
-	border-radius:50%;
-	margin-right: 10px;
-	/* margin-left: 10px; */
-}
-
-
-
-</style>
+.d_t_c_a_left > span {
+  width: 32px;
+  height: 32px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: white;
+  background-color: #3681fc;
+  border-radius: 50%;
+}
+
+.d_bottom {
+  width: 100%;
+  height: 90px;
+  display: flex;
+  flex-direction: column;
+  justify-content: space-between;
+}
+
+.d_b_btnArea {
+  width: 100%;
+  height: 30px;
+  display: flex;
+  align-items: center;
+  box-sizing: border-box;
+  padding: 0 10px;
+}
+
+.d_b_ba-item {
+  width: auto;
+  box-sizing: border-box;
+  padding: 0 10px;
+  height: 25px;
+  background-color: white;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  /* 阴影 */
+  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.363);
+  border-radius: 15px;
+  font-size: 14px;
+  cursor: pointer;
+}
+
+.d_b_inputArea {
+  width: 100%;
+  height: 55px;
+  box-sizing: border-box;
+  border-top: solid 1px #ededed;
+  display: flex;
+  justify-content: space-between;
+  padding-right: 10px;
+  align-items: center;
+}
+
+.d_b_tape {
+  width: 35px;
+  height: 35px;
+  background: url("../../../assets/icon/course/tape.png") no-repeat;
+  background-size: 50% 60%;
+  background-position: center;
+  cursor: pointer;
+}
+
+.d_b_input {
+  /* width: 75%; */
+  flex: 1;
+  height: 45px;
+  background-color: #f3f3f3;
+  border-radius: 50px;
+  margin: 0 10px;
+  display: flex;
+  overflow: hidden;
+  align-items: center;
+}
+
+.d_b_i_left {
+  width: 100%;
+  line-height: 45px;
+  height: 100%;
+}
+
+.d_b_i_left >>> .el-input__inner {
+  border: none;
+  background-color: #f3f3f3;
+  outline: none;
+  border-radius: 50px 0 0 50px;
+}
+
+.d_b_i_right {
+  width: 45px;
+  height: 45px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+
+.d_b_i_right > span {
+  width: 35px;
+  height: 35px;
+  background: url("../../../assets/icon/course/file.png") no-repeat;
+  background-size: 50% 60%;
+  background-position: center;
+  cursor: pointer;
+}
+
+.d_b_btn {
+  width: 40px;
+  height: 40px;
+  background-color: #3681fc;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 50%;
+  cursor: pointer;
+}
+
+.d_b_btn > span {
+  width: 30px;
+  height: 30px;
+  background: url("../../../assets/icon/course/send.png") no-repeat;
+  background-size: 70% 70%;
+  background-position: center;
+}
+
+.choiceTop {
+  width: 100%;
+  height: 95%;
+  overflow-x: hidden;
+  box-sizing: border-box;
+  padding: 10px;
+}
+
+.choiceBottom {
+  width: 100%;
+  height: 5%;
+  display: flex;
+  align-items: center;
+  justify-content: flex-end;
+}
+
+.cb_btn {
+  margin: 0 10px;
+}
+
+.choiceRoleHeader {
+  width: 100%;
+  /* margin: 10px; */
+  margin-bottom: 20px;
+}
+
+.choiceRoleHeader > div {
+  font-size: 16px;
+  font-weight: bold;
+}
+
+.choiceRoleHeader > span {
+  font-size: 14px;
+}
+.choiceSelect {
+  width: 100%;
+  display: flex;
+  height: 35px;
+  justify-content: flex-start;
+  align-items: center;
+  margin: 15px 0;
+}
+.choiceSelect > .option {
+  width: 80px;
+  height: 100%;
+  border-radius: 5px;
+  margin-right: 10px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+}
+.filterSubjects {
+  margin: 10px;
+  width: 100%;
+  height: auto;
+}
+
+.fs_box {
+  width: 100%;
+  display: flex;
+  flex-wrap: wrap;
+  margin-top: 10px;
+}
+
+.fs_b_item {
+  width: auto;
+  height: 35px;
+  font-size: 14px;
+  box-sizing: border-box;
+  padding: 0 9px;
+  background-color: #f3f7fd;
+  border: solid 1px #f3f7fd;
+  border-radius: 5px;
+  margin-right: 8px;
+  margin-bottom: 8px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  cursor: pointer;
+}
+
+.fs_b_itemActive {
+  border: solid 1px #4d8ffc;
+  color: #4d8ffc;
+  background-color: #f3f7fd;
+}
+
+.roleList {
+  width: 100%;
+  height: auto;
+  margin: 10px;
+}
+
+.r_box {
+  width: 100%;
+  height: auto;
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.r_b_item {
+  height: 40px;
+  font-size: 14px;
+  display: flex;
+  /* justify-content: center; */
+  align-items: center;
+  background-color: #f0f2f5;
+  border-radius: 5px;
+  margin: 5px;
+  cursor: pointer;
+  box-sizing: border-box;
+  padding: 0 4px;
+  border: solid 1px #f0f2f5;
+}
+
+.r_b_itemActive {
+  box-sizing: border-box;
+  border: solid 1px #aeccfe;
+  color: #4d8ffb;
+}
+
+.r_b_item > img {
+  min-width: 24px;
+  min-height: 24px;
+  width: 24px;
+  height: 24px;
+  border-radius: 50%;
+  margin-right: 10px;
+  /* margin-left: 10px; */
+}
+</style>

+ 428 - 223
src/components/classRoomHelper/component/searchArea.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="search">
     <div class="s_top" ref="chatRef">
-      <div class="s_t_chat">
+      <!-- <div class="s_t_chat">
         <div class="s_t_c_ai">
           <div class="s_t_c_a_left">
             <span>Ai</span>
@@ -26,25 +26,28 @@
             </div>
           </div>
         </div>
-      </div>
-      <div
-        class="s_t_chat"
-        v-for="(item, index) in chatList"
-        :key="index"
-      >
-        <div class="s_t_c_user" v-if="item.role == 'user'">
+      </div> -->
+      <div class="s_t_chat" v-for="(item, index) in chatList" :key="index">
+        <div
+          class="s_t_c_user"
+          v-if="item.content && item.content != 'wanSearch'"
+        >
           <div class="s_t_c_u_left">
             <div class="s_t_c_u_l_content">{{ item.content }}</div>
-            <div class="s_t_c_u_l_time">{{ item.time }}</div>
+            <div class="s_t_c_u_l_time">{{ item.createtime }}</div>
           </div>
           <div class="s_t_c_u_right">
             <span>我</span>
           </div>
         </div>
 
-        <div class="s_t_c_ai" v-if="item.role == 'ai'">
+        <div class="s_t_c_ai" v-if="item.content != 'wanSearch'">
           <div class="aiCopy">
-            <img style="width: 30px;" src="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%A4%8D%E5%88%B6%E5%9B%BE%E6%A0%871715569581741.png" alt="">
+            <img
+              style="width: 30px;"
+              src="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%A4%8D%E5%88%B6%E5%9B%BE%E6%A0%871715569581741.png"
+              alt=""
+            />
           </div>
           <div class="s_t_c_a_left">
             <span>Ai</span>
@@ -52,23 +55,15 @@
           <div class="s_t_c_a_right">
             <div
               class="s_t_c_a_r_content"
-              v-loading="loading && index == chatList.length - 1"
-              v-if="item.type == 0"
-            >{{ item.content }}
-            </div>
-            <div
+              v-loading="item.loading"
+              v-html="item.aiContent"
+            ></div>
+            <!-- <div
               class="s_t_c_a_r_contentImage"
               v-loading="loading && index == chatList.length - 1"
               v-if="item.type == 1"
             >
               <span style="margin-bottom: 10px;">为您找到以下图片:</span>
-              <!-- <el-image 
-  							  style="width: 45%;height: 125px;margin: 1% 1.5%;"
-  							  v-for="(item,index) in item.content"
-									:key="index"
-									:src="item"
-  							  :preview-src-list="item">
-  							</el-image> -->
               <img
                 v-for="(item, index) in item.content"
                 @click.stop="$hevueImgPreview(item)"
@@ -83,8 +78,34 @@
                   <img style="width: 36px;height: 30px;" src="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/Frame%20131715569413607.png" alt="">
                 </div>
               </div>
+            </div> -->
+            <div class="s_t_c_a_r_time">{{ item.createtime }}</div>
+          </div>
+        </div>
+
+        <div class="s_t_chat" v-if="item.content == 'wanSearch'">
+          <div class="s_t_c_ai">
+            <div class="s_t_c_a_left">
+              <el-avatar v-if="item.filename" :src="item.filename"></el-avatar>
+              <span v-else>Ai</span>
+            </div>
+            <div class="s_t_c_a_right">
+              <div class="s_t_c_a_r_content2" v-loading="item.loading">
+                <div class="s_t_c_a_r_c_title">
+                  <img :src="require('../../../assets/icon/course/idea.png')" />
+                  <span>猜你想搜:</span>
+                </div>
+                <div
+                  class="s_t_c_a_r_c_item"
+                  v-for="(item, index) in item.aiContent"
+                  :key="index"
+                  @click="sendAiIdea(item.label)"
+                >
+                  {{ index + 1 }}.{{ item.title }}:{{ item.label }}
+                </div>
+              </div>
+              <div class="s_t_c_a_r_time">{{ item.createtime }}</div>
             </div>
-            <div class="s_t_c_a_r_time">{{ item.time }}</div>
           </div>
         </div>
       </div>
@@ -114,8 +135,9 @@
         <!-- <div class="s_b_tape" @click="goTape()"></div> -->
         <div class="s_b_input">
           <el-input
-            :disabled="loading"
-						@keyup.enter.native="send()"
+            :disabled="loading || chatLoading"
+            v-loading="loading || chatLoading"
+            @keyup.enter.native="send()"
             class="s_b_i_left"
             v-model="text"
           ></el-input>
@@ -132,53 +154,26 @@
 </template>
 
 <script>
+import { v4 as uuidv4 } from "uuid";
+import MarkdownIt from "markdown-it";
 export default {
+  props: {
+    courseDetail: {
+      type: Object,
+      default: () => {}
+    }
+  },
   data() {
     return {
       text: "",
       loading: false,
+      chatLoading: false,
       imageCheck: false,
       videoCheck: false,
-      imgNumList:[
-        'U1','U2','U3','U4'
-      ],
-      wantSearch: [
-        {
-          index: 1,
-          title: "垃圾分类标准",
-          label: "不同国家的垃圾分类标准和方法?"
-        },
-        {
-          index: 2,
-          title: "可回收垃圾处理",
-          label: "可回收垃圾的处理流程和再利用方法?"
-        },
-        {
-          index: 3,
-          title: "有害垃圾的影响",
-          label: "有害垃圾对环境和人体健康的潜在影响?"
-        }
-      ],
-      chatList: [
-        {
-          role: "ai",
-          content: `您好,有什么可以帮助您的吗?`,
-          time: new Date().toLocaleString().replace(/\//gi, "-"),
-          type: 0
-        }
-        // 					{
-        // 						role:"user",
-        // 						content:"正十三边形的每个角是多少度?",
-        // 						time:"2023-11-11 11:10:11"
-        // 					},
-        // 					{
-        // 						role:"ai",
-        // 						content:`小朋友们,你们知道正十三边形吗?就像我们班有13个好朋友站成一个圈圈一样。如果我们想知道每个人转身看向下一个人需要转多少度,我们可以这样想:首先,所有朋友手拉手围成的圈圈是360度,对吧?但是,我们不能直接算每个人转身的角度,因为那是外面的角度,我们要算里面的角度,就像每个人转身时脚尖指向圈心的角度。
-        // 我们先用一个小技巧,算出所有内角加起来是多少度。方法是:(13-2)乘以180度,得到1980度。这是因为,想象成一个多边形,它可以分成11个三角形,每个三角形的角度和是180度。
-        // 然后,我们把1980度平分给13个角,就是每个角的度数了。算一算,1980除以13等于152度。所以,正十三边形的每个角是152度。就像每个人转身看下一个朋友,每个人需要转152度一样。`,
-        // 						time:"2023-11-11 11:10:11"
-        // 					},
-      ]
+      userid: this.$route.query.userid,
+      courseId: this.$route.query.courseId,
+      imgNumList: ["U1", "U2", "U3", "U4"],
+      chatList: []
     };
   },
   methods: {
@@ -186,174 +181,382 @@ export default {
       this.cardType = 1;
     },
     sendFile() {
-			if (this.loading) return this.$message.info("请稍等");
+      if (this.loading) return this.$message.info("请稍等");
       this.$message.info("点击了附件");
     },
     goTape() {
-			if (this.loading) return this.$message.info("请稍等");
+      if (this.loading) return this.$message.info("请稍等");
       this.$message.info(`点击了语音`);
     },
-    send() {
-      if (this.loading) return this.$message.info("请稍等");
-			if(this.text.trim().length==0)return this.$message.info("请输入内容")
-      this.loading = true;
+    send(_text = this.text) {
+      if (this.loading || this.chatLoading) return this.$message.info("请稍等");
+      if (_text.trim().length == 0) return this.$message.info("请输入内容");
+			let _msg = ``;
+      this.chatLoading = true;
+      let _uuid = uuidv4();
       this.chatList.push({
         role: "user",
-        content: this.text,
-        time: new Date().toLocaleString().replace(/\//gi, "-")
-      });
-			
-      this.chatList.push({
-        role: "ai",
-        content: "",
-        type: 0,
-        time: new Date().toLocaleString().replace(/\//gi, "-")
-      });
-      this.$nextTick(() => {
-        this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
+        content: `${_text}`,
+        uid: _uuid,
+        AI: "AI",
+        aiContent: "",
+        oldContent: "",
+        isShowSynchronization: false,
+        filename: "",
+        index: this.chatList.length,
+        is_mind_map: false,
+        loading: true
       });
-      setTimeout(() => {
-        let aiContent = "对不起,这个问题我回答不了。";
-        let type = 0;
-
-        switch (this.text) {
-          case "帮我查找几张常见的不同类型的垃圾图片":
-            aiContent = [
-              "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8721713253471000.png",
-              "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8731713253488299.png",
-              "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8741713253506303.png",
-              "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8751713253523152.png"
-            ];
-            type = 1;
-            break;
-          case "帮我查找一些B站的视频,介绍垃圾如何处理":
-            aiContent = `当然,以下是关于垃圾处理的一些B站视频链接:
-1.【科普短视频】垃圾会被怎么处理? - 这个视频通过简短的内容向观众展示垃圾处理的过程。
-https://www.bilibili.com/video/BV1UD4y1U71a
-
-2.垃圾分类,就是这么简单- 这个视频以科普的形式,向观众介绍了垃圾分类的基本知识。
-https://www.bilibili.com/video/BV1bt41157wH 
- 
-3.【环保短片】震撼环保公益短片《致我们的地球》- 这部短片通过震撼的画面和内容,强调了环保问题的重要性。
-https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
-            type = 0;
-            break;
-          case "不同国家的垃圾分类标准和方法?":
-            aiContent = `好的,我们来聊聊不同国家是怎么分类垃圾的。垃圾分类就像是帮助垃圾找到它们正确的家,这样我们的环境才能更干净,地球也会更健康。
-•日本:日本的垃圾分类做得非常细致。他们不仅仅是分可回收和不可回收,而是将垃圾分成很多种类,比如瓶子、罐头、纸张、塑料等等。在日本,居民需要按照当地的规定把垃圾分类好,然后放在特定的垃圾袋里,在指定的时间拿出去扔。如果分类错了,垃圾收集者可能不会带走垃圾哦。
-•德国:德国也非常重视垃圾分类。他们有一种叫做“绿点”的系统,很多包装上都有一个绿色的点。这意味着制造商已经支付了回收费用。德国人会把纸、塑料、玻璃和金属分开收集。他们甚至有专门的容器来收集旧衣服和鞋子。
-•美国:美国的垃圾分类方法比较简单,通常分为可回收物、有机物和其他垃圾。可回收物包括纸张、塑料、玻璃和金属等。有些城市还有专门的食物垃圾桶,用来收集厨余垃圾,这些可以被转化为肥料或者生产能源。
-•瑞典:瑞典几乎可以回收利用所有的垃圾。他们非常擅长把垃圾变成资源,比如将燃烧垃圾产生的热能用来供暖和供电。瑞典人也会把垃圾分类成多种类,确保每种垃圾都能找到最合适的处理方式。
-通过这些例子,我们可以看到,虽然不同国家的垃圾分类方法和标准不一样,但他们都有一个共同的目标,那就是保护我们的环境,让地球变得更美好。所以,我们每个人在日常生活中也要努力做好垃圾分类,为保护地球出一份力!`;
-            type = 0;
-            break;
-          case "可回收垃圾的处理流程和再利用方法?":
-            aiContent = `好的,我们来聊聊可回收垃圾的处理流程和再利用方法,就像是给垃圾进行一次神奇的变身之旅。
-首先,可回收垃圾是指那些可以被再次利用的垃圾,比如塑料瓶、纸张、玻璃瓶和金属罐头盒等。这些垃圾如果被正确处理,就可以变成新的东西,而不是被扔掉占用地球的空间。
-第一步:收集和分类
-想象一下,你在家里帮忙把不同的垃圾放在不同的垃圾桶里。比如,把塑料瓶放在一个桶里,把纸张放在另一个桶里。这样做的目的是为了让垃圾更容易被处理和回收。在学校或者社区,也有专门的垃圾桶来收集这些可回收的材料。
-第二步:运输
-收集好的可回收垃圾会被送到一个特别的地方,叫做回收中心。在那里,工人会再次检查垃圾,确保每样东西都放对了地方,并且是干净的。
-第三步:清洗和处理
-在回收中心,可回收的物品会被清洗干净,比如塑料瓶和玻璃瓶会被洗掉上面的污渍和标签。然后,这些物品会根据材料的类型被切割、压扁或者磨碎,准备变成新的东西。
-第四步:再制造
-这些被处理过的材料,比如碎纸或者塑料颗粒,会被送到不同的工厂,变成新的产品。例如,旧报纸可以被制成新的纸张或者纸板,塑料瓶可以变成塑料椅子或者玩具,玻璃瓶可以熔化后再制成新的玻璃制品。
-第五步:重新使用
-最后,这些新制成的物品会被送到商店,人们可以再次购买使用。这样一来,我们就完成了一次“垃圾变宝贝”的神奇旅程。
-通过这个流程,我们不仅节省了资源,减少了垃圾,还帮助保护了我们的环境。所以,下次当你要扔东西时,记得先想想这个东西能不能被回收,然后放到正确的垃圾桶里哦!这样你也成为了保护地球的小小英雄!`;
-            type = 0;
-            break;
-          case "有害垃圾对环境和人体健康的潜在影响?":
-            type = 0;
-            break;
-        }
-
-        if (this.imageCheck) {
-          aiContent = [
-            "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8721713253471000.png",
-            "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8731713253488299.png",
-            "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8741713253506303.png",
-            "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8751713253523152.png"
-          ];
-          type = 1;
-          this.chatList[this.chatList.length - 1].content = aiContent;
-          this.chatList[this.chatList.length - 1].type = type;
-          this.chatList[
-            this.chatList.length - 1
-          ].time = new Date().toLocaleString().replace(/\//gi, "-");
-          // this.chatList.push({
-          // 	role:"ai",
-          // 	content:aiContent,
-          // 	type:type,
-          // 	time:new Date().toLocaleString().replace(/\//ig,'-')
-          // })
-        }
-        if (this.videoCheck) {
-          aiContent = `当然,以下是关于垃圾处理的一些B站视频链接:
-							1.【科普短视频】垃圾会被怎么处理? - 这个视频通过简短的内容向观众展示垃圾处理的过程。
-							https://www.bilibili.com/video/BV1UD4y1U71a
-
-							2.垃圾分类,就是这么简单- 这个视频以科普的形式,向观众介绍了垃圾分类的基本知识。
-							https://www.bilibili.com/video/BV1bt41157wH 
-
-							3.【环保短片】震撼环保公益短片《致我们的地球》- 这部短片通过震撼的画面和内容,强调了环保问题的重要性。
-							https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
-          type = 0;
-          this.chatList[this.chatList.length - 1].content = aiContent;
-          this.chatList[this.chatList.length - 1].type = type;
-          this.chatList[
-            this.chatList.length - 1
-          ].time = new Date().toLocaleString().replace(/\//gi, "-");
-          // this.chatList.push({
-          // 	role:"ai",
-          // 	content:aiContent,
-          // 	type:type,
-          // 	time:new Date().toLocaleString().replace(/\//ig,'-')
-          // })
+      this.scrollBottom();
+			if(_text.indexOf("视频")!=-1){
+				_msg = `
+					ATTENTION: Use '##' or '####'  to SPLIT SECTIONS, not '#'.Output format carefully referenced "Format example".
+
+					---
+					## 任务
+					你的任务是根据用户的请求,结合“课程信息”,在https://www.bilibili.com/ 等教育网站上搜索相关视频,并且按照“输出格式”将结果输出给用户。
+					### 课程信息(读取【课程中心】相关信息)
+					#### 课程标题:${this.courseDetail.title}
+					#### 分类:${this.courseDetail.name?this.courseDetail.name:"无"}
+					#### 学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+					#### 课程其他内容(【课程中心】-【导出信息】的内容)
+					#### 课程实时语音转录文本的结果(未来支持,目前无视)
+					---
+					## 规则
+					- 输出结果必须真实有效,不要捏造无效的视频链接
+					- 如果没有相关内容,请跟用户表明没有找到相关主题内容,然后推荐近似内容
+					---
+					## 输出
+					- 在ted.com等教育网站上搜索视频,并且以有序列表的形式将结果输出给用户
+					- 请一步步思考如何根据现有信息推送视频,但是最终输出结果不需要包含你的思考过程,只需要包含视频标题+链接。
+					---
+					## 输出格式
+					视频标题 + 视频链接
+					---
+
+				`
+			}
+			// else if(_text.indexOf('图片')!=-1){
+			// 	_msg = `
+			// 		ATTENTION: Use '##' or '####'  to SPLIT SECTIONS, not '#'.Output format carefully referenced "Format example".
+				
+			// 		---
+			// 		## 任务
+			// 		你的任务是根据用户的请求,结合“课程信息”,搜索4张图片,将搜索结果以2*2的排列格式返回给用户。
+			// 		### 课程信息(读取【课程中心】相关信息)
+			// 		#### 课程标题:${this.courseDetail.title}
+			// 		#### 分类:${this.courseDetail.name?this.courseDetail.name:"无"}
+			// 		#### 学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+			// 		#### 课程其他内容(【课程中心】-【导出信息】的内容)
+			// 		#### 课程实时语音转录文本的结果(未来支持,目前无视)
+			// 		---
+			// 		## 规则
+			// 		- 输出结果基于“课程信息”,避免提供与“课程信息”无关的图片。
+			// 		- 当你判断用户的请求与“课程信息”不相关时,你需要向用户解释他的请求与“课程信息”无关。
+			// 		- 如果用户坚持生成跟“课程信息”无关的图片时,你只需要按照用户的请求搜索1张图片。
+			// 		---
+			// 		## 输出
+			// 		- 搜索4张图片,将搜索结果以2*2的排列格式输出给用户
+			// 		- 请一步步思考如何根据现有信息推送图片,但是不需要输出图片以外的内容。
+			// 		-----
+			// 	`
+			// }
+			let history = [];
+			if(_msg){
+				history.push({ role: "user", content: _msg })
+			}
+			history.push({ role: "user", content: _text })
+      let params = {
+        model: "gpt-3.5-turbo",
+        temperature: 0,
+        max_tokens: 4096,
+        top_p: 1,
+        frequency_penalty: 0,
+        presence_penalty: 0,
+        messages: history,
+        uid: _uuid,
+        mind_map_question: ""
+      };
+      this.text = "";
+
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/chat", params)
+        .then(res => {
+          if (res.data.FunctionResponse.result == "发送成功") {
+          } else {
+            this.$message.warning(res.data.FunctionResponse.result);
+            this.chatLoading = false;
+          }
+        })
+        .catch(e => {
+          console.log(e);
+          this.chatLoading = false;
+        });
+      this.getAiContent(_uuid);
+    },
+    // 获取ai对话
+    getAiContent(_uid) {
+      let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
+      let _allText = "";
+      let _mdText = "";
+      const md = new MarkdownIt();
+      _source.onmessage = _e => {
+        if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
+          //对话已经完成
+          _mdText = _mdText.replace("_", "");
+          _source.close();
+          this.chatLoading = false;
+          this.scrollBottom();
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).isalltext = true;
+          this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          // 这里保存对话
+          this.insertChat(_uid);
+          return;
+        } else {
+          //对话还在继续
+          let _text = "";
+          _text = _e.data.replaceAll("'", "");
+          if (_allText == "") {
+            _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
+          } else {
+            _allText += _text;
+          }
+          _mdText = _allText + "_";
+          _mdText = _mdText.replace(/\\n/g, "\n");
+          _mdText = _mdText.replace(/\\/g, "");
+          if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
+          //转化返回的回复流数据
+          _mdText = md.render(_mdText);
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          this.scrollBottom();
+
+          // 处理流数据
         }
-        if (!this.imageCheck && !this.videoCheck) {
-					this.chatList[this.chatList.length-1].content = aiContent;
-					this.chatList[this.chatList.length-1].type = type;
-					this.chatList[this.chatList.length-1].time = new Date().toLocaleString().replace(/\//ig,'-');
-					this.text = "";
-          // this.chatList.push({
-          //   role: "ai",
-          //   content: aiContent,
-          //   type: type,
-          //   time: new Date().toLocaleString().replace(/\//gi, "-")
-          // });
+      };
+    },
+    getWAntSearchContent(_uid) {
+      let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
+      let _allText = "";
+      let _mdText = "";
+      this.scrollBottom();
+      _source.onmessage = _e => {
+        if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
+          //对话已经完成
+          _mdText = _mdText.replace("_", "");
+          _mdText = _mdText.replace("```json", "");
+          _mdText = _mdText.replace("```", "");
+          _source.close();
+          this.chatLoading = false;
+          this.chatList.find(i => i.uid == _uid).aiContent = JSON.parse(
+            _mdText
+          );
+          this.chatList.find(i => i.uid == _uid).isalltext = true;
+          this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          this.scrollBottom();
+          // 这里保存对话
+          return;
+        } else {
+          //对话还在继续
+          let _text = "";
+          _text = _e.data.replaceAll("'", "");
+          if (_allText == "") {
+            _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
+          } else {
+            _allText += _text;
+          }
+          _mdText = _allText + "_";
+          _mdText = _mdText.replace(/\\n/g, "\n");
+          _mdText = _mdText.replace(/\\/g, "");
+          if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
+          //转化返回的回复流数据
+          this.scrollBottom();
         }
-        this.$nextTick(() => {
-          this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-        });
-        this.loading = false;
-      }, 5000);
-      // this.chatList.push({
-      // 	role:"user",
-      // 	content:this.text,
-      // 	time:"2023-11-11 11:10:11"
-      // },{
-      // 	role:"ai",
-      // 	content:`小朋友,你真棒!`,//这里需要调用接口
-      // 	time:"2023-11-11 11:10:11"
-      // })
-      // this.text = "";
-      // // 元素滚动条触底
-      // this.$nextTick(() => {
-      //   this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-      // });
+      };
+    },
+    //保存消息
+    insertChat(_uid) {
+      let _data = this.chatList.find(i => i.uid == _uid);
+      if (!_data) return;
+      let params = {
+        userId: this.userid,
+        userName: "qgt",
+        groupId: "602def61-005d-11ee-91d8-005056b8q12w",
+        answer: _data.aiContent,
+        problem: _data.content,
+        file_id: _data.fileid ? _data.fileid : "",
+        alltext: _data.aiContent,
+        type: "chat",
+        filename: _data.filename,
+        session_name: `${this.courseId}-studyStudent` //这是对话记录位置
+      };
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/insert_chat", params)
+        .then(res => {});
+    },
+    // 获取对应的聊天记录
+    getChatList() {
+      return new Promise((resolve, reject) => {
+        if (this.loading) return this.$message.info("请稍等...");
+        this.chatList = [];
+        this.loading = true;
+        let params = {
+          userid: this.userid,
+          groupid: "602def61-005d-11ee-91d8-005056b8q12w",
+          // session_name:``
+          session_name: `${this.courseId}-studyStudent`
+        };
+        this.ajax
+          .post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
+          .then(res => {
+            let _data = JSON.parse(res.data.FunctionResponse);
+            if (_data.length > 0) {
+              let _chatList = [];
+              for (let i = 0; i < _data.length; i++) {
+                _chatList.push({
+                  loading: false,
+                  role: "user",
+                  content: _data[i].problem,
+                  uid: _data[i].id,
+                  AI: "AI",
+                  aiContent: _data[i].answer,
+                  oldContent: _data[i].answer,
+                  isShowSynchronization: false,
+                  filename: _data[i].filename,
+                  index: i,
+                  is_mind_map: false,
+                  fileid: _data[i].fileid
+                });
+              }
+              this.chatList = _chatList;
+              this.loading = false;
+            } else {
+              //没有对话记录
+              this.loading = false;
+            }
+            resolve();
+          })
+          .catch(err => {
+            console.log(err);
+            this.$message.error("获取对话记录失败");
+            this.loading = false;
+            resolve();
+          });
+      });
     },
     sendAiIdea(text) {
-			if (this.loading) return this.$message.info("请稍等");
-      this.text = text;
-      this.send();
+      if (this.loading) return this.$message.info("请稍等");
+      this.send(text);
     },
     sendImage() {
       this.$message.info("发送图片");
     },
     sendVideo() {
       this.$message.info("发送视频");
+    },
+    getWantSearch() {
+      this.chatLoading = true;
+      let _uuid = uuidv4();
+
+      let _msg = `
+			ATTENTION: Use '##' or '####'  to SPLIT SECTIONS, not '#'.Output format carefully referenced "Format example".
+
+			## 任务
+			你的任务是根据“课程信息”,提供用户需要的搜索建议,将搜索建议的结果以有序列表的形式返回给用户。
+			## 课程信息
+			#### 课程标题:${this.courseDetail.title}
+			#### 分类:${this.courseDetail.name?this.courseDetail.name:"无"}
+			#### 学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+			---
+
+			## 规则
+			- 输出结果基于“课程信息”,避免提供无关的信息。
+			- 搜索建议的结果符合伦理规范。
+			---
+
+			## 输出
+			- 输出应包括3个相关的搜索建议,每个搜索建议需要以问号的方式结束。
+			- 请一步步思考如何根据现有信息推送搜索建议,但是不需要输出搜索建议以外的内容。
+
+			---
+			## 输出格式
+			搜索建议应以有序列表形式呈现,每个建议包括关键词和简短描述。输出JSON格式的数组
+
+			---
+      ## Format example
+      [{
+          "index": 1,
+          "title": "垃圾分类标准",
+          "label": "不同国家的垃圾分类标准和方法?"
+        },
+        {
+          "index": 2,
+          "title": "可回收垃圾处理",
+          "label": "可回收垃圾的处理流程和再利用方法?"
+        },
+        {
+          "index": 3,
+          "title": "有害垃圾的影响",
+          "label": "有害垃圾对环境和人体健康的潜在影响?"
+        }]
+			`;
+      this.chatList.push({
+        role: "user",
+        content: `wanSearch`,
+        uid: _uuid,
+        AI: "AI",
+        aiContent: "",
+        oldContent: "",
+        isShowSynchronization: false,
+        filename: "",
+        index: this.chatList.length,
+        is_mind_map: false,
+        loading: true
+      });
+      this.scrollBottom();
+
+      let params = {
+        model: "gpt-3.5-turbo",
+        temperature: 0,
+        max_tokens: 4096,
+        top_p: 1,
+        frequency_penalty: 0,
+        presence_penalty: 0,
+        messages: [{ role: "user", content: _msg }],
+        uid: _uuid,
+        mind_map_question: ""
+      };
+      this.text = "";
+
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/chat", params)
+        .then(res => {
+          if (res.data.FunctionResponse.result == "发送成功") {
+          } else {
+            this.chatLoading = false;
+            this.$message.warning(res.data.FunctionResponse.result);
+          }
+        })
+        .catch(e => {
+          this.chatLoading = false;
+          console.log(e);
+        });
+      this.getWAntSearchContent(_uuid);
+    },
+    scrollBottom() {
+      this.$nextTick(() => {
+        this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
+      });
     }
+  },
+  mounted() {
+    this.getChatList().then(_ => {
+      this.scrollBottom();
+      this.getWantSearch();
+    });
   }
 };
 </script>
@@ -364,7 +567,7 @@ https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
   height: 100%;
   box-sizing: border-box;
 }
-.imgNumberBlock{
+.imgNumberBlock {
   width: 100%;
   height: 30px;
   display: flex;
@@ -375,9 +578,9 @@ https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
 .imgNumberBlock > .imgNumber {
   width: 18%;
   height: 30px;
-  white-space:initial;
+  white-space: initial;
   background: rgba(224, 234, 251, 1);
-  border-radius: 5px; 
+  border-radius: 5px;
   display: flex;
   align-items: center;
   cursor: pointer;
@@ -397,6 +600,7 @@ https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
   display: flex;
   box-sizing: border-box;
   padding: 10px;
+  flex-direction: column;
 }
 
 .s_t_chat > div {
@@ -484,13 +688,14 @@ https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
   box-sizing: border-box;
   padding-right: 35px;
   position: relative;
+  margin-top: 10px;
 }
 
-.aiCopy{
+.aiCopy {
   position: absolute;
   right: 5px;
   bottom: 0%;
-  transform: translate(0,-30%);
+  transform: translate(0, -30%);
   cursor: pointer;
 }
 
@@ -624,7 +829,7 @@ https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
   display: flex;
   justify-content: space-between;
   align-items: center;
-	padding-right: 10px;
+  padding-right: 10px;
 }
 
 .s_b_tape {
@@ -650,8 +855,8 @@ https://www.bilibili.com/video/BV1ZD4y1U7H7/ `;
 
 .s_b_i_left {
   width: 100%;
-	line-height: 45px;
-	height: 100%;
+  line-height: 45px;
+  height: 100%;
 }
 
 .s_b_i_left >>> .el-input__inner {

+ 825 - 596
src/components/classRoomHelper/component/taskArea.vue

@@ -1,666 +1,895 @@
 <template>
-	<div class="task">
-		<div class="taskTop">
-			<div class="tt_title">任务时间分配</div>
-			<div class="tt_item">
-				<div class="tt_i_title">
-					<span>课程时间轴</span>
-				</div>
-				<div class="tt_i_box">
-					<img :src="require('../../../assets/icon/course/group.png')">
-				</div>
-			</div>
-
-			<div class="tt_item">
-				<div class="tt_i_title">
-					<span>任务状态</span>
-					<span>学生活动中...</span>
-				</div>
-				<div class="tt_i_box">
-					<div class="tt_i_b_item">
-						<div class="tt_i_b_title">作业提交</div>
-						<div class="tt_i_b_box">
-							<div class="tt_i_b_b_item">
-								<div>提交人数</div>
-								<span>34<span>人</span></span>
-							</div>
-							<div class="tt_i_b_b_item">
-								<div>正确率</div>
-								<span>88<span>%</span></span>
-							</div>
-						</div>
-					</div>
-					<div class="tt_i_b_item">
-						<div class="tt_i_b_title">交流互动</div>
-						<div class="tt_i_b_box">
-							<div class="tt_i_b_b_item">
-								<div>参与人数</div>
-								<span>56<span>人</span></span>
-							</div>
-							<div class="tt_i_b_b_item">
-								<div>点赞数</div>
-								<span>36<span>个</span></span>
-							</div>
-							<div class="tt_i_b_b_item">
-								<div>评论数</div>
-								<span>128<span>条</span></span>
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-		</div>
-		<div class="t_top" ref="chatRef">
-			<div class="t_t_chat" v-for="(item,index) in chatList" :key="index">
-				<div class="t_t_c_user" v-if="item.role =='user'">
-					<div class="t_t_c_u_left">
-						<div class="t_t_c_u_l_content">{{item.content}}</div>
-						<div class="t_t_c_u_l_time">{{item.time}}</div>
-					</div>
-					<div class="t_t_c_u_right">
-						<span>我</span>
-					</div>
-				</div>
-				<div class="t_t_c_ai" v-if="item.role =='ai'">
-					<div class="t_t_c_a_left">
-						<span>Ai</span>
-					</div>
-					<div class="t_t_c_a_right">
-						<div class="t_t_c_a_r_content" v-loading="loading && index == chatList.length - 1" v-html="item.content"></div>
-						<div class="t_t_c_a_r_time">{{item.time}}</div>
-					</div>
-					
-				</div>
-			</div>
-			
-		</div>
-		<div class="t_bottom">
-			<div class="t_b_btnArea">
-				<!-- <div class="s_b_ba-item" @click.stop="choiceRole()">选择角色</div> -->
-				<div class="t_b_ba_item" @click="sendType('智能总结')">智能总结</div>
-				<div class="t_b_ba_item" @click="sendType('智能出题')">智能出题</div>
-				<!-- <div class="t_b_ba_item" @click="sendType('优秀标兵')">优秀标兵</div> -->
-				<div class="t_b_ba_item" @click="sendType('扩展知识')">扩展知识</div>
-			</div>
-			<div class="t_b_inputArea">
-				<!-- <div class="t_b_tape" @click="goTape()"></div> -->
-				<div class="t_b_input">
-					<el-input :disabled="loading" @keyup.enter.native="send()" class="t_b_i_left" v-model="text"></el-input>
-					<!-- <div class="t_b_i_right" @click="sendFile()">
+  <div class="task">
+    <div class="taskTop">
+      <div class="tt_title">任务时间分配</div>
+      <div class="tt_item">
+        <div class="tt_i_title">
+          <span>课程时间轴</span>
+        </div>
+        <div class="tt_i_box">
+          <img :src="require('../../../assets/icon/course/group.png')" />
+        </div>
+      </div>
+
+      <div class="tt_item">
+        <div class="tt_i_title">
+          <span>任务状态</span>
+          <span>学生活动中...</span>
+        </div>
+        <div class="tt_i_box">
+          <div class="tt_i_b_item">
+            <div class="tt_i_b_title">作业提交</div>
+            <div class="tt_i_b_box">
+              <div class="tt_i_b_b_item">
+                <div>提交人数</div>
+                <span>34<span>人</span></span>
+              </div>
+              <div class="tt_i_b_b_item">
+                <div>正确率</div>
+                <span>88<span>%</span></span>
+              </div>
+            </div>
+          </div>
+          <div class="tt_i_b_item">
+            <div class="tt_i_b_title">交流互动</div>
+            <div class="tt_i_b_box">
+              <div class="tt_i_b_b_item">
+                <div>参与人数</div>
+                <span>56<span>人</span></span>
+              </div>
+              <div class="tt_i_b_b_item">
+                <div>点赞数</div>
+                <span>36<span>个</span></span>
+              </div>
+              <div class="tt_i_b_b_item">
+                <div>评论数</div>
+                <span>128<span>条</span></span>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="t_top" ref="chatRef">
+      <div class="t_t_chat" v-for="(item, index) in chatList" :key="index">
+        <div class="t_t_c_user" v-if="item.content">
+          <div class="t_t_c_u_left">
+            <div class="t_t_c_u_l_content">{{ item.content }}</div>
+            <div class="t_t_c_u_l_time">{{ item.createtime }}</div>
+          </div>
+          <div class="t_t_c_u_right">
+            <span>我</span>
+          </div>
+        </div>
+        <div class="t_t_c_ai">
+          <div class="t_t_c_a_left">
+						<el-avatar v-if="item.filename" :src="item.filename"></el-avatar>
+              <span v-else>Ai</span>
+          </div>
+          <div class="t_t_c_a_right">
+            <div
+              class="t_t_c_a_r_content"
+              v-loading="item.loading"
+              v-html="item.aiContent"
+            ></div>
+            <div class="t_t_c_a_r_time">{{ item.createtime }}</div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="t_bottom">
+      <div class="t_b_btnArea">
+        <!-- <div class="s_b_ba-item" @click.stop="choiceRole()">选择角色</div> -->
+        <div class="t_b_ba_item" @click="sendType('智能总结')">智能总结</div>
+        <div class="t_b_ba_item" @click="sendType('智能出题')">智能出题</div>
+        <!-- <div class="t_b_ba_item" @click="sendType('优秀标兵')">优秀标兵</div> -->
+        <div class="t_b_ba_item" @click="sendType('扩展知识')">扩展知识</div>
+      </div>
+      <div class="t_b_inputArea">
+        <!-- <div class="t_b_tape" @click="goTape()"></div> -->
+        <div class="t_b_input">
+          <el-input
+            :disabled="loading || chatLoading"
+            v-loading="loading || chatLoading"
+            @keyup.enter.native="send()"
+            class="t_b_i_left"
+            v-model="text"
+          ></el-input>
+          <!-- <div class="t_b_i_right" @click="sendFile()">
 						<span></span>
 					</div> -->
-				</div>
-				<div class="t_b_btn" @click="send()">
-					<span></span>
-				</div>
-			</div>
-		</div>
-	</div>
+        </div>
+        <div class="t_b_btn" @click="send()">
+          <span></span>
+        </div>
+      </div>
+    </div>
+  </div>
 </template>
 
 <script>
 // import { Loading } from 'element-ui';
-
-	export default {
-		data(){
-			return{
-				text:"",
-				loading:false,
-				chatList:[
-				{
-						role:"ai",
-						content:`您好,有什么可以帮助您的吗?`,
-						time:new Date().toLocaleString().replace(/\//ig,'-')
-					},
-// 					{
-// 						role:"user",
-// 						content:"正十三边形的每个角是多少度?",
-// 						time:"2023-11-11 11:10:11"
-// 					},
-// 					{
-// 						role:"ai",
-// 						content:`小朋友们,你们知道正十三边形吗?就像我们班有13个好朋友站成一个圈圈一样。如果我们想知道每个人转身看向下一个人需要转多少度,我们可以这样想:首先,所有朋友手拉手围成的圈圈是360度,对吧?但是,我们不能直接算每个人转身的角度,因为那是外面的角度,我们要算里面的角度,就像每个人转身时脚尖指向圈心的角度。
-// 我们先用一个小技巧,算出所有内角加起来是多少度。方法是:(13-2)乘以180度,得到1980度。这是因为,想象成一个多边形,它可以分成11个三角形,每个三角形的角度和是180度。
-// 然后,我们把1980度平分给13个角,就是每个角的度数了。算一算,1980除以13等于152度。所以,正十三边形的每个角是152度。就像每个人转身看下一个朋友,每个人需要转152度一样。`,
-// 						time:"2023-11-11 11:10:11"
-// 					},
-				],
-			}
-		},
-		methods: {
-			choiceRole(){
-				this.cardType = 1;
-			},
-			sendFile(){
-				if (this.loading) return this.$message.info("请稍等");
-				this.$message.info("点击了附件")
-			},
-			goTape(){
-				if (this.loading) return this.$message.info("请稍等");
-				this.$message.info(`点击了语音`)
-			},
-			send(){
-				if (this.loading) return this.$message.info("请稍等");
-				if(this.text.trim().length==0)return this.$message.info("请输入内容")
-				this.loading = true;
-				this.chatList.push({
-					role:"user",
-					content:this.text,
-					time:new Date().toLocaleString().replace(/\//ig,'-')
-				})
-				
-				this.chatList.push({
-					role:"ai",
-					content:"",
-					time:new Date().toLocaleString().replace(/\//ig,'-')
-				})
-				this.$nextTick(() => {
-				  this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-				});;
-				setTimeout(()=>{
+import { v4 as uuidv4 } from "uuid";
+import MarkdownIt from "markdown-it";
+export default {
+  props: {
+    courseDetail: {
+      type: Object,
+      default: () => {}
+    }
+  },
+  data() {
+    return {
+      userid: this.$route.query.userid,
+      courseId: this.$route.query.courseId,
+      text: "",
+      loading: false,
+      chatLoading: false,
+      chatList: []
+    };
+  },
+  methods: {
+    // 获取ai对话
+    getAiContent(_uid) {
+      let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
+      let _allText = "";
+      let _mdText = "";
+      const md = new MarkdownIt();
+      _source.onmessage = _e => {
+        if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
+          //对话已经完成
+          _mdText = _mdText.replace("_", "");
+          _source.close();
+          this.chatLoading = false;
+          this.scrollBottom();
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).isalltext = true;
+          this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          // 这里保存对话
+          this.insertChat(_uid);
+          return;
+        } else {
+          //对话还在继续
+          let _text = "";
+          _text = _e.data.replaceAll("'", "");
+          if (_allText == "") {
+            _allText = _text.replace(/^\n+/, ""); //去掉回复消息中偶尔开头就存在的连续换行符
+          } else {
+            _allText += _text;
+          }
+          _mdText = _allText + "_";
+          _mdText = _mdText.replace(/\\n/g, "\n");
+          _mdText = _mdText.replace(/\\/g, "");
+          if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
+          //转化返回的回复流数据
+          _mdText = md.render(_mdText);
+          this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
+          this.chatList.find(i => i.uid == _uid).loading = false;
+          this.scrollBottom();
+          // 处理流数据
+        }
+      };
+    },
+    //保存消息
+    insertChat(_uid) {
+      let _data = this.chatList.find(i => i.uid == _uid);
+      if (!_data) return;
+      let params = {
+        userId: this.userid,
+        userName: "qgt",
+        groupId: "602def61-005d-11ee-91d8-005056b8q12w",
+        answer: _data.aiContent,
+        problem: _data.content,
+        file_id: _data.fileid ? _data.fileid : "",
+        alltext: _data.aiContent,
+        type: "chat",
+        filename: _data.filename,
+        session_name: `${this.courseId}-studyStudent` //这是对话记录位置
+      };
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/insert_chat", params)
+        .then(res => {});
+    },
+    // 获取对应的聊天记录
+    getChatList() {
+      return new Promise((resolve, reject) => {
+        if (this.loading) return this.$message.info("请稍等...");
+        this.chatList = [];
+        this.loading = true;
+        this.chatLoading = true;
+        let params = {
+          userid: this.userid,
+          groupid: "602def61-005d-11ee-91d8-005056b8q12w",
+          // session_name:``
+          session_name: `${this.courseId}-studyStudent`
+        };
+        this.ajax
+          .post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
+          .then(res => {
+            let _data = JSON.parse(res.data.FunctionResponse);
+            if (_data.length > 0) {
+              let _chatList = [];
+              for (let i = 0; i < _data.length; i++) {
+                _chatList.push({
+                  loading: false,
+                  role: "user",
+                  content: _data[i].problem,
+                  uid: _data[i].id,
+                  AI: "AI",
+                  aiContent: _data[i].answer,
+                  oldContent: _data[i].answer,
+                  isShowSynchronization: false,
+                  filename: _data[i].filename,
+                  index: i,
+                  is_mind_map: false,
+                  fileid: _data[i].fileid
+                });
+              }
+              this.chatList = _chatList;
+              this.loading = false;
+              this.chatLoading = false;
+            } else {
+              //没有对话记录
+              this.loading = false;
+              this.chatLoading = false;
+            }
+            resolve();
+          })
+          .catch(err => {
+            console.log(err);
+            this.$message.error("获取对话记录失败");
+            this.loading = false;
+            this.chatLoading = false;
+            resolve();
+          });
+      });
+    },
+    choiceRole() {
+      this.cardType = 1;
+    },
+    sendFile() {
+      if (this.loading) return this.$message.info("请稍等");
+      this.$message.info("点击了附件");
+    },
+    goTape() {
+      if (this.loading) return this.$message.info("请稍等");
+      this.$message.info(`点击了语音`);
+    },
+    send(_text = this.text) {
+      if (this.loading || this.chatLoading) return this.$message.info("请稍等");
+      if (_text.trim().length == 0) return this.$message.info("请输入内容");
+      this.chatLoading = true;
+      let _uuid = uuidv4();
+      this.chatList.push({
+        role: "user",
+        content: `${_text}`,
+        uid: _uuid,
+        AI: "AI",
+        aiContent: "",
+        oldContent: "",
+        isShowSynchronization: false,
+        filename: "",
+        index: this.chatList.length,
+        is_mind_map: false,
+        loading: true
+      });
+      this.scrollBottom();
+      let params = {
+        model: "gpt-3.5-turbo",
+        temperature: 0,
+        max_tokens: 4096,
+        top_p: 1,
+        frequency_penalty: 0,
+        presence_penalty: 0,
+        messages: [{ role: "user", content: _text }],
+        uid: _uuid,
+        mind_map_question: ""
+      };
+      this.text = "";
+
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/chat", params)
+        .then(res => {
+          if (res.data.FunctionResponse.result == "发送成功") {
+          } else {
+            this.$message.warning(res.data.FunctionResponse.result);
+            this.chatLoading = false;
+          }
+        })
+        .catch(e => {
+          console.log(e);
+          this.chatLoading = false;
+        });
+      this.getAiContent(_uuid);
+    },
+    sendType(_text) {
+      if (this.loading || this.chatLoading) return this.$message.info("请稍等");
+      let _msg = ``;
+      if (_text == "扩展知识") {
+        _msg = `
+				  ATTENTION: Use '##' or '####'  to SPLIT SECTIONS, not '#'.Output format carefully referenced "Format example".
 					
-
-					let aiContent="对不起,这个问题我回答不了。"
-
-					switch(this.text){
-						case "智能总结":
-							aiContent=`在这节课上,教师和学生们围绕垃圾问题进行了深入的讨论和实践活动。截止到目前为止,课程已经教学了以下内容:
-
-1.环境调查与问题识别:学生们首先进行了实地调查,发现了大鹏新区存在的环境问题,特别是垃圾问题。学生们观察到菜市场和路边有大量垃圾堆积。
-2.垃圾产生的数据分析:教师引导学生计算家庭和学校垃圾产生的总量,并通过比喻(如成年公羊和非洲大象的重量)来形象地表达垃圾的重量,增强学生对垃圾量的直观理解。
-3.垃圾处理方法的探讨:学生们讨论了垃圾的处理方式,包括填埋、焚烧发电以及回收利用。他们探讨了这些方法的优缺点,如填埋会占用大量土地并可能污染土地和水源,焚烧则可能导致空气污染。
-4.垃圾分类的重要性:课程强调了垃圾分类的重要性,并通过实际分类活动让学生们理解不同垃圾的处理方式。学生们学习了如何将垃圾分为可回收垃圾、厨余垃圾、有害垃圾和其他垃圾,并探讨了各类垃圾的具体处理方法。
-5.实际行动的倡议:教师鼓励学生从减少一次性用品的使用开始,采取实际行动来减少垃圾产生。学生们提出了多种减少和重新利用垃圾的创意方法,如将剩饭剩菜喂给小动物或制作成堆肥。
-
-总结来说,这节课通过实地调查、数据分析和小组讨论等多种教学方法,有效地提高了学生们对环境保护和垃圾处理问题的认识和参与度。学生们通过实际操作和讨论,学习了垃圾分类的技能,并对垃圾处理的各种方法有了深入的了解和评价。`
-						break;
-						case "智能出题":
-							aiContent = `选择题:下列哪一项应该被归类为可回收物?
-A. 废弃的塑料袋
-B. 污染严重的厨房纸巾
-C. 破碎的玻璃杯
-D. 废旧的电池`
-							break;
-						case "优秀标兵":
-							aiContent = `这节课的学习数据如下:
-
-							<img src='https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/%E5%9B%BE%E7%89%8711713252928457.png' style="max-width:100%">
-1.陈小春:陈小春同学的作业完成率接近完美,考试成绩也非常优秀,课堂参与度非常积极,项目贡献被评为优秀。综合各方面表现,陈小春在学习上非常突出,是一个全面发展的学生。
-2.李雷:李雷同学的作业完成率较高,考试成绩良好,课堂参与度积极,项目贡献优秀。李雷在学习成绩和课堂表现上表现突出,是一个学习能力强的学生。
-3.林婷婷:虽然林婷婷同学的作业完成率略低于陈小春和李雷,但考试成绩与李雷持平,且课堂参与度积极,项目贡献良好。林婷婷在学习成绩上表现稳定,是一个有潜力的学生。`;
-							break;
-						case "扩展知识":
-							aiContent = `在这节关于解决垃圾问题的科学课上,学生们已经通过实际的调查和计算,以及对垃圾分类和处理方法的讨论,获得了很多实用的知识。为了进一步扩展这些知识,以下是一些可以在课堂上引入的相关主题和活动:
-
-1.全球垃圾处理策略对比:
-a.研究并讨论不同国家如何处理垃圾,例如德国、日本和瑞士的垃圾分类和处理系统。这可以帮助学生了解不同文化和政策环境下的环保策略。
-b.学生可以制作海报或演示文稿,展示每个国家的垃圾处理方法,并讨论其优缺点。
-2.垃圾减量的科技创新:
-a.探索和讨论新技术如何帮助减少垃圾产生,例如生物降解材料、可回收包装设计等。
-b.邀请一个环保技术公司的代表来讲述他们如何通过创新技术来处理或减少垃圾。
-3.实地考察:
-a.组织一次学校附近的垃圾处理设施或回收中心的参观。让学生亲眼看到垃圾是如何被分类、处理和回收的。 
-b.在参观后,学生可以讨论他们的观察结果,以及这些设施如何影响社区和环境。
-4.环保项目设计:
-a.鼓励学生设计自己的环保项目,如校园内的垃圾分类宣传、制作可持续材料的手工艺品等。
-b.这些项目可以在学校的科学展览会上展出,或者在校园网站上分享。
-5.家庭和社区的环保行动:
-a.让学生调查并记录他们家庭一周内的垃圾产生和处理情况,然后讨论如何改进。 
-b.学生可以创建一个“绿色挑战”活动,鼓励家庭成员减少垃圾产生,如使用可重复使用的购物袋、减少一次性产品使用等。
-
-通过这些扩展活动,学生不仅能够加深对垃圾问题的理解,还能学习到如何在日常生活中实际应用这些知识,从而更有效地保护我们的环境。`;
-							break;
-					}
-					this.chatList[this.chatList.length - 1].content = aiContent;
-          this.chatList[
-            this.chatList.length - 1
-          ].time = new Date().toLocaleString().replace(/\//gi, "-");
-					// this.chatList.push({
-					// 	role:"ai",
-					// 	content:aiContent,
-					// 	time:new Date().toLocaleString().replace(/\//ig,'-')
-					// })
-					this.text = "";
-					this.$nextTick(() => {
-					  this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-					});;
-					this.loading = false;
-				},5000)
-				// this.chatList.push({
-				// 	role:"user",
-				// 	content:this.text,
-				// 	time:"2023-11-11 11:10:11"
-				// },{
-				// 	role:"ai",
-				// 	content:`小朋友,你真棒!`,//这里需要调用接口
-				// 	time:"2023-11-11 11:10:11"
-				// })
-				// this.text = "";
-				// // 元素滚动条触底
-				// this.$nextTick(() => {
-				//   this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
-				// });;
-			},
-			sendType(text){
-				
-				if (this.loading) return this.$message.info("请稍等");
-				this.text = text;
-				this.send();
-			},
-			sendImage(){
-				this.$message.info("发送图片")
-			},
-			sendVideo(){
-				this.$message.info("发送视频")
-			},
-		},
-	}
+					---
+					## 任务
+					你的任务是根据用户的请求,结合“课程信息”,向用户推荐相关的知识点,将结果以有序列表的形式返回给用户。
+					## 课程信息(读取【课程中心】相关信息)
+					#### 课程标题:${this.courseDetail.title}
+					#### 分类:${this.courseDetail.name?this.courseDetail.name:"无"}
+					#### 学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+
+					---
+					## 规则
+					- 输出结果基于“课程信息”,避免提供无关的信息。
+					- 搜索建议的结果符合伦理规范。
+
+					---
+					## 输出
+					- 输出应包括3个相关的扩展知识点。
+					- 请一步步思考如何根据现有信息推送扩展知识点,但是不需要输出扩展知识以外的内容。
+
+					---
+					## 输出内容
+					搜索建议应以有序列表形式呈现,每个建议包括关键词和简短描述。
+
+					---
+					## Format example
+					世界奇观众多,数不胜数,本文仅从5000+起步记述,按这个标准,世界第一高峰珠穆朗玛峰、第二高峰乔戈里峰、第四高峰洛子峰、第五高峰马卡鲁峰、第六高峰卓奥友峰均为刚刚及格或者未达标。他们均位于群山腹地,距离低海拔地区较远。
+					先说答案:南迦帕尔巴特,海拔8125,距离28公里处相对高度差为7081米,且可直视峰顶。注意这几个条件,因为抛开他们的话,后面会有数据上的争议。但有了这些限制条件,可以说,南迦·帕尔巴特峰几乎在所有排行榜上都是当之无愧的冠军,来看看它的数据:世界海拔第9高峰,位于喜马拉雅山脉的西端"地结"(属于巴控克什米尔地区)上,海拔8125米,被印度河深切环绕。顺着该山西北一条山脊往下,可以直达一片面积还不算很小的平地——该平地最低点的一条河仅有1044米。
+					关于麦金利山的说法,麦金利山位于美国阿拉斯加州东南部,海拔6193米,约有5500米的相对高差,不但不是高差最大的山,而且论排名,前30也很难进去。因为这个数据如果放在亚洲实在是比较普通。毕竟相对高差是建立在绝对高度的基础上的,想要相对高差突破7000+,那么你的绝对高度当然要先过这个数。而世界所有的7000+高峰,均位于亚洲的大喜马拉雅和喀喇昆仑地区。除了南迦帕尔巴特峰之外,世界第七高峰海拔8167米的道拉吉里峰和第十高峰海拔8093米的安娜普尔娜峰之间,有一条海拔仅在1050-1500米,宽约20公里的卡利甘达基谷地,这里有着12公里距离,双侧均为6900-7000米高差的恐怖纪录。卡利甘达基峡谷数据和壮观程度要超过雅鲁藏布大峡谷,实为世界第一大峡谷,只是国人为了面子问题佯作不知。
+					`;
+      } else if (_text == "智能出题") {
+        _msg = `
+				  ATTENTION: Use '##' or '####'  to SPLIT SECTIONS, not '#'.Output format carefully referenced "Format example".
+
+					---
+					## 任务
+					你的任务是根据用户的请求,结合“课程信息”,向用户推荐相关的题目,将结果以有序列表的形式返回给用户。
+					## 课程信息(读取【课程中心】相关信息)
+					#### 课程标题:${this.courseDetail.title}
+					#### 分类:${this.courseDetail.name?this.courseDetail.name:"无"}
+					#### 学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+
+					---
+					## 规则
+					- 输出结果基于“课程信息”,避免提供无关的信息。
+					- 搜索建议的结果符合伦理规范。
+
+					---
+					## 输出
+					- 输出应包括3个相关课程的题目。
+					- 请一步步思考如何根据现有信息出题,但是不需要输出相关课程以外的内容。
+
+					---
+					## 输出内容
+					搜索建议应以有序列表形式呈现,每个建议包括关键词和简短描述。
+
+					---
+					## Format example
+					题目:如果一个物体的动能是 50J,且其速度是 5 m/s,求该物体的质量。
+
+					答案:2 kg
+
+					题目:写出与 "quick" 同义的词。
+
+					答案:fast
+
+					题目:世界上最高的山是什么山。
+					A:喜马拉雅山
+					B:珠穆朗玛峰
+					C:天山
+					D:阿尔卑斯山
+
+					答案:B
+					`;
+      } else if (_text == "智能总结") {
+        _msg = `
+				  ATTENTION: Use '##' or '####'  to SPLIT SECTIONS, not '#'.Output format carefully referenced "Format example".
+
+					---
+					## 任务
+					你的任务是根据用户的请求,结合“课程信息”,向用户推荐相关的课程总结,将结果以有序列表的形式返回给用户。
+					## 课程信息(读取【课程中心】相关信息)
+					#### 课程标题:${this.courseDetail.title}
+					#### 分类:${this.courseDetail.name?this.courseDetail.name:"无"}
+					#### 学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+
+					---
+					## 规则
+					- 输出结果基于“课程信息”,避免提供无关的信息。
+					- 搜索建议的结果符合伦理规范。
+
+					---
+					## 输出
+					- 输出应对应相关课程的总结。
+					- 请一步步思考如何根据现有信息总结课程,但是不需要输出相关课程以外的内容。
+
+					---
+					## 输出内容
+					搜索建议应以有序列表形式呈现,每个建议包括关键词和简短描述。
+
+					---
+					## Format example
+					珠穆朗玛峰(中国/尼泊尔边界,海拔8848米)
+
+					世界之巅。
+
+					乔戈里峰(K2,中国/巴基斯坦边界,海拔8611米)
+
+					世界第二高峰,峰顶呈金字塔形,山势险峻异常,是国际登山界公认的8000米以上攀登难度最大的山峰。
+
+					干城章嘉峰(印度/尼泊尔边界,海拔8586米)
+
+					世界第三高峰,全球14座8000米级雪山中位置最靠东的高山,山顶呈工字形,山体巨大,靠近喜马拉雅山脉南麓,远眺壮观异常。
+
+					从70千米外海拔500-2000米的大吉岭地区远眺海拔8586米的世界第三高峰干城章嘉峰,极限高差可达8000+。
+					`;
+      }
+      if (!_msg) return;
+      this.chatLoading = true;
+      let _uuid = uuidv4();
+      this.chatList.push({
+        role: "user",
+        content: `${_text}`,
+        uid: _uuid,
+        AI: "AI",
+        aiContent: "",
+        oldContent: "",
+        isShowSynchronization: false,
+        filename: "",
+        index: this.chatList.length,
+        is_mind_map: false,
+        loading: true
+      });
+      this.scrollBottom();
+
+      let params = {
+        model: "gpt-3.5-turbo",
+        temperature: 0,
+        max_tokens: 4096,
+        top_p: 1,
+        frequency_penalty: 0,
+        presence_penalty: 0,
+        messages: [{ role: "user", content: _msg }],
+        uid: _uuid,
+        mind_map_question: ""
+      };
+      this.text = "";
+
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/chat", params)
+        .then(res => {
+          if (res.data.FunctionResponse.result == "发送成功") {
+          } else {
+            this.$message.warning(res.data.FunctionResponse.result);
+            this.chatLoading = false;
+          }
+        })
+        .catch(e => {
+          console.log(e);
+          this.chatLoading = false;
+        });
+      this.getAiContent(_uuid);
+      // this.send(text);
+    },
+    sendImage() {
+      this.$message.info("发送图片");
+    },
+    sendVideo() {
+      this.$message.info("发送视频");
+    },
+    scrollBottom() {
+      this.$nextTick(() => {
+        this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;
+      });
+    }
+  },
+  mounted() {
+    this.getChatList().then(_ => {
+      this.scrollBottom();
+    });
+  }
+};
 </script>
 
 <style scoped>
-.task{
-	width: 100%;
-	height: 100%;
-	box-sizing: border-box;
+.task {
+  width: 100%;
+  height: 100%;
+  box-sizing: border-box;
 }
 
-.taskTop{
-	width: 100%;
-	height: 280px;
-	box-sizing: border-box;
-	padding: 10px;
-	overflow-x: hidden;
+.taskTop {
+  width: 100%;
+  height: 280px;
+  box-sizing: border-box;
+  padding: 10px;
+  overflow-x: hidden;
 }
 
-.tt_title{
-	font-size: 18px;
-	font-weight: bold;
-	margin-bottom: 5px;
+.tt_title {
+  font-size: 18px;
+  font-weight: bold;
+  margin-bottom: 5px;
 }
 
-.tt_item{
-	width: 100%;
-	height: auto;
-	margin-top: 10px;
+.tt_item {
+  width: 100%;
+  height: auto;
+  margin-top: 10px;
 }
 
-.tt_i_title{
-	display: flex;
-	justify-content: space-between;
-	align-items: center;
+.tt_i_title {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
 }
 
-.tt_i_title>span:nth-of-type(2){
-	box-sizing: border-box;
-	padding: 0 10px;
-	height: 25px;
-	background-color: #EFFCF5;
-	color: #83E0AF;
+.tt_i_title > span:nth-of-type(2) {
+  box-sizing: border-box;
+  padding: 0 10px;
+  height: 25px;
+  background-color: #effcf5;
+  color: #83e0af;
 }
 
-
-.tt_i_box{
-	width: 100%;
-	height: auto;
-	display: flex;
-	margin-top: 10px;
-	justify-content: space-between;
+.tt_i_box {
+  width: 100%;
+  height: auto;
+  display: flex;
+  margin-top: 10px;
+  justify-content: space-between;
 }
 
-.tt_i_box>img{
-	width: 100%;
-	height: 50px;
+.tt_i_box > img {
+  width: 100%;
+  height: 50px;
 }
 
-
-.tt_i_b_item{
-	width: auto;
-	height: 90px;
-	background-color: #F6F9FF;
+.tt_i_b_item {
+  width: auto;
+  height: 90px;
+  background-color: #f6f9ff;
 }
 
-.tt_i_b_title{
-	width: 100%;
-	height: 30px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	box-sizing: border-box;
-	border: solid 1px #E0EAFB;
-	color: #626466;
+.tt_i_b_title {
+  width: 100%;
+  height: 30px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  box-sizing: border-box;
+  border: solid 1px #e0eafb;
+  color: #626466;
 }
 
-.tt_i_b_box{
-	width: auto;
-	height: 60px;
-	box-sizing: border-box;
-	border: solid 1px #E0EAFB;
-	border-top: none;
-	display: flex;
+.tt_i_b_box {
+  width: auto;
+  height: 60px;
+  box-sizing: border-box;
+  border: solid 1px #e0eafb;
+  border-top: none;
+  display: flex;
 }
 
-.tt_i_b_b_item{
-	width: 70px;
-	height: 100%;
-	display: flex;
-	flex-direction: column;
-	justify-content: center;
-	align-items: center;
-	border-left: solid 1px #E0EAFB;
+.tt_i_b_b_item {
+  width: 70px;
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+  border-left: solid 1px #e0eafb;
 }
 
-.tt_i_b_box>.tt_i_b_b_item:nth-of-type(1){
-	border-left:none
+.tt_i_b_box > .tt_i_b_b_item:nth-of-type(1) {
+  border-left: none;
 }
 
-.tt_i_b_b_item>div{
-	font-size: 14px;
-	color: #949599;
+.tt_i_b_b_item > div {
+  font-size: 14px;
+  color: #949599;
 }
 
-.tt_i_b_b_item>span{
-	font-weight: bold;
+.tt_i_b_b_item > span {
+  font-weight: bold;
 }
 
-.tt_i_b_b_item>span>span{
-	font-size: 12px;
-	font-weight: 200;
+.tt_i_b_b_item > span > span {
+  font-size: 12px;
+  font-weight: 200;
 }
 
-
-.t_top{
-	width: 100%;
-	height: calc(100% - 370px);
-	overflow: auto;
-	box-sizing: border-box;
-	padding: 20px 0;
+.t_top {
+  width: 100%;
+  height: calc(100% - 370px);
+  overflow: auto;
+  box-sizing: border-box;
+  padding: 20px 0;
 }
 
-.t_t_chat{
-	width: 100%;
-	display: flex;
-	box-sizing: border-box;
-	padding: 10px;
+.t_t_chat {
+  width: 100%;
+  display: flex;
+  box-sizing: border-box;
+  padding: 10px;
+  flex-direction: column;
 }
 
-.t_t_chat>div{
-	display: flex;
-	align-items: flex-start;
-	width: 100%;
+.t_t_chat > div {
+  display: flex;
+  align-items: flex-start;
+  width: 100%;
 }
 
-.t_t_c_user{
-	box-sizing: border-box;
-	padding-left: 35px;
+.t_t_c_user {
+  box-sizing: border-box;
+  padding-left: 35px;
 }
 
-.t_t_c_u_left{
-	width: 90%;
-	height: auto;
+.t_t_c_u_left {
+  width: 90%;
+  height: auto;
 }
 
-.t_t_c_u_l_content{
-	width: auto;
-	max-width: 100%;
-	height: auto;
-	box-sizing: border-box;
-	padding: 10px;
-	color: white;
-	background-color: #3681FC;
-	border-radius: 8px 2px 8px 8px;
-  white-space: pre-line
+.t_t_c_u_l_content {
+  width: auto;
+  max-width: 100%;
+  height: auto;
+  box-sizing: border-box;
+  padding: 10px;
+  color: white;
+  background-color: #3681fc;
+  border-radius: 8px 2px 8px 8px;
+  white-space: pre-line;
 }
 
-.t_t_c_u_l_time{
-	width: 100%;
-	display: flex;
-	justify-content: flex-end;
-	font-size: 12px;
-	color: #9F9F9F;
-	margin-top: 5px;
+.t_t_c_u_l_time {
+  width: 100%;
+  display: flex;
+  justify-content: flex-end;
+  font-size: 12px;
+  color: #9f9f9f;
+  margin-top: 5px;
 }
 
-.t_t_c_u_right{
-	width: 35px;
-	height: 35px;
-	display: flex;
-	justify-content: center;
-	margin-left: 5px
+.t_t_c_u_right {
+  width: 35px;
+  height: 35px;
+  display: flex;
+  justify-content: center;
+  margin-left: 5px;
 }
 
-.t_t_c_u_right>span{
-	width: 32px;
-	height: 32px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	color: white;
-	background-color: #3681FC;
-	border-radius: 50%;;
+.t_t_c_u_right > span {
+  width: 32px;
+  height: 32px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: white;
+  background-color: #3681fc;
+  border-radius: 50%;
 }
 
-.t_t_c_ai{
-	box-sizing: border-box;
-	padding-right: 35px;
+.t_t_c_ai {
+  margin-top: 10px;
+  box-sizing: border-box;
+  padding-right: 35px;
 }
 
-.t_t_c_a_right{
-	min-width: 90%;
-	height: auto;
+.t_t_c_a_right {
+  min-width: 90%;
+  height: auto;
 }
 
-.t_t_c_a_r_content{
-	width: auto;
-	max-width: 100%;
-	height: auto;
-	box-sizing: border-box;
-	padding: 10px;
-	background-color: #F6F8FF;
-	border-radius: 2px 8px 8px 8px;
+.t_t_c_a_r_content {
+  width: auto;
+  max-width: 100%;
+  height: auto;
+  box-sizing: border-box;
+  padding: 10px;
+  background-color: #f6f8ff;
+  border-radius: 2px 8px 8px 8px;
   white-space: pre-line;
-	word-break: break-all;
+  word-break: break-all;
 }
 
-.t_t_c_a_r_content2{
-	background-color: #F6F8FF;
-	width: 100%;
-	height: auto;
-	box-sizing: border-box;
-	padding: 10px;
-	border-radius: 2px 8px 8px 8px;
+.t_t_c_a_r_content2 {
+  background-color: #f6f8ff;
+  width: 100%;
+  height: auto;
+  box-sizing: border-box;
+  padding: 10px;
+  border-radius: 2px 8px 8px 8px;
   white-space: pre-line;
-	box-shadow: 0 0px 10px #c5cbee;
-}
-
-.t_t_c_a_r_c_title{
-	display: flex;
-	align-items: center;
-}
-.t_t_c_a_r_c_title>img{
-	width: 16px;
-	height: 16px;
-}
-
-.t_t_c_a_r_c_item{
-	width: 100%;
-	height: auto;
-	box-sizing: border-box;
-	padding: 10px;
-	background-color: #FFFFFF;
-	border-radius: 5px;
-	margin-top: 5px;
-	color: #666666;
-	font-size: 14px;
-	cursor: pointer;
-}
-
-.t_t_c_a_r_c_item:hover{
-	border: solid #B8D2FE 1px;
-	box-shadow: 0 0 5px 2px #B8D2FE;
-}
-
-.t_t_c_a_r_c_title>span{
-	font-weight: bold;
-}
-
-
-.t_t_c_a_r_time{
-	width: 100%;
-	display: flex;
-	justify-content: flex-start;
-	font-size: 12px;
-	color: #9F9F9F;
-	margin-top: 5px;
-}
-
-.t_t_c_a_left{
-	width: 35px;
-	height: 35px;
-	display: flex;
-	justify-content: center;
-	margin-right: 5px
-}
-
-.t_t_c_a_left>span{
-	width: 32px;
-	height: 32px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	color: white;
-	background-color: #3681FC;
-	border-radius: 50%;
-}
-
-.t_bottom{
-	width: 100%;
-	height: 90px;
-	display: flex;
-	flex-direction: column;
-	justify-content: space-between;
-}
-
-.t_b_btnArea{
-	width: 100%;
-	height: 30px;
-	display: flex;
-	align-items: center;
-	box-sizing: border-box;
-	padding: 0 10px;
-	overflow-y: hidden;
-}
-
-.t_b_ba_item{
-	width: auto;
-	box-sizing: border-box;
-	padding: 0 10px;
-	height: 25px;
-	background-color: white;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	/* 阴影 */
-	box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.363);
-	border-radius: 15px;
-	font-size: 14px;
-	cursor: pointer;
-	margin-right: 10px;
-	white-space: nowrap;
-	transition: .3s;
-}
-
-.t_b_ba_item:hover{
-	background-color: rgb(236, 236, 236);
-}
-
-
-.t_b_inputArea{
-	width: 100%;
-	height: 55px;
-	box-sizing: border-box;
-	border-top: solid 1px #EDEDED;
-	display: flex;
-	justify-content: space-between;
-	align-items: center;
-	padding-right: 10px;
-}
-
-.t_b_tape{
-	width: 35px;
-	height: 35px;
-	background: url("../../../assets/icon/course/tape.png") no-repeat;
-	background-size: 50% 60%;
-	background-position: center;
-	cursor: pointer;
-}
-
-.t_b_input{
-	/* width: 75%; */
-	flex: 1;
-	height: 45px;
-	background-color: #F3F3F3;
-	border-radius: 50px;
-	margin: 0 10px;
-	display: flex;
-	overflow: hidden;
-	align-items: center;
-}
-
-.t_b_i_left{
-	/* width: calc(100% - 45px); */
-	width: 100%;
-	line-height: 45px;
-	height: 100%;
-}
-
-.t_b_i_left>>>.el-input__inner{
-	border: none;
-	background-color: #F3F3F3;
-	outline: none;
-	border-radius: 50px 0 0 50px;
-}
-
-
-.t_b_i_right{
-	width: 45px;
-	height: 45px;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-}
-
-.t_b_i_right>span{
-	width: 35px;
-	height: 35px;
-	background: url("../../../assets/icon/course/file.png") no-repeat;
-	background-size: 50% 60%;
-	background-position: center;
-	cursor: pointer;
-}
-
-.t_b_btn{
-	width: 40px;
-	height: 40px;
-	background-color: #3681FC;
-	display: flex;
-	justify-content: center;
-	align-items: center;
-	border-radius: 50%;
-	cursor: pointer;
-}
-
-.t_b_btn>span{
-	width: 30px;
-	height: 30px;
-	background: url("../../../assets/icon/course/send.png") no-repeat;
-	background-size: 70% 70%;
-	background-position: center;
-	
-}
-
-td,th{
-	padding: 10px;
-}
-
+  box-shadow: 0 0px 10px #c5cbee;
+}
 
-</style>
+.t_t_c_a_r_c_title {
+  display: flex;
+  align-items: center;
+}
+.t_t_c_a_r_c_title > img {
+  width: 16px;
+  height: 16px;
+}
+
+.t_t_c_a_r_c_item {
+  width: 100%;
+  height: auto;
+  box-sizing: border-box;
+  padding: 10px;
+  background-color: #ffffff;
+  border-radius: 5px;
+  margin-top: 5px;
+  color: #666666;
+  font-size: 14px;
+  cursor: pointer;
+}
+
+.t_t_c_a_r_c_item:hover {
+  border: solid #b8d2fe 1px;
+  box-shadow: 0 0 5px 2px #b8d2fe;
+}
+
+.t_t_c_a_r_c_title > span {
+  font-weight: bold;
+}
+
+.t_t_c_a_r_time {
+  width: 100%;
+  display: flex;
+  justify-content: flex-start;
+  font-size: 12px;
+  color: #9f9f9f;
+  margin-top: 5px;
+}
+
+.t_t_c_a_left {
+  width: 35px;
+  height: 35px;
+  display: flex;
+  justify-content: center;
+  margin-right: 5px;
+}
+
+.t_t_c_a_left > span {
+  width: 32px;
+  height: 32px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: white;
+  background-color: #3681fc;
+  border-radius: 50%;
+}
+
+.t_bottom {
+  width: 100%;
+  height: 90px;
+  display: flex;
+  flex-direction: column;
+  justify-content: space-between;
+}
+
+.t_b_btnArea {
+  width: 100%;
+  height: 30px;
+  display: flex;
+  align-items: center;
+  box-sizing: border-box;
+  padding: 0 10px;
+  overflow-y: hidden;
+}
+
+.t_b_ba_item {
+  width: auto;
+  box-sizing: border-box;
+  padding: 0 10px;
+  height: 25px;
+  background-color: white;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  /* 阴影 */
+  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.363);
+  border-radius: 15px;
+  font-size: 14px;
+  cursor: pointer;
+  margin-right: 10px;
+  white-space: nowrap;
+  transition: 0.3s;
+}
+
+.t_b_ba_item:hover {
+  background-color: rgb(236, 236, 236);
+}
+
+.t_b_inputArea {
+  width: 100%;
+  height: 55px;
+  box-sizing: border-box;
+  border-top: solid 1px #ededed;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding-right: 10px;
+}
+
+.t_b_tape {
+  width: 35px;
+  height: 35px;
+  background: url("../../../assets/icon/course/tape.png") no-repeat;
+  background-size: 50% 60%;
+  background-position: center;
+  cursor: pointer;
+}
+
+.t_b_input {
+  /* width: 75%; */
+  flex: 1;
+  height: 45px;
+  background-color: #f3f3f3;
+  border-radius: 50px;
+  margin: 0 10px;
+  display: flex;
+  overflow: hidden;
+  align-items: center;
+}
+
+.t_b_i_left {
+  /* width: calc(100% - 45px); */
+  width: 100%;
+  line-height: 45px;
+  height: 100%;
+}
+
+.t_b_i_left >>> .el-input__inner {
+  border: none;
+  background-color: #f3f3f3;
+  outline: none;
+  border-radius: 50px 0 0 50px;
+}
+
+.t_b_i_right {
+  width: 45px;
+  height: 45px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+
+.t_b_i_right > span {
+  width: 35px;
+  height: 35px;
+  background: url("../../../assets/icon/course/file.png") no-repeat;
+  background-size: 50% 60%;
+  background-position: center;
+  cursor: pointer;
+}
+
+.t_b_btn {
+  width: 40px;
+  height: 40px;
+  background-color: #3681fc;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 50%;
+  cursor: pointer;
+}
+
+.t_b_btn > span {
+  width: 30px;
+  height: 30px;
+  background: url("../../../assets/icon/course/send.png") no-repeat;
+  background-size: 70% 70%;
+  background-position: center;
+}
+
+td,
+th {
+  padding: 10px;
+}
+</style>

+ 33 - 5
src/components/classRoomHelper/index.vue

@@ -1,9 +1,21 @@
 <template>
   <div class="ch_box" ref="ch_box">
     <div class="ch_content_box" v-if="type == 1">
-      <searchArea v-show="itemType == 1" />
-      <taskArea v-show="itemType == 2" />
-      <dialogArea v-show="itemType == 3" />
+      <searchArea
+        :courseDetail="courseDetail"
+        ref="searchAreaRef"
+        v-show="itemType == 1"
+      />
+      <taskArea
+        :courseDetail="courseDetail"
+        ref="taskAreaRef"
+        v-show="itemType == 2"
+      />
+      <dialogArea
+        :courseDetail="courseDetail"
+        ref="dialogAreaRef"
+        v-show="itemType == 3"
+      />
     </div>
     <div class="ch_nav_box">
       <div class="ch_nav_box_top">
@@ -130,12 +142,18 @@ import searchArea from "./component/searchArea.vue";
 import taskArea from "./component/taskArea.vue";
 import dialogArea from "./component/dialogArea.vue";
 export default {
-  emits: ["refresh", "goStep", "backPage","authority"],
+  emits: ["refresh", "goStep", "backPage", "authority"],
   components: {
     searchArea,
     taskArea,
     dialogArea
   },
+  props: {
+    courseDetail: {
+      type: Object,
+      default: () => {}
+    }
+  },
   data() {
     return {
       type: 0,
@@ -160,7 +178,17 @@ export default {
     changeItemType(type) {
       this.type = 0;
       this.openSetting();
-      this.itemType = type;
+      this.$nextTick(() => {
+        if (this.itemType == 1 && type != 1) {
+          this.$refs.searchAreaRef.scrollBottom();
+          this.$refs.searchAreaRef.getWantSearch();
+        } else if (this.itemType == 2) {
+          this.$refs.taskAreaRef.scrollBottom();
+        } else if (this.itemType == 3) {
+          this.$refs.dialogAreaRef.scrollBottom();
+        }
+        this.itemType = type;
+      });
     }
   }
 };

+ 1 - 1
src/components/studyStudent.vue

@@ -8064,7 +8064,7 @@
           </div>
         </el-dialog>
       </div>
-      <classRoomHelper ref="classRoomHelperRef" @setWidth="setClassRoomHelperWidth" @refresh="refreshCourse" @goStep="nextOrpreSteps" @authority="juriVisible = true" @backPage="goTo(
+      <classRoomHelper ref="classRoomHelperRef" :courseDetail="courseDetail" @setWidth="setClassRoomHelperWidth" @refresh="refreshCourse" @goStep="nextOrpreSteps" @authority="juriVisible = true" @backPage="goTo(
                     '/courseDetail?userid=' +
                       userid +
                       '&oid=' +