liuqiang 1 anno fa
parent
commit
f42e5ed45d

+ 5 - 0
src/layout/NewIndex.vue

@@ -7,6 +7,7 @@
       :hasRole="hasRole"
     ></TopMenu>
     <DefaultPage
+    ref="defaultpage"
       :showSearch="showSearch"
       :hightData="hightData"
       :allData="allData"
@@ -61,6 +62,8 @@ const tableFileData = ref([]);
 const highEnd = ref(true);
 const allEnd = ref(true);
 
+const defaultpage = ref(null);
+
 // 将标签信息保存到本地
 const openMaxmin = (title, path) => {
   const item = {
@@ -227,6 +230,8 @@ const iframeSize = (id) => {
 // 点击logo回到主页
 const goIndex = () => {
   showSearch.value = false;
+  
+  defaultpage.value.clearSearchText();
 };
 
 // 页面刷新后清除标签

+ 16 - 3
src/layout/components/AIPage/AIPage.vue

@@ -30,7 +30,7 @@
               <span v-else>{{ userInfo.name }}</span>
             </div>
             <div class="chat" :class="{ botChat: item.role == 'assistant' }">
-              <span v-html="item.content"></span>
+              <span style="white-space: pre-wrap;" v-html="item.content"></span>
             </div>
           </template>
         </div>
@@ -41,8 +41,9 @@
           style="width: 90%"
           :autosize="{ minRows: 2, maxRows: 5 }"
           type="textarea"
-          placeholder="请在此输入关键词"
-          @keyup.enter="enterChat"
+          placeholder="请在此输入关键词,按 Ctrl+Enter 换行"
+
+          @keydown="handleKeyCode($event)"
         />
         <div class="chatBtn">
           <img :src="send" class="send-info" @click="enterChat" />
@@ -86,6 +87,17 @@ const baseMsgList = [
 // 这里的数值可能需要根据实际的CSS调整
 const baseInputHeight = 52;
 const maxInputHeight = 115;
+const handleKeyCode = (event)=>{
+  if (event.keyCode == 13) {
+    if (!event.ctrlKey) {
+      event.preventDefault();
+      enterChat();
+    } else {
+      iptText.value += '\n';
+      console.log('enter');
+    }
+  }
+}
 const enterChat =async () => {
   if (disabled.value) return;
   disabled.value = true;
@@ -107,6 +119,7 @@ const enterChat =async () => {
     query = [baseMsgList[0], ...longArr]
   }
   query = query.map((item) => {
+    if(item.role == "user") return item
     return {
       role: item.role,
       content: item.content.replace(/&lt;/gi, "")

+ 8 - 0
src/layout/components/DefaultPage/DefaultPage.vue

@@ -576,6 +576,13 @@ function formatFileSize(fileSize) {
     return fileSize + "B";
   }
 }
+const clearSearchText = ()=>{
+  searchText.value = '';
+}
+//暴露clearSearchText方法
+defineExpose({
+  clearSearchText
+});
 watchEffect(() => {
   if (props.showSearch) {
     isSearch.value = true;
@@ -646,6 +653,7 @@ watch(
   }
 );
 onMounted(() => {
+  console.log('mounted');
   getSpaceList();
   getDirId();
   getConfigKey("file.size.limit").then((response) => {