Browse Source

fix:1.优化选择知识库后聊天被遮挡;2.调整知识库和模型选中的布局

ob-weiwei 1 month ago
parent
commit
8dd95f2918
3 changed files with 21 additions and 13 deletions
  1. 1 8
      src/views/chat/index.vue
  2. 19 4
      src/views/mj/aiGptInput.vue
  3. 1 1
      src/views/mj/aiModel.vue

+ 1 - 8
src/views/chat/index.vue

@@ -651,13 +651,6 @@ load()
 
     <main class="flex-1 overflow-hidden">
 
-      <template v-if="gptConfigStore.myData.kid">
-        <div class="flex  mt-4  text-neutral-300 chat-header">
-           <SvgIcon icon="material-symbols:book" class="mr-1 text-2xl" ></SvgIcon>
-           <span>{{ gptConfigStore.myData.kName }}</span>
-        </div>
-      </template>
-
       <div id="scrollRef" ref="scrollRef" class="h-full overflow-hidden overflow-y-auto">
 
         <div
@@ -756,7 +749,7 @@ load()
         </div>
       </div>
     </main>
-    
+
     <footer :class="footerClass" class="footer-content" v-if="local!=='draw'">
       <div class="w-full max-w-screen-xl m-auto">
         <aiGptInput @handle-clear="handleClear" @export="handleExport" v-if="['gpt-4o-mini','gpt-3.5-turbo-16k'].indexOf(gptConfigStore.myData.model)>-1 || st.inputme "

+ 19 - 4
src/views/mj/aiGptInput.vue

@@ -215,7 +215,6 @@ const paste = (e: ClipboardEvent) => {
 	let rz = getFileFromClipboard(e);
 	if (rz.length > 0) upFile(rz[0]);
 };
-
 const sendMic = (e: any) => {
 	mlog("sendMic", e);
 	st.value.showMic = false;
@@ -279,6 +278,22 @@ const handleSelectASR = (key: string | number) => {
 	if (key == "asr") goASR();
 	if (key == "whisper") st.value.showMic = true;
 };
+/**
+ * 校验字符串的大小
+ * @param inputStr 输入的字符
+ * @param maxLength 字符串长度
+ */
+const truncateText = (inputStr:any, maxLength = 20) => {
+	// 处理空值情况
+	if (!inputStr) return ''
+	// 类型安全校验
+	const str = String(inputStr)
+	// 判断并截断
+	return str.length > maxLength
+		? `${str.slice(0, maxLength)}...`
+		: str
+}
+
 const show = ref(false);
 function handleExport() {
 	emit("export");
@@ -340,9 +355,9 @@ function handleClear() {
 						</template>
 						<template v-else>
 							<SvgIcon icon="heroicons:sparkles" />
-							<span>{{
-								nGptStore.modelLabel ? nGptStore.modelLabel : "gpt-4o-mini"
-							}}</span>
+							<span>模型:{{
+								nGptStore.modelLabel ? truncateText(nGptStore.modelLabel,20) : "gpt-4o-mini"
+							}} {{nGptStore.kid?'知识库:'+truncateText(nGptStore.kName,10):''}}</span>
 						</template>
 						<SvgIcon icon="icon-park-outline:right" />
 					</div>

+ 1 - 1
src/views/mj/aiModel.vue

@@ -52,7 +52,7 @@ const fetchDataGetKnowledge = async () => {
         }));
 
         // 请求成功
-        options.value.push({ label: 'please select', value: '' });
+        options.value.push({ label: '暂不配置', value: '' });
       }
     } catch (error) {
       console.error('Error fetching data:', error);