fix: 隐藏文件上传按钮,去除不必要的log打印
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<!-- 默认消息列表页 -->
|
||||
<script setup lang="ts">
|
||||
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
||||
import FilesSelect from '@/components/FilesSelect/index.vue';
|
||||
import ModelSelect from '@/components/ModelSelect/index.vue';
|
||||
import WelecomeText from '@/components/WelecomeText/index.vue';
|
||||
import { useUserStore } from '@/stores';
|
||||
@@ -97,7 +96,7 @@ watch(
|
||||
</template>
|
||||
<template #prefix>
|
||||
<div class="flex-1 flex items-center gap-8px flex-none w-fit overflow-hidden">
|
||||
<FilesSelect />
|
||||
<!-- <FilesSelect /> -->
|
||||
<ModelSelect />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -6,17 +6,18 @@ import type { BubbleProps } from 'vue-element-plus-x/types/Bubble';
|
||||
import type { BubbleListInstance } from 'vue-element-plus-x/types/BubbleList';
|
||||
import type { FilesCardProps } from 'vue-element-plus-x/types/FilesCard';
|
||||
import type { ThinkingStatus } from 'vue-element-plus-x/types/Thinking';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
||||
import { ElIcon, ElMessage } from 'element-plus';
|
||||
import { useHookFetch } from 'hook-fetch/vue';
|
||||
import { ref } from 'vue';
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { send } from '@/api';
|
||||
import FilesSelect from '@/components/FilesSelect/index.vue';
|
||||
import ModelSelect from '@/components/ModelSelect/index.vue';
|
||||
import { useChatStore } from '@/stores/modules/chat';
|
||||
import { useFilesStore } from '@/stores/modules/files';
|
||||
import { useModelStore } from '@/stores/modules/model';
|
||||
import { useUserStore } from '@/stores/modules/user';
|
||||
import { systemProfilePicture, userProfilePicture } from '@/utils/user.ts';
|
||||
import '@/styles/github-markdown.css';
|
||||
import '@/styles/yixin-markdown.scss';
|
||||
|
||||
@@ -61,6 +62,7 @@ const { stream, loading: isLoading, cancel } = useHookFetch({
|
||||
userStore.openLoginDialog();
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
// 记录进入思考中
|
||||
let isThinking = false;
|
||||
@@ -121,7 +123,6 @@ function handleDataChunk(chunk: AnyObject) {
|
||||
|
||||
// 另一种思考中形式,content中有 <think></think> 的格式
|
||||
// 一开始匹配到 <think> 开始,匹配到 </think> 结束,并处理标签中的内容为思考内容
|
||||
console.log(chunk.choices, 'chunk.choices');
|
||||
const parsedChunk = chunk.choices?.[0].delta.content;
|
||||
if (parsedChunk) {
|
||||
const thinkStart = parsedChunk.includes('<think>');
|
||||
@@ -166,8 +167,6 @@ function handleError(err: any) {
|
||||
|
||||
async function startSSE(chatContent: string) {
|
||||
try {
|
||||
// 添加用户输入的消息
|
||||
// console.log('chatContent', chatContent);
|
||||
// 清空输入框
|
||||
inputValue.value = '';
|
||||
addMessage(chatContent, true);
|
||||
@@ -176,23 +175,14 @@ async function startSSE(chatContent: string) {
|
||||
// 这里有必要调用一下 BubbleList 组件的滚动到底部 手动触发 自动滚动
|
||||
bubbleListRef.value?.scrollToBottom();
|
||||
|
||||
console.log('bubbleItems.value--', bubbleItems.value);
|
||||
// 使用 for-await 处理流式响应
|
||||
for await (const chunk of stream({
|
||||
// messages: bubbleItems.value
|
||||
// .filter((item: any) => item.role === 'user')
|
||||
// .map((item: any) => ({
|
||||
// role: item.role,
|
||||
// content: item.content,
|
||||
// })),
|
||||
messages: bubbleItems.value
|
||||
.slice(0, -1) // 去掉最后1条(即排除最新那条)
|
||||
.slice(-6) // 然后取倒数第2到第7条(总共6条)
|
||||
.map((item: MessageItem) => ({
|
||||
role: item.role,
|
||||
content: (item.role === 'ai' || item.role === 'assistant') && item.content.length > 2000
|
||||
? `${item.content.substring(0, 2000)}...(内容过长,已省略)`
|
||||
: item.content,
|
||||
})),
|
||||
messages: bubbleItems.value.slice(0, -1).slice(-6).map((item: MessageItem) => ({
|
||||
role: item.role,
|
||||
content: (item.role === 'ai' || item.role === 'assistant') && item.content.length > 2000
|
||||
? `${item.content.substring(0, 2000)}...(内容过长,已省略)`
|
||||
: item.content,
|
||||
})),
|
||||
sessionId: route.params?.id !== 'not_login' ? String(route.params?.id) : undefined,
|
||||
userId: userStore.userInfo?.userId,
|
||||
model: modelStore.currentModelInfo.modelId ?? '',
|
||||
@@ -201,11 +191,14 @@ async function startSSE(chatContent: string) {
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log('33---');
|
||||
handleError(err);
|
||||
if (err.name === 'AbortError') {
|
||||
console.log('用户中止请求'); // 正常中止,无需提示
|
||||
}
|
||||
else {
|
||||
handleError(err); // 其他错误
|
||||
}
|
||||
}
|
||||
finally {
|
||||
console.log('数据接收完毕');
|
||||
// 停止打字器状态
|
||||
if (bubbleItems.value.length) {
|
||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||
@@ -215,10 +208,14 @@ async function startSSE(chatContent: string) {
|
||||
|
||||
// 中断请求
|
||||
async function cancelSSE() {
|
||||
cancel();
|
||||
// 结束最后一条消息打字状态
|
||||
if (bubbleItems.value.length) {
|
||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||
try {
|
||||
cancel(); // 直接调用,无需参数
|
||||
if (bubbleItems.value.length) {
|
||||
bubbleItems.value[bubbleItems.value.length - 1].typing = false;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
handleError(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,8 +225,8 @@ function addMessage(message: string, isUser: boolean) {
|
||||
const obj: MessageItem = {
|
||||
key: i,
|
||||
avatar: isUser
|
||||
? avatar.value
|
||||
: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
? userProfilePicture
|
||||
: systemProfilePicture,
|
||||
avatarSize: '32px',
|
||||
role: isUser ? 'user' : 'assistant',
|
||||
placement: isUser ? 'end' : 'start',
|
||||
@@ -269,7 +266,6 @@ watch(
|
||||
);
|
||||
|
||||
function markdownContent(item: any) {
|
||||
console.log('item---', item);
|
||||
return item.content;
|
||||
}
|
||||
</script>
|
||||
@@ -305,9 +301,9 @@ function markdownContent(item: any) {
|
||||
class="prev-next-btn left-8px flex-center w-22px h-22px rounded-8px border-1px border-solid border-[rgba(0,0,0,0.08)] c-[rgba(0,0,0,.4)] hover:bg-#f3f4f6 bg-#fff font-size-10px"
|
||||
@click="onScrollLeft"
|
||||
>
|
||||
<el-icon>
|
||||
<ElIcon>
|
||||
<ArrowLeftBold />
|
||||
</el-icon>
|
||||
</ElIcon>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -317,9 +313,9 @@ function markdownContent(item: any) {
|
||||
class="prev-next-btn right-8px flex-center w-22px h-22px rounded-8px border-1px border-solid border-[rgba(0,0,0,0.08)] c-[rgba(0,0,0,.4)] hover:bg-#f3f4f6 bg-#fff font-size-10px"
|
||||
@click="onScrollRight"
|
||||
>
|
||||
<el-icon>
|
||||
<ElIcon>
|
||||
<ArrowRightBold />
|
||||
</el-icon>
|
||||
</ElIcon>
|
||||
</div>
|
||||
</template>
|
||||
</Attachments>
|
||||
@@ -327,7 +323,7 @@ function markdownContent(item: any) {
|
||||
</template>
|
||||
<template #prefix>
|
||||
<div class="flex-1 flex items-center gap-8px flex-none w-fit overflow-hidden">
|
||||
<FilesSelect />
|
||||
<!-- <FilesSelect /> -->
|
||||
<ModelSelect />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user