소스 검색

知识问答VueMarkdown

maxiaoxiao 10 달 전
부모
커밋
ac27656777
2개의 변경된 파일26개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 0
      package.json
  2. 25 12
      src/views/aiModel/index.vue

+ 1 - 0
package.json

@@ -28,6 +28,7 @@
         "vue": "^2.7.16",
         "vue-layer": "^1.2.5",
         "vue-lazyload": "^1.3.3",
+        "vue-markdown": "^2.2.4",
         "vue-template-compiler": "2.7.16",
         "wellknown": "^0.5.0"
     },

+ 25 - 12
src/views/aiModel/index.vue

@@ -25,12 +25,8 @@
             @click="sendToBackend(item.content, index)"
           ></i>
           <div class="content">
-            <audio
-              v-if="item.mp3url"
-              controls
-              autoplay
-              :src="item.mp3url"
-            ></audio>
+            <!-- autoplay -->
+            <audio v-if="item.mp3url" controls :src="item.mp3url"></audio>
             <div v-if="item.content">
               <span>{{ item.content }}</span>
               <i class="el-icon-document-copy" @click="copy(item)"></i>
@@ -46,10 +42,16 @@
             <img src="/static/images/aiModel/kefu.png" />
           </div>
           <div class="content">
-            <span v-if="item.type" class="tit">参考意见</span>
-            <span :class="{ high: item.type }" @click="onClick(item)">
-              {{ item.content }}
-            </span>
+            <VueMarkdown
+              v-if="item.type == 'answer'"
+              :source="item.content"
+            ></VueMarkdown>
+            <div v-else>
+              <span v-if="item.data" class="tit">参考意见</span>
+              <span :class="{ high: item.type }" @click="onClick(item)">
+                {{ item.content }}
+              </span>
+            </div>
           </div>
         </div>
       </div>
@@ -99,9 +101,13 @@
 import { AddFzxz } from "../../api/ghss/ghxz.js";
 import { GetMsg, uploadAudio, closeMsg } from "../../api/aiModel.js";
 import record from "./record.js";
+import VueMarkdown from "vue-markdown";
 let recognition = null;
 export default {
   props: {},
+  components: {
+    VueMarkdown,
+  },
   data() {
     return {
       questionList: [],
@@ -229,10 +235,16 @@ export default {
             this.questionList[mindex].mstatus = 2;
             if (mres.data.code == 200 && mres.data.data) {
               if (mres.data.type == "selectLand") {
-                this.questionList.push({ content: "分析中...请稍等" });
+                this.questionList.push({
+                  type: mres.data.type,
+                  content: "分析中...请稍等",
+                });
                 this.AddFzxz(mres.data.data, mres.data.type);
               } else {
-                this.questionList.push({ content: mres.data.data });
+                this.questionList.push({
+                  type: mres.data.type,
+                  content: mres.data.data,
+                });
               }
             } else {
               this.questionList.push({
@@ -276,6 +288,7 @@ export default {
         });
     },
     onClick(item) {
+      if (item.data) return;
       if (item.type == "selectLand") {
         this.$router.push({
           path: "/siteselection",