fix(platform): 合并本地修复到测试环境

This commit is contained in:
HTEWJ\26070045 committed 2026-08-06 17:17:17 +08:00
commit 975e8bbcf5
41 files changed
+4564 -768

No files matched your search

@@ -41,8 +41,13 @@ export function useChatScroll(options: UseChatScrollOptions) {
const stopContainerWatch = watch(container, syncScrollListener, { immediate: true });
/**
* 判断是否显示“回到最新消息”按钮。
* 核心逻辑:只要用户离开底部就提供入口;流式回复只有两条消息时同样需要可恢复跟随。
* @returns 用户是否正在查看历史内容。
*/
const showScrollToBottom = computed(() =>
messages.value.length >= 4 && !isNearBottom.value,
messages.value.length > 0 && !isNearBottom.value,
);
const scrollToBottom = async () => {
@@ -118,9 +123,15 @@ export function useChatScroll(options: UseChatScrollOptions) {
stopContainerWatch();
};
/** 消息/思考态变化时自动滚动(思考结束滚到用户问题,否则贴底) */
/**
* 监听流式消息与会话状态,决定是否继续贴底跟随。
* 核心逻辑:用户在底部时显示最新生成内容;用户手动向上阅读后停止自动滚动,
* 直到其主动点击“回到最新消息”。
* @param isThinking - 当前回复是否仍在生成,用于纳入监听依赖。
* @param conversationId - 当前会话标识,用于在切换会话后重新评估滚动状态。
* @returns 无返回值;监听会在 composable 卸载时自动清理。
*/
const setupThinkingScrollWatch = (isThinking: Ref<boolean>, conversationId?: Ref<string | null>) => {
let wasThinking = false;
watch(
() => ({
messageCount: messages.value.length,
@@ -130,14 +141,14 @@ export function useChatScroll(options: UseChatScrollOptions) {
conversationId: conversationId?.value || '',
}),
() => {
if (wasThinking && !isThinking.value) {
wasThinking = false;
void scrollToUserQuestion();
} else {
if (isThinking.value) wasThinking = true;
if (isNearBottom.value) scheduleScrollToBottom();
else window.requestAnimationFrame(updateNearBottomState);
// [STEP 1] 用户停留在底部时随新内容向下滚动;离开底部后保留阅读位置。
if (isNearBottom.value) {
scheduleScrollToBottom();
return;
}
// [STEP 2] 内容高度变化可能使“接近底部”状态恢复,重新计算但不主动移动视口。
window.requestAnimationFrame(updateNearBottomState);
},
{ deep: false },
);