zhuliu 7 tháng trước cách đây
mục cha
commit
561b0cfd88

BIN
src/assets/img/小世AI.png


+ 75 - 20
src/utils/model/AIChat/AIChatBox.vue

@@ -8,7 +8,7 @@
           <div v-if="isLoading && message === currentStreamingMessage && message.type === 'ai'"  class="message-loading">
             <i class="el-icon-loading"></i>
           </div>
-          <div v-if="message.type === 'ai'" class="message-actions">
+          <!-- <div v-if="message.type === 'ai'" class="message-actions">
             <template v-if="message === currentStreamingMessage">
               <el-button  
                   type="text"
@@ -29,7 +29,7 @@
               </el-button>
             </template>
             
-          </div>
+          </div> -->
           <!-- <div class="content-text">{{ message.isTyping ? message.displayContent : message.content }}</div> -->
           <!-- <div class="content-text markdown-body" 
                v-html="message.isTyping ? 
@@ -58,7 +58,30 @@
                 </div>
             </template>
           </div>
-          <div class="message-time">{{ message.timestamp }}</div>
+          <div class="message-time">
+            {{ message.timestamp }}
+            <span v-if="message.type === 'ai'">
+              <template v-if="message === currentStreamingMessage">
+                <el-button  
+                    type="text"
+                      @click="stopGeneration" 
+                      title="停止生成">
+                  停止生成
+                </el-button>
+              </template>
+              <template v-else>
+                <el-button type="text" @click="copyMessage(message.content)" title="复制">
+                  <i class="el-icon-document-copy"></i>
+                </el-button>
+                <el-button type="text"
+                        @click="regenerateResponse(index)" 
+                        title="重新生成"
+                        :disabled="isLoading">
+                  <i class="el-icon-refresh"></i>
+                </el-button>
+              </template>
+            </span>
+          </div>
         </div>
       </div>
     </div>
@@ -75,11 +98,12 @@
       </select>
       
       <div class="input-group">
-        <input type="text" 
+        <el-input type="textarea" autosize resize="none"
                v-model="userInput" 
-               @keyup.enter="sendMessage"
-               placeholder="输入您的问题...">
-        <button @click="sendMessage" :disabled="isLoading">发送</button>
+               @keydown.native="handleKeyCode($event)"
+              placeholder="请输入您想问的内容,按 Ctrl+Enter 换行"
+        />
+        <el-button type="primary" size="small" class="margin-left_10" @click="sendMessage" :disabled="isLoading">发送</el-button>
       </div>
     </div>
   </div>
@@ -183,12 +207,17 @@ export default {
   },
   
   watch: {
-    chatHistory: {
-      handler(newVal) {
-        // 保存到 localStorage
-        localStorage.setItem('chatHistory', JSON.stringify(newVal))
-      },
-      deep: true
+    // chatHistory: {
+    //   handler(newVal) {
+    //     // 保存到 localStorage
+    //     localStorage.setItem('chatHistory', JSON.stringify(newVal))
+    //   },
+    //   deep: true
+    // },
+    isLoading(val,oldVal){
+      if(oldVal && !val){
+        localStorage.setItem('chatHistory', JSON.stringify(this.chatHistory))
+      }
     },
     selectedQuestion(val) {
       if (val) {
@@ -221,6 +250,17 @@ export default {
   },
   
   methods: {
+    //键盘按下事件
+    handleKeyCode(event) {
+      if (event.keyCode == 13) {
+          if (!event.ctrlKey) {
+              event.preventDefault();
+              this.sendMessage()
+            } else {
+              this.userInput += "\n";
+            }
+          }
+    },
     //发送信息
     async sendMessage() {
       if (!this.userInput.trim()) return;
@@ -553,14 +593,23 @@ export default {
   }
 }
 </script>
-
-<style scoped>
+<style lang="scss">
+  .chat-container{
+    .user{
+      .markdown-body{
+        background: #007bff !important;
+        color: white !important;
+      }
+    }
+  }
+</style>
+<style lang="scss" scoped>
 .chat-container {
   width: 100%;
   max-width: 600px;
   margin: 0 auto;
-  border: 1px solid #ddd;
-  border-radius: 8px;
+  /* border: 1px solid #ddd;
+  border-radius: 8px; */
   overflow: hidden;
 }
 
@@ -568,7 +617,7 @@ export default {
   height: 400px;
   overflow-y: auto;
   padding: 20px;
-  background: #f5f5f5;
+  /* background: #f5f5f5; */
   scroll-behavior: smooth; 
 }
 
@@ -582,6 +631,9 @@ export default {
   /* margin-left: auto; */
   display: flex;
   flex-direction: row-reverse;
+  .message-time{
+    color: rgb(212, 208, 208);
+  }
 }
 
 .message-content {
@@ -596,8 +648,8 @@ export default {
 }
 
 .user .message-content {
-  /* background: #007bff; */
-  background: white;
+  background: #007bff;
+  /* background: white; */
   color: white;
 }
 
@@ -613,6 +665,7 @@ export default {
 
 .input-group {
   display: flex;
+  align-items: flex-end;
   margin-top: 10px;
 }
 
@@ -654,6 +707,8 @@ button:hover {
   font-size: 0.8em;
   color: #999;
   margin-top: 4px;
+  display: flex;
+  align-items: center;
 }
 
 /* 添加一个清空历史记录的按钮样式 */

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 131 - 0
src/views/components/PatentAI/index.vue


+ 0 - 1
src/views/home/index.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="home">
     <div class="main">
-      <AIChatBox></AIChatBox>
       <div class="carousel" id="step1">
         <carousel></carousel>
       </div>

+ 8 - 1
src/views/project/patentDetails/index.vue

@@ -19,6 +19,10 @@
     </div>
     <teamwork ref="teamwork" :patentNo="patentNo" :projectId="projectId" :reportType="reportType"></teamwork>
     <inventionPointDialog v-if="noveltySearch" :projectId="projectId" :retrieveRecordId="retrieveRecordId" :contrastFileList="saveRemarkList"></inventionPointDialog>
+
+
+    <!-- 专利ai -->
+    <PatentAI></PatentAI>
   </div>
 </template>
 
@@ -30,13 +34,16 @@ import teamwork from '@/views/report/components/dialog/teamwork.vue'
 import notPatentDetails from './components/notPatentDetails.vue'
 import {mapGetters} from 'vuex'
 import {getLastRoute} from '@/router'
+
+import PatentAI from "@/views/components/PatentAI/index.vue"
 export default {
   components: {
     articleMenu,
     PatentDetails,
     tortContrast,
     teamwork,
-    notPatentDetails
+    notPatentDetails,
+    PatentAI
   },
   props: {},
   data() {