Merge upstream main and resolve conflicts
This commit is contained in:
@@ -1000,9 +1000,15 @@ const handleCitationActivate = (el: HTMLElement) => {
|
||||
const url = el.getAttribute('data-url');
|
||||
if (!url) return;
|
||||
try {
|
||||
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
||||
if (!newWindow) {
|
||||
window.location.assign(url);
|
||||
// @ts-ignore: Wails runtime check
|
||||
if (window.runtime && window.runtime.BrowserOpenURL) {
|
||||
// @ts-ignore
|
||||
window.runtime.BrowserOpenURL(url);
|
||||
} else {
|
||||
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
||||
if (!newWindow) {
|
||||
window.location.assign(url);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
window.location.assign(url);
|
||||
@@ -1200,10 +1206,8 @@ const onRootClick = (e: Event) => {
|
||||
// Handle web citation clicks
|
||||
const webEl = target.closest?.('.citation-web') as HTMLElement | null;
|
||||
if (webEl && webEl.getAttribute('data-url')) {
|
||||
if (!(webEl instanceof HTMLAnchorElement)) {
|
||||
e.preventDefault();
|
||||
handleCitationActivate(webEl);
|
||||
}
|
||||
e.preventDefault();
|
||||
handleCitationActivate(webEl);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1223,6 +1227,18 @@ const onRootClick = (e: Event) => {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle generic a clicks (especially in Wails desktop)
|
||||
const aEl = target.closest?.('a') as HTMLAnchorElement | null;
|
||||
// @ts-ignore
|
||||
if (aEl && aEl.href && window.runtime && window.runtime.BrowserOpenURL) {
|
||||
if (aEl.href.startsWith('http://') || aEl.href.startsWith('https://')) {
|
||||
e.preventDefault();
|
||||
// @ts-ignore
|
||||
window.runtime.BrowserOpenURL(aEl.href);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onRootKeydown = (e: KeyboardEvent) => {
|
||||
@@ -1233,15 +1249,8 @@ const onRootKeydown = (e: KeyboardEvent) => {
|
||||
const webEl = target.closest?.('.citation-web') as HTMLElement | null;
|
||||
if (webEl) {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
if (webEl instanceof HTMLAnchorElement && e.key === 'Enter') {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
if (webEl instanceof HTMLAnchorElement) {
|
||||
webEl.click();
|
||||
} else {
|
||||
handleCitationActivate(webEl);
|
||||
}
|
||||
handleCitationActivate(webEl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -259,19 +259,17 @@ const getWebSearchDisplayText = (item) => {
|
||||
line-height: 20px;
|
||||
padding: 2px 0;
|
||||
transition: all 0.2s ease;
|
||||
border-bottom: 1px solid transparent;
|
||||
border-bottom: 1px dashed var(--td-brand-color);
|
||||
|
||||
&:hover {
|
||||
border-bottom-color: var(--td-brand-color);
|
||||
background-color: rgba(7, 192, 95, 0.08);
|
||||
border-radius: 3px;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
&.doc-web {
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,33 @@
|
||||
<div class="chat">
|
||||
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
|
||||
<div class="msg_list">
|
||||
<!-- 消息列表骨架屏 -->
|
||||
<div v-if="historyLoading && messagesList.length === 0" class="msg-skeleton-list">
|
||||
<div class="msg-skeleton msg-skeleton-user">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '45%', height: '36px', type: 'rect' }]" />
|
||||
</div>
|
||||
<div class="msg-skeleton msg-skeleton-bot">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '16px' }, { width: '100%', height: '16px' }, { width: '60%', height: '16px' }]" />
|
||||
</div>
|
||||
<div class="msg-skeleton msg-skeleton-user">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '35%', height: '36px', type: 'rect' }]" />
|
||||
</div>
|
||||
<div class="msg-skeleton msg-skeleton-bot">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '70%', height: '16px' }, { width: '90%', height: '16px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 推荐问题卡片 - 仅在新会话(无消息)时展示 -->
|
||||
<div v-if="messagesList.length === 0 && !loading" class="suggested-questions-container" :class="{ 'has-questions': suggestedQuestions.length > 0 }">
|
||||
<transition name="sq-fade">
|
||||
<div v-if="messagesList.length === 0 && !loading" class="suggested-questions-container" :class="{ 'has-questions': suggestedQuestions.length > 0 || suggestedQuestionsLoading }">
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="suggestedQuestionsLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
|
||||
<div class="suggested-questions-title"><t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '18px' }]" /></div>
|
||||
<div class="suggested-questions-grid">
|
||||
<div v-for="n in 6" :key="'sq-skel-'+n" class="suggested-question-card sq-card-skeleton">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '90%', height: '14px' }, { width: '60%', height: '14px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<transition v-else appear name="sq-fade">
|
||||
<div v-if="suggestedQuestions.length > 0" class="suggested-questions-inner">
|
||||
<div class="suggested-questions-title">{{ t('chat.suggestedQuestions') }}</div>
|
||||
<div class="suggested-questions-grid">
|
||||
@@ -40,6 +64,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<transition name="scroll-btn-fade">
|
||||
<div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
|
||||
<t-icon name="chevron-down" size="20px" />
|
||||
</div>
|
||||
</transition>
|
||||
<div style="min-height: 115px; margin: 16px auto 4px;width: 100%;max-width: 800px;">
|
||||
<InputField
|
||||
ref="inputFieldRef"
|
||||
@@ -98,9 +127,19 @@ const scrollLock = ref(false);
|
||||
const isNeedTitle = ref(false);
|
||||
const isFirstEnter = ref(true);
|
||||
const loading = ref(false);
|
||||
const historyLoading = ref(true);
|
||||
let fullContent = ref('')
|
||||
let userquery = ref('')
|
||||
const scrollContainer = ref(null)
|
||||
const userHasScrolledUp = ref(false)
|
||||
const SCROLL_BOTTOM_THRESHOLD = 80
|
||||
|
||||
const isNearBottom = () => {
|
||||
if (!scrollContainer.value) return true;
|
||||
const { scrollTop, scrollHeight, clientHeight } = scrollContainer.value;
|
||||
return scrollHeight - scrollTop - clientHeight < SCROLL_BOTTOM_THRESHOLD;
|
||||
}
|
||||
|
||||
const handleKBEditorSuccess = (kbId) => {
|
||||
navigateToKnowledgeBaseList(kbId)
|
||||
}
|
||||
@@ -198,10 +237,12 @@ watch([() => route.params], (newvalue) => {
|
||||
messagesList.splice(0);
|
||||
session_id.value = newvalue[0].chatid;
|
||||
|
||||
// 切换会话时,重置状态(加载历史消息不应显示loading)
|
||||
// 切换会话时,重置状态
|
||||
historyLoading.value = true;
|
||||
loading.value = false;
|
||||
isReplying.value = false;
|
||||
currentAssistantMessageId.value = '';
|
||||
userHasScrolledUp.value = false;
|
||||
|
||||
checkmenuTitle(session_id.value)
|
||||
let data = {
|
||||
@@ -212,13 +253,18 @@ watch([() => route.params], (newvalue) => {
|
||||
getmsgList(data);
|
||||
}
|
||||
});
|
||||
const scrollToBottom = () => {
|
||||
const scrollToBottom = (force = false) => {
|
||||
if (!force && userHasScrolledUp.value) return;
|
||||
nextTick(() => {
|
||||
if (scrollContainer.value) {
|
||||
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
|
||||
}
|
||||
})
|
||||
}
|
||||
const onClickScrollToBottom = () => {
|
||||
userHasScrolledUp.value = false;
|
||||
scrollToBottom(true);
|
||||
}
|
||||
const debounce = (fn, delay) => {
|
||||
let timer
|
||||
return (...args) => {
|
||||
@@ -239,7 +285,11 @@ const onChatScrollTop = () => {
|
||||
getmsgList(data, true, scrollHeight);
|
||||
}
|
||||
}
|
||||
const handleScroll = debounce(onChatScrollTop, 500);
|
||||
const debouncedScrollTop = debounce(onChatScrollTop, 500);
|
||||
const handleScroll = () => {
|
||||
userHasScrolledUp.value = !isNearBottom();
|
||||
debouncedScrollTop();
|
||||
};
|
||||
|
||||
const getmsgList = (data, isScrollType = false, scrollHeight) => {
|
||||
getMessageList(data).then(res => {
|
||||
@@ -247,6 +297,8 @@ const getmsgList = (data, isScrollType = false, scrollHeight) => {
|
||||
created_at.value = res.data[0].created_at;
|
||||
handleMsgList(res.data, isScrollType, scrollHeight);
|
||||
}
|
||||
}).finally(() => {
|
||||
historyLoading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
@@ -381,7 +433,7 @@ const handleMsgList = async (data, isScrollType = false, newScrollHeight) => {
|
||||
}
|
||||
messagesList.unshift(item);
|
||||
if (isFirstEnter.value) {
|
||||
scrollToBottom();
|
||||
scrollToBottom(true);
|
||||
} else if (isScrollType) {
|
||||
nextTick(() => {
|
||||
const { scrollHeight } = scrollContainer.value;
|
||||
@@ -473,8 +525,9 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
|
||||
}
|
||||
|
||||
// 将@提及的知识库和文件信息存入用户消息
|
||||
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, attachments: attachmentFiles.map(a => ({ file_name: a.name, file_size: a.size, file_type: '.' + a.name.split('.').pop()?.toLowerCase() })), channel: 'web' });
|
||||
scrollToBottom();
|
||||
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, attachments: attachmentFiles.map(a => ({ file_name: a.name, file_size: a.size, file_type: '.' + a.name.split('.').pop()?.toLowerCase() })), channel: 'web' });
|
||||
userHasScrolledUp.value = false;
|
||||
scrollToBottom(true);
|
||||
|
||||
// Get agent mode status from settings store
|
||||
const agentEnabled = useSettingsStoreInstance.isAgentEnabled;
|
||||
@@ -637,7 +690,7 @@ onChunk((data) => {
|
||||
};
|
||||
messagesList.push(existingMessage);
|
||||
loading.value = false; // 消息已创建,关闭 loading
|
||||
scrollToBottom();
|
||||
scrollToBottom(true);
|
||||
}
|
||||
|
||||
existingMessage.knowledge_references = data.knowledge_references || data.data?.references || [];
|
||||
@@ -739,7 +792,7 @@ const handleAgentChunk = (data) => {
|
||||
};
|
||||
messagesList.push(newMsg);
|
||||
loading.value = false; // 消息已创建,关闭 loading
|
||||
scrollToBottom();
|
||||
scrollToBottom(true);
|
||||
// Don't return - continue to process the current event data
|
||||
message = newMsg;
|
||||
}
|
||||
@@ -1110,7 +1163,8 @@ onMounted(async () => {
|
||||
checkmenuTitle(session_id.value)
|
||||
if (firstQuery.value) {
|
||||
scrollLock.value = true;
|
||||
sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || [], firstAttachmentFiles.value || []);
|
||||
historyLoading.value = false;
|
||||
sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || [], firstAttachmentFiles.value || []);
|
||||
usemenuStore.changeFirstQuery('', [], '', [], []);
|
||||
} else {
|
||||
scrollLock.value = false;
|
||||
@@ -1179,6 +1233,45 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
.scroll-to-bottom-btn {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
bottom: 140px;
|
||||
z-index: 10;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-primary);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateX(-50%) scale(0.92);
|
||||
}
|
||||
}
|
||||
|
||||
.scroll-btn-fade-enter-active,
|
||||
.scroll-btn-fade-leave-active {
|
||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
.scroll-btn-fade-enter-from,
|
||||
.scroll-btn-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(8px);
|
||||
}
|
||||
|
||||
.agent-mode-indicator {
|
||||
display: flex;
|
||||
@@ -1204,6 +1297,30 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.msg-skeleton-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
max-width: 800px;
|
||||
padding: 16px 0;
|
||||
animation: contentFadeIn 0.3s ease-out;
|
||||
}
|
||||
.msg-skeleton-user {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.msg-skeleton-bot {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.msg_list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1276,6 +1393,7 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
animation: contentFadeIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
.sq-fade-enter-active,
|
||||
|
||||
Reference in New Issue
Block a user