zhangnuoyan 2 年 前
コミット
cc1467be75
2 ファイル変更33 行追加29 行削除
  1. 26 26
      src/components/DialogWrap.vue
  2. 7 3
      src/views/Home.vue

+ 26 - 26
src/components/DialogWrap.vue

@@ -67,23 +67,34 @@
                             <span class="dialog-span">{{ agentInfo.title }}</span>
                         </a-typography-paragraph>
                     </div>
-                    <div class="dialog-footer" v-if="item?.capacity">
+                    <div class="dialog-footer">
                         <div
+                            v-if="type === 'knowledge'"
                             @click="openCapacity(key)"
                             :class="[readonly || item.capacity.status === 'loading' ? 'disabled' : '']"
                         >
                             <a-spin :size="18" v-if="item.capacity.status === 'loading'" />
                             <icon-check-circle-fill :size="18" v-else />
-                            <span>{{ item.capacity.status === "loading" ? "正在调用" : "已调用" }}</span>
-                            <b>{{ item.capacity.text }}</b>
+                            <span>{{ item.capacity.status === "loading" ? "小数正在检索" : "查看检索信息" }}</span>
+                            <!-- <b>{{ item.capacity.text }}</b> -->
                             <icon-caret-right
                                 size="18"
                                 v-if="item.capacity.status === 'loaded' && !menuList[key].open"
                             />
                             <icon-caret-down size="18" v-if="item.capacity.status === 'loaded' && menuList[key].open" />
                         </div>
-                        <section v-if="item.capacity.status === 'loaded'" v-show="menuList[key].open">
-                            <p>{{ item.capacity.data.title }}</p>
+                        <div
+                            v-else
+                            v-show="item.capacity.status === 'loading'"
+                            :class="[readonly || item.capacity.status === 'loading' ? 'disabled' : '']"
+                        >
+                            <a-spin :size="18" />
+                            <span>小数正在为您生成答案...</span>
+                        </div>
+                        <section
+                            v-if="type === 'knowledge' && item.capacity.status === 'loaded'"
+                            v-show="menuList[key].open"
+                        >
                             <div v-if="item.capacity.data.list">
                                 <p v-for="(item, key) in item.capacity.data.list" :key="key">
                                     <a-typography-paragraph
@@ -131,7 +142,9 @@
                                 </div>
                             </div>
                         </section>
-                        <p v-if="item.answer">{{ item.answer }}</p>
+                        <p v-if="item.answer" :style="{ 'margin-top': type === 'knowledge' ? '12px' : '0' }">
+                            {{ item.answer }}
+                        </p>
                     </div>
                     <div class="dialog-other" v-if="item?.other">
                         <p v-if="isSetting">
@@ -194,7 +207,7 @@ export default defineComponent({
     components: {
         DialogFeedback
     },
-    props: ["open", "suggestions", "agentInfo", "userInfo", "isSetting", "readonly"],
+    props: ["open", "suggestions", "agentInfo", "userInfo", "isSetting", "readonly", "type"],
     setup(props, { emit }) {
         const DOCUMENT_RESULT = {
             type: "document",
@@ -251,10 +264,8 @@ export default defineComponent({
                 dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
             }
         };
-        let questionInterval = null;
         let answerInterval = null;
         const stopWriting = () => {
-            window.clearInterval(questionInterval);
             window.clearInterval(answerInterval);
             emit("set-readonly", false);
             if (dialogList[dialogIndex]) {
@@ -271,7 +282,6 @@ export default defineComponent({
             scrollToEnd();
         };
         const mockLink = (text, file = null) => {
-            let num1 = 0;
             let num2 = 0;
             let p1 = text;
             const p2 = `尊敬的领导,
@@ -284,21 +294,12 @@ export default defineComponent({
             let result = { question: "", capacity: null, answer: "", other: null, file: null };
             // 第一步,输入问题
             const step1 = () => {
-                questionInterval = setInterval(() => {
-                    if (num1 < p1.length + 1) {
-                        result.question = p1.slice(0, num1);
-                        num1 += 1;
-                        addData(result);
-                    } else {
-                        window.clearInterval(questionInterval);
-                        // 如果有文件,显示上传文件
-                        if (file) {
-                            result.file = file;
-                            addData(result);
-                        }
-                        step2();
-                    }
-                }, 50);
+                result.question = p1;
+                if (file) {
+                    result.file = file;
+                    addData(result);
+                }
+                step2();
             };
             // 第二步,调用能力
             const step2 = () => {
@@ -488,7 +489,6 @@ export default defineComponent({
     > p {
         color: rgba(16, 16, 16, 1);
         font-size: 14px;
-        margin-top: 16px;
     }
     > div {
         border: 1px solid rgba(64, 95, 234, 0.42);

+ 7 - 3
src/views/Home.vue

@@ -16,7 +16,7 @@
                 <Index :number="swiperNumber" v-if="navIndex === -1" @select-nav="selectNav" />
                 <div class="border-wrap" v-else>
                     <div>
-                        <header>
+                        <header v-if="!showDialog">
                             <div>
                                 <img src="@/assets/other/robot.gif" width="52" />
                                 <p>
@@ -36,6 +36,7 @@
                             <Analysis v-if="navIndex === 7 && !showDialog" />
                             <dialog-wrap
                                 v-if="showDialog"
+                                :type="dialogType[navIndex]"
                                 :agentInfo="data"
                                 :userInfo="userInfo"
                                 :isSetting="false"
@@ -93,6 +94,8 @@ export default defineComponent({
         Analysis
     },
     setup() {
+        // nav对应的问答类型,4文库问答,对应的是knowledge类型
+        const dialogType = ["normal", "normal", "normal", "normal", "knowledge", "normal", "normal", "normal"];
         const { config, helper } = inject("$global");
         const closeOthers = ref(false);
         const swiperNumber = ref(5);
@@ -136,7 +139,7 @@ export default defineComponent({
                 showDialog.value = true;
                 setTimeout(() => {
                     helper.$bus.emit("send-message", value);
-                }, 300);
+                }, 500);
             });
         });
         onBeforeUnmount(() => {
@@ -154,7 +157,8 @@ export default defineComponent({
             showDialog,
             selectHistory,
             closeOthers,
-            openAll
+            openAll,
+            dialogType
         };
     }
 });