zengyicheng 1 year ago
parent
commit
3fcb080dfe

File diff suppressed because it is too large
+ 288 - 716
package-lock.json


+ 13 - 14
src/common/axios.config.js

@@ -1,13 +1,13 @@
 import axios from "axios"
 import qs from "qs"
-axios.defaults.timeout = 900000   //响应时间
-axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';        //配置请求头
-axios.defaults.baseURL = process.env.NODE_HOST;   //配置接口地址
+axios.defaults.timeout = 900000 //响应时间
+axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; //配置请求头
+axios.defaults.baseURL = process.env.NODE_HOST; //配置接口地址
 console.log(process.env)
-//POST传参序列化(添加请求拦截器)
+    //POST传参序列化(添加请求拦截器)
 axios.interceptors.request.use((config) => {
     //在发送请求之前做某件事
-    let token = sessionStorage.getItem('access_token') || ""  //获取token 
+    let token = sessionStorage.getItem('access_token') || "" //获取token 
     console.log(token)
     if (token != "") {
         config.headers = {
@@ -15,13 +15,12 @@ axios.interceptors.request.use((config) => {
             'Content-Type': 'application/x-www-form-urlencoded'
         }
     }
-
-    if(config.url === 'https://gpt.cocorobo.cn/chat') {
-        config.data = config.data//序列化post 参数
-    } 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') {
-        config.data = qs.stringify(config.data)//序列化post 参数
+    if (config.url === 'https://gpt.cocorobo.cn/chat') {
+        config.data = config.data //序列化post 参数
+    } 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') {
+        config.data = qs.stringify(config.data) //序列化post 参数
     }
     return config;
 }, (error) => {
@@ -33,13 +32,13 @@ axios.interceptors.request.use((config) => {
 axios.interceptors.response.use((res) => {
     //对响应数据做些事
     if (!res.data.success) {
-        let newToken = res.data.token    //成功后更新token 
+        let newToken = res.data.token //成功后更新token 
         localStorage.setItem('access_token', newToken)
 
     }
     return res;
 }, (error) => {
-    if (error.response.data.status == '401') {    //如果token 过期 则跳转到登录页面
+    if (error.response.data.status == '401') { //如果token 过期 则跳转到登录页面
         this.$router.push('/login');
     }
     return Promise.reject(error);

+ 107 - 50
src/components/components/englishEva.vue

@@ -27,7 +27,9 @@
         :style="{ height: `calc(100% - ${topHeight}px)` }"
       >
         <div class="oldBox">
-          <div class="oldMes">原文( 作者:{{ evaEngJson.username }} )</div>
+          <div class="oldMes">
+            原文( 作者:{{ evaEngJson.message.username }} )
+          </div>
           <div class="oldText">
             <div class="detailBox">
               <div class="oldDetail">
@@ -53,7 +55,11 @@
             </div>
           </div>
         </div>
-        <div class="oldBox" style="position: relative">
+        <div
+          class="oldBox"
+          style="position: relative; overflow: hidden"
+          :style="{ height: `calc(100% - ${topHeight}px)` }"
+        >
           <div
             class="oldMes"
             style="
@@ -79,57 +85,61 @@
               教师评价
             </div>
           </div>
-          <div v-if="type == 0">
-            <el-button
+          <div
+            v-if="type == 0"
+            style="
+              height: calc(100% - 45px);
+              margin: 10px 0 0 0;
+              overflow: auto;
+            "
+          >
+            <!-- <el-button
               type="primary"
               @click="getAiPj"
               v-if="!isPj"
               style="margin: 10px 0 0 0"
               >AI评价</el-button
-            >
-            <div class="oldText" style="margin-top: 10px" v-else>
+            > -->
+            <div class="oldText loadingText" style="margin-top: 10px">
               <div class="detailBox" style="min-width: 300px">
                 <div class="oldDetail" style="min-width: 300px">
-                  <div>作业批改:</div>
-                  <el-input
+                  <div>作业原文:</div>
+                  <div v-html="evaEngJson.studentJson.engText"></div>
+                  <!-- <el-input
                     type="textarea"
                     :rows="10"
                     resize="none"
                     v-model="aiList.engTitle"
                     disabled
-                  />
+                  /> -->
                 </div>
                 <div class="oldDetail" style="min-width: 300px">
                   <div>作业评价:</div>
-                  <el-input
+                  <div v-if="!aiList.engText">暂无AI评价</div>
+                  <div v-else v-html="html"></div>
+                  <!-- <el-input
                     type="textarea"
                     :rows="10"
                     resize="none"
                     v-model="aiList.engText"
                     disabled
-                  />
+                  /> -->
                 </div>
               </div>
             </div>
             <el-button
               type="primary"
-              @click="isPj = false"
-              v-if="isPj"
+              @click="getAiPj"
               style="position: absolute; top: 50px; right: 20px"
-              >返回评价</el-button
+              >AI评价</el-button
             >
           </div>
           <div v-if="type == 1" style="margin: 10px 0 0 0">
             <div class="oldText" style="margin-top: 10px">
               <div class="detailBox" style="min-width: 300px">
                 <div class="oldDetail" style="min-width: 300px">
-                  <div>作业批改:</div>
-                  <el-input
-                    type="textarea"
-                    :rows="10"
-                    resize="none"
-                    v-model="teacherList.engTitle"
-                  />
+                  <div>作业原文:</div>
+                  <div v-html="evaEngJson.studentJson.engText"></div>
                 </div>
                 <div class="oldDetail" style="min-width: 300px">
                   <div>作业评价:</div>
@@ -152,29 +162,35 @@
       style="z-index: 999; position: relative"
     >
       <el-button @click="close()">取 消</el-button>
-      <el-button type="primary">确 定</el-button>
+      <el-button type="primary" @click="addCode">确 定</el-button>
     </span>
   </el-dialog>
 </template>
 
 <script>
+import MarkdownIt from "markdown-it";
 export default {
-  props: ["engEvaDialogVisible", "evaEngJson", "userid"],
+  props: ["engEvaDialogVisible", "evaEngJson", "uid"],
   data() {
     return {
       topHeight: 0,
       type: 0,
-      isPj: false,
       aiList: {
-        engTitle: "这是题目",
-        engText: "这是内容",
+        engTitle: "",
+        engText: "",
       },
       teacherList: {
         engTitle: "",
         engText: "",
       },
+      md: new MarkdownIt(),
     };
   },
+  computed: {
+    html() {
+      return this.aiList.engText ? this.md.render(this.aiList.engText) : "";
+    },
+  },
   methods: {
     handleClose(done) {
       this.close();
@@ -211,38 +227,80 @@ export default {
       this.$forceUpdate();
     },
     getAiPj() {
-      let param = [
-        {
-          model: "gpt-3.5-turbo",
-          temperature: 0,
-          max_tokens: 2048,
-          top_p: 1,
-          frequency_penalty: 0,
-          presence_penalty: 0,
-          message: [
-            {
-              role: "user",
-              content:
-                "英语写作批改是这样的:你的任务是为文字内容进行批注,请依照以下步骤完成任务,并仅显示第二步完成的内容:1.校对并更正:" + this.evaEngJson.studentJson.engText + "2.通过文本批注的形式,即将错误的单词用删除线划去,并将正确内容补充在后面,将前一段文字修改为后一段文字,并以markdown的形式呈现。",
-            },
-          ],
-          uid: this.userid,
-          stream: false,
-        },
-      ];
+      const loading = this.$loading.service({
+        background: "rgba(255, 255, 255)",
+        target: document.querySelectorAll(".loadingText")[0],
+      });
+      let param = {
+        model: "gpt-3.5-turbo",
+        temperature: 0,
+        max_tokens: 2048,
+        top_p: 1,
+        frequency_penalty: 0,
+        presence_penalty: 0,
+        messages: [
+          {
+            role: "user",
+            content:
+              "你的任务是为文字内容进行批注,请依照以下步骤完成任务,并仅显示第二步完成的内容:1.校对并更正:" +
+              this.evaEngJson.studentJson.engText +
+              "2.通过文本批注的形式,即将错误的单词用删除线划去,并将正确内容补充在后面,将前一段文字修改为后一段文字,并以markdown的形式呈现。",
+          },
+        ],
+        uid: this.uid,
+        stream: false,
+      };
       this.ajax.post("https://gpt.cocorobo.cn/chat", param).then(
         (res) => {
-          console.log(res);
-          this.isPj = true;
+          if (
+            res.data.FunctionResponse &&
+            res.data.FunctionResponse.result &&
+            res.data.FunctionResponse.result == "无效请求,请重新发起对话"
+          ) {
+            this.$message.error("你的作文内容太长,无法使用Ai评价!");
+            return;
+          }
+          this.aiList.engText =
+            res.data.FunctionResponse.choices[0].message.content;
+          loading.close();
         },
         (err) => {
           console.log(err);
+          loading.close();
         }
       );
     },
+    addCode() {
+      let params = {
+        id: this.evaEngJson.message.id,
+        aic: this.aiList.engText,
+        tc: this.teacherList.engText,
+        t: this.type,
+      };
+      this.ajax
+        .get(this.$store.state.api + "addEngEva", params)
+        .then((res) => {
+          this.$message.success("评价成功");
+        })
+        .catch((err) => {
+          this.$message.error("网络不佳");
+          console.error(err);
+        });
+    },
   },
-  mounted() {
-    this.topHeight = document.querySelectorAll(".engUpTop")[0].offsetHeight;
+  mounted() {},
+  watch: {
+    engEvaDialogVisible: {
+      handler(newVal) {
+        if (newVal == true) {
+          this.aiList.engText = this.evaEngJson.message.aiCode;
+          this.teacherList.engText = this.evaEngJson.message.teacherCode;
+          this.topHeight =
+            document.querySelectorAll(".engUpTop")[0].offsetHeight;
+        }
+      },
+      deep: true,
+    },
   },
 };
 </script>
@@ -352,7 +410,6 @@ export default {
   flex-direction: column;
   flex-wrap: nowrap;
   align-content: center;
-  justify-content: center;
   align-items: center;
 }
 

+ 3 - 3
src/components/easy2/studyStudent.vue

@@ -11406,7 +11406,7 @@
         <el-button type="primary" @click="addCorrect">确 定</el-button>
       </span>
     </el-dialog>
-    <englishEva :evaEngJson="evaEngJson" :engEvaDialogVisible.sync="engEvaDialogVisible"></englishEva>
+    <englishEva :evaEngJson="evaEngJson" :engEvaDialogVisible.sync="engEvaDialogVisible" :uid="userid"></englishEva>
     <interVideo
       :dialogVisibleVideo.sync="dialogVisibleVideo"
       :videoJson="videoJson"
@@ -11551,9 +11551,9 @@ export default {
       engUpdateDialogVisible:false,
       engEvaDialogVisible: false,
       evaEngJson: {
-        username: "",
         teacherJson: {},
         studentJson: {},
+        message: {},
       },
       isNoUserid:false,
       engListLength:0,
@@ -13591,8 +13591,8 @@ export default {
       this.ajax
         .get(this.$store.state.api + "selectEngWork", params)
         .then((res) => {
+          this.evaEngJson.message = res.data[0][0];
           this.evaEngJson.studentJson = JSON.parse(res.data[0][0].content);
-          this.evaEngJson.username = res.data[0][0].username;
           this.evaEngJson.teacherJson = this.chapInfoList[this.courseType].chapterInfo[0].taskJson[this.taskCount]
               .toolChoose[i].englishList;
           this.engEvaDialogVisible = true;

+ 3 - 3
src/components/easy3/studyStudent.vue

@@ -11393,7 +11393,7 @@
         <el-button type="primary" @click="addCorrect">确 定</el-button>
       </span>
     </el-dialog>
-    <englishEva :evaEngJson="evaEngJson" :engEvaDialogVisible.sync="engEvaDialogVisible"></englishEva>
+    <englishEva :evaEngJson="evaEngJson" :engEvaDialogVisible.sync="engEvaDialogVisible" :uid="userid"></englishEva>
     <interVideo
       :dialogVisibleVideo.sync="dialogVisibleVideo"
       :videoJson="videoJson"
@@ -11723,9 +11723,9 @@ export default {
       engUpdateDialogVisible:false,
       engEvaDialogVisible: false,
       evaEngJson: {
-        username: "",
         teacherJson: {},
         studentJson: {},
+        message: {},
       },
       isNoUserid:false,
       engListLength:0,
@@ -13580,8 +13580,8 @@ export default {
       this.ajax
         .get(this.$store.state.api + "selectEngWork", params)
         .then((res) => {
+          this.evaEngJson.message = res.data[0][0];
           this.evaEngJson.studentJson = JSON.parse(res.data[0][0].content);
-          this.evaEngJson.username = res.data[0][0].username;
           this.evaEngJson.teacherJson = this.chapInfoList[this.courseType].chapterInfo[0].taskJson[this.taskCount]
               .toolChoose[i].englishList;
           this.engEvaDialogVisible = true;

+ 2 - 2
src/components/studyStudent.vue

@@ -11520,9 +11520,9 @@ export default {
       engUpdateDialogVisible: false,
       engEvaDialogVisible: false,
       evaEngJson: {
-        username: "",
         teacherJson: {},
         studentJson: {},
+        message: {},
       },
       isNoUserid:false,
       engListLength:0,
@@ -13558,8 +13558,8 @@ export default {
       this.ajax
         .get(this.$store.state.api + "selectEngWork", params)
         .then((res) => {
+          this.evaEngJson.message = res.data[0][0];
           this.evaEngJson.studentJson = JSON.parse(res.data[0][0].content);
-          this.evaEngJson.username = res.data[0][0].username;
           this.evaEngJson.teacherJson = this.chapInfoList[this.courseType].chapterInfo[0].taskJson[this.taskCount]
               .toolChoose[i].englishList;
           this.engEvaDialogVisible = true;

Some files were not shown because too many files changed in this diff