2 Commits 36fb2870b0 ... 3be7c5b7f4

Tác giả SHA1 Thông báo Ngày
  lsc 3be7c5b7f4 Merge branch 'beta' of https://git.cocorobo.cn/CocoRoboLabs/pbl-teacher-table into beta 1 tháng trước cách đây
  lsc a991c5dda2 update 1 tháng trước cách đây

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


+ 69 - 19
src/components/pages/aiAddCourse/addCourse.vue

@@ -1,8 +1,8 @@
 <template>
-  <div class="pb_content" style="background: #f0f2f5" v-loading="loading" element-loading-text="小可正在努力生成中,请稍等...">
+  <div class="pb_content" style="background: #f0f2f5;overflow: hidden;" v-loading="loading" element-loading-text="小可正在努力生成中,请稍等...">
     <div class="c_pub_button_confirm stopBtn" v-if="loading && isOutlineCancelToken" @click="cancelAjax('outline')">停止</div>
     <div class="c_pub_button_confirm stopBtn" v-if="loading && isTeacherTaskCancelToken" @click="cancelAjax('teacherTask')">停止</div>
-    <div class="pb_content_body" style="position: relative; margin: 0">
+    <div class="pb_content_body" style="position: relative; margin: 0;overflow: hidden;">
       <div class="right" :style="{width:istemplate == 1 ? 'calc(100% - 300px)' : '100%'}">
         <div class="courseTop">
           <div class="stepsNav">
@@ -11253,11 +11253,45 @@ export default {
         let _file = this.knowFileArray[fi]
         let fileM = _file.grade ? converter(_file.grade).split('/') : 1
         let fileS = _file.name ? converter(_file.name).split('/') : 1
-        let _sub = fileS == 1 ? [1] : this.arrayToArray(fileS, sub)
-        let _mclass = fileM == 1 ? [1] : this.arrayToArray(fileM, mclass)
+        let _sub = fileS == 1 ? [] : this.arrayToArray(fileS, sub)
+        let _mclass = fileM == 1 ? [] : mclass.length ? this.arrayToArray(fileM, mclass) : [2]
         let fileids = this.knowInfoData.map((item) => item.fileid)
 
-        if(_sub.length > 0 && _mclass.length > 0 && fileids.indexOf(_file.fileid) == -1){
+        if(_sub.length > 0 && _mclass.length > 0 && _mclass[0] == 2 && fileids.indexOf(_file.fileid) == -1){
+          this.knowInfoData.push({
+            name: _file.filename,
+            url: _file.url,
+            uid: '',
+            type: 3,
+            fileid: _file.fileid,
+          });
+          this.knowFileids.push(_file.fileid)
+        }
+        fileids = this.knowInfoData.map((item) => item.fileid)
+        if(_mclass.length > 0 && fileS == 1 && _mclass[0] != 2 && fileids.indexOf(_file.fileid) == -1){
+          this.knowInfoData.push({
+            name: _file.filename,
+            url: _file.url,
+            uid: '',
+            type: 3,
+            fileid: _file.fileid,
+          });
+          this.knowFileids.push(_file.fileid)
+        }
+        fileids = this.knowInfoData.map((item) => item.fileid)
+        if(_sub.length > 0 && fileM == 1 && fileids.indexOf(_file.fileid) == -1){
+          this.knowInfoData.push({
+            name: _file.filename,
+            url: _file.url,
+            uid: '',
+            type: 3,
+            fileid: _file.fileid,
+          });
+          this.knowFileids.push(_file.fileid)
+        }
+        fileids = this.knowInfoData.map((item) => item.fileid)
+
+        if(_sub.length > 0 && _mclass.length > 0 && _mclass[0] != 2 && fileids.indexOf(_file.fileid) == -1){
           this.knowInfoData.push({
             name: _file.filename,
             url: _file.url,
@@ -16554,12 +16588,23 @@ export default {
         this.$message.error("请补充填写课程名称");
         return;
       }
-      this.openAiDialog(2, 'aiDetail',1)
+      let functionA = ''
       if(this.templateid != '4480d65a-1e48-11ef-bee5-005056b86db5' && this.templateid != 'cf5722a4-401b-11ef-b873-005056b86dc3'){
-        setTimeout(() => {
+        // setTimeout(() => {
           // this.openAiDialog(2, 'aitargetTextDetail2',1)
+        //   this.openAiDialog(2, 'aitargetTextDetail3',1)
+        // }, 500);
+        functionA = ()=>{
           this.openAiDialog(2, 'aitargetTextDetail3',1)
-        }, 500);
+        }
+      }
+
+      this.openAiDialog(2, 'aiDetail',1, functionA)
+      if(this.templateid != '4480d65a-1e48-11ef-bee5-005056b86db5' && this.templateid != 'cf5722a4-401b-11ef-b873-005056b86dc3'){
+        // setTimeout(() => {
+          // this.openAiDialog(2, 'aitargetTextDetail2',1)
+        //   this.openAiDialog(2, 'aitargetTextDetail3',1)
+        // }, 500);
       }
 
       this.courseTextBool = true
@@ -16680,7 +16725,7 @@ export default {
         this.aitype = "aiDetail"
         // this.aiText = `请根据${this.courseText}设计一个名为${this.courseName}的${sub.length ? sub.join(",") + "学科的" : ""},面向${this.getListClassC(this.checkboxList2)}的项目式学习课程。`
         this.aiText = this.aiJson.aiDetail
-        this.aiCallBack = callback
+        this.aiCallBack = [callback, index]
       } else if (type == "aiOutline") {
         this.aitype = "aiOutline"
         // this.aiText = `请根据${this.courseText}设计一个名为${this.courseName}的${sub.length ? sub.join(",") + "学科的" : ""},面向${this.getListClassC(this.checkboxList2)}的项目式学习课程设计序列教学活动(需要每个任务都需要至少50个token的详细描述),每个教学活动的活动设计(可以直接使用文件内容)以及每个教学活动的评价量规(学生能做到...)。`
@@ -16977,6 +17022,10 @@ export default {
           });
           return;
         }
+        if(!this.courseText){
+          this.$message.error("请生成简要描述后再生成目标");
+          return;
+        }
         this.aitype = type
         this.aiText = this.aiJson.aiTargetGet
         this.aiText2 = this.aiJson.aiTarget2
@@ -17694,16 +17743,14 @@ ${sub.length ? '学科:' + sub.join(",") : ''}
 ${mclass.length ? '面向年级:' + mclass.join(",") : ''}
 ${(this.mode == 1 && (!this.yiKeTemplateArray.includes(this.templateid)) && this.teacherCourseText) ? '提取教案摘要:'+this.teacherCourseText : ''}
 ${(this.mode == 1 && (!this.yiKeTemplateArray.includes(this.templateid)) && target) ? '提取教案目标:'+target : ''}
-${this.courseText && this.aiCallBack == 2 ? '参考内容:'+this.courseText : ''}
+${this.courseText && this.aiCallBack[0] == 2 ? '参考内容:'+this.courseText : ''}
 
 ## 要求
 ${message} 以及##参考资料 ${(!this.yiKeTemplateArray.includes(this.templateid)) ? "" : '以文本格式输出项目概况,驱动性问题,最终作品'}
 
 ${(this.templateid != 'cf5722a4-401b-11ef-b873-005056b86dc4') && '## Format example 课程简要描述:课程内容的简单叙述。 驱动性问题:1个驱动整个项目的问题。 最终作品:对应解决驱动性问题的作品,可个人可团队。'}
 
-${this.courseText && this.aiCallBack == 2 ? '注意,优化原有的<参考内容>即可不用重新生成,让内容更具体化,更具体' : ''}
-
-如果在上传的文件中没有找到相关的课程简要描述、驱动性问题和最终作品的信息,请用自身的理解输出`
+${this.courseText && this.aiCallBack[0] == 2 ? '注意,优化原有的<参考内容>即可不用重新生成,让内容更具体化,更具体' : ''}`
       this.aiGet(msg)
     },
     setUnitJson() {
@@ -17859,6 +17906,7 @@ ${this.courseText && this.aiCallBack == 2 ? '注意,优化原有的<参考内
           this.ttextLoading = false
           this.courseTextB = false
           this.isTextCancelToken = null
+          this.aiCallBack[1] ? this.aiCallBack[1]() : ''
           return;
         } else {
           _iindex++
@@ -22779,8 +22827,8 @@ ${this.targetCourseText && this.aiCallBack == 2 ? '注意,优化原有的<参
       }
 
       if(!msg2 && sub.length){
-        let _fileid = _this.importFileid(sub)
-        fileid = [...fileid, ..._fileid]
+        // let _fileid = _this.importFileid(sub)
+        // fileid = [...fileid, ..._fileid]
       }
 
       let messages = `NOTICE
@@ -22821,7 +22869,7 @@ ${this.targetCourseText && this.aiCallBack == 2 ? '注意,优化原有的<参
       _this.isTargetCancelToken2 = _this.ajax.setCancelSource();
 
       let params = {
-        assistant_id: 'f8e1ebb2-2e0d-11ef-8bf4-12e77c4cb76b',
+        assistant_id: 'b19f1a1a-7586-11ef-8ce0-12e77c4cb76b',
         message: [{"type":"text", "text":this.languageSetting == 1 ? converter2(messages.replaceAll('\n', " ").replaceAll('*', "")) : messages.replaceAll('\n', " ").replaceAll('*', "")}],
         session_name: _uuid,
         userId: _this.userid,
@@ -22881,7 +22929,7 @@ ${this.targetCourseText && this.aiCallBack == 2 ? '注意,优化原有的<参
         this.isTargetCancelToken2 = null
         return;
       }
-      
+      let text1 = this.targetCourseText2 ? JSON.parse(JSON.stringify(this.targetCourseText2)) : ''
       let _allText = "";
       let _mdText = "";
       let _iindex = 0
@@ -22892,7 +22940,7 @@ ${this.targetCourseText && this.aiCallBack == 2 ? '注意,优化原有的<参
           _mdText = _mdText.replace("_", "").replace(/【[^】]*source[^】]*】/g, '').replaceAll("<br>", "");
           this.isTargetCancelSource2.close();
           this.isTargetCancelSource2 = null;
-          this.targetCourseText2 = _mdText;
+          this.targetCourseText2 = text1+'    \n    '+_mdText;
           this.targetTextLoading2 = false
           this.ttargetTextLoading2 = false
           this.targetCourseText2B = false
@@ -22914,7 +22962,7 @@ ${this.targetCourseText && this.aiCallBack == 2 ? '注意,优化原有的<参
           if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
           //转化返回的回复流数据
           if(_iindex == 10){
-            this.targetCourseText2 = _mdText;
+            this.targetCourseText2 = text1+'     \n    '+_mdText;
             _iindex = 0
           }
           if(this.targetTextLoading2){
@@ -23011,6 +23059,7 @@ ${this.targetCourseText && this.aiCallBack == 2 ? '注意,优化原有的<参
 
 ## 课程信息
 课程名字:${this.courseName}
+课程概况:${this.courseText}
 ${sub.length ? '学科:' + sub.join(",") : ''}
 ${mclass.length ? '年级:' + mclass.join(",") : ''}`
       let _uuid = uuidv4();
@@ -23070,6 +23119,7 @@ ${mclass.length ? '年级:' + mclass.join(",") : ''}`
         // }
         if (data.message) {
           console.log('返回回来的目标:',data.message);
+          _this.targetCourseText2 = data.message
           _this.aitargetTextDetail22(_this.aiJson.aiTarget2, data.message.replaceAll('#', " ").replaceAll('*', "").replaceAll('\n', ""))
         
         }

+ 74 - 5
src/components/pages/aiAddCourse/aiBoxRight.vue

@@ -19,8 +19,11 @@
             minHeight: item.loading ? '50px' : 'unset',
             minWidth: item.loading ? '50px' : 'unset'
           }" class="content" v-loading="item.loading">
-            <span class="vditor-reset" v-html="item.aiContent"></span><span class="createTime"
-              v-text="item.createtime"></span>
+            <span class="vditor-reset" v-html="item.aiContent"></span>
+            <span class="createTime" v-text="item.createtime"></span>
+          </div>
+          <div class="ai_btn_box" v-if="!pan(item.aiContent).length && !item.loading">
+            <img src="../../../assets/icon/course/pasete.png" @click="onCopy(item.aiContent)" >
           </div>
         </div>
       </div>
@@ -113,7 +116,7 @@
       <div class="ai_b_i_jListPanel" @click="showjList = !showjList" v-if="showjList && jArray.length > 0"></div>
       <div class="ai_b_i_jListBox" v-if="showjList && jArray.length > 0">
         <div class="jlist_box" v-for="(item, index) in jArray" :key="index">
-          <el-tooltip :content="item.area + ':' + item.value" placement="top" effect="dark" popper-class="text_tooltip2">
+          <el-tooltip :content="item.area + ':' + item.value" placement="left" effect="dark" popper-class="text_tooltip2">
             <!-- content to trigger tooltip here -->
             <span>{{ item.area }}:{{ item.value }}</span>
           </el-tooltip>
@@ -162,6 +165,9 @@ import checkImg from "../../../assets/icon/sourceFile/check.png";
 import checkIsImg from "../../../assets/icon/sourceFile/check_is.png";
 import { v4 as uuidv4 } from "uuid";
 import MarkdownIt from "markdown-it";
+import TurndownService from 'turndown';
+
+
 export default {
   props: {
     unitJson: {
@@ -1007,9 +1013,62 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
         } `;
       this.$refs.textareaRef.focus();
       this.showRoleList = false;
-    }
+    },
+    onCopy(content) {
+      const turndownService = new TurndownService();
+      // 添加自定义规则来处理表格
+      turndownService.addRule('table', {
+        filter: 'table',
+        replacement: (content, node) => {
+          const rows = node.querySelectorAll('tr');
+          let markdown = '';
+
+          rows.forEach((row) => {
+            const cells = row.querySelectorAll('th, td');
+            const rowMarkdown = Array.from(cells).map(cell => cell.textContent).join(' | ');
+            markdown += `| ${rowMarkdown} |\n`;
+            if(cells && cells.length && cells[0].tagName == 'TH'){
+              let a = Array.from(cells).map(cell => '').join(' --- |')
+              markdown += `| --- |${a}\n`;
+            }
+          });
+
+          // 添加分隔行
+          // markdown = markdown.replace(/^/, '| --- |\n');
+          return markdown;
+        },
+      });
+      // 创建临时textarea元素
+      const tempInput = document.createElement("textarea");
+      
+      tempInput.value = turndownService.turndown(content); // 设置要复制的内容
+      // 隐藏元素
+      tempInput.style.position = "absolute";
+      tempInput.style.left = "-9999px";
+      // 将元素添加到DOM中
+      document.body.appendChild(tempInput);
+      // 选中元素内容
+      tempInput.select();
+      // 执行复制操作
+      document.execCommand("copy");
+      // 移除临时元素
+      document.body.removeChild(tempInput);
+      this.$message({
+        message: "复制成功",
+        type: "success"
+      });
+    },
   },
   computed: {
+    pan() {
+      return content => {
+        try {
+          return JSON.parse(content);
+        } catch (error) {
+          return [];
+        }
+      };
+    },
     courseTextLength() {
       return this.courseText.length;
     },
@@ -1429,7 +1488,7 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
   word-break: break-word;
   box-sizing: border-box;
   /* white-space: pre-line; */
-  max-width: calc(100% - 50px);
+  max-width: calc(100% - 85px);
   background: #f6f9ff;
   /* overflow: hidden; */
   margin: 0 10px;
@@ -1665,4 +1724,14 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'.Output format carefully reference
   overflow: hidden;
   word-break: break-all;
 }
+
+.ai_btn_box{
+  min-width: fit-content;
+  margin-top: auto;
+}
+
+.ai_btn_box > img{
+  cursor: pointer;
+  width: 15px;
+}
 </style>