feat(chat): 更新发货任务处理逻辑和界面文本

- 移除不必要的状态引用
- 更新上传处理提示文本,使用国际化支持
- 扩展发货任务摘要接口,增加错误信息和短缺信息
- 更新多语言支持的文本,改善用户体验
- 增加批次工作区的汇总信息和操作提示
This commit is contained in:
hugo committed 2026-06-29 14:43:27 +08:00
1 parent 0b083cfdbd
commit 1fc9976ca3
60 files changed
+3876 -639

No files matched your search

@@ -1,8 +1,8 @@
/**
* features/chat/composables/useChatScroll.ts
* 聊天主区域滚动:贴底、滚到最新用户问题与思考态切换时的滚动策略。
* 聊天主区域滚动:贴底、滚到最新用户问题、悬浮跳底按钮与思考态切换时的滚动策略。
*/
import { nextTick, watch, type Ref } from 'vue';
import { computed, nextTick, onBeforeUnmount, ref, watch, type Ref } from 'vue';
import type { ChatMessage } from '../types/chat.types';
export interface UseChatScrollOptions {
@@ -13,6 +13,37 @@ export interface UseChatScrollOptions {
export function useChatScroll(options: UseChatScrollOptions) {
const { container, messages } = options;
let scrollToBottomFrame: number | null = null;
let observedContainer: HTMLElement | null = null;
const isNearBottom = ref(true);
const updateNearBottomState = () => {
const el = container.value;
if (!el) {
isNearBottom.value = true;
return;
}
const remaining = el.scrollHeight - el.scrollTop - el.clientHeight;
isNearBottom.value = remaining <= 96;
};
/** 绑定当前滚动容器,容器引用变化时同步换绑监听器。 */
const syncScrollListener = () => {
const nextContainer = container.value;
if (observedContainer === nextContainer) {
updateNearBottomState();
return;
}
observedContainer?.removeEventListener('scroll', updateNearBottomState);
observedContainer = nextContainer;
observedContainer?.addEventListener('scroll', updateNearBottomState, { passive: true });
updateNearBottomState();
};
const stopContainerWatch = watch(container, syncScrollListener, { immediate: true });
const showScrollToBottom = computed(() =>
messages.value.length >= 4 && !isNearBottom.value,
);
const scrollToBottom = async () => {
await nextTick();
@@ -22,6 +53,17 @@ export function useChatScroll(options: UseChatScrollOptions) {
top: el.scrollHeight,
behavior: 'auto',
});
updateNearBottomState();
};
const scrollToBottomSmooth = async () => {
await nextTick();
const el = container.value;
if (!el) return;
el.scrollTo({
top: el.scrollHeight,
behavior: 'smooth',
});
};
const scrollToUserQuestion = async () => {
@@ -60,6 +102,9 @@ export function useChatScroll(options: UseChatScrollOptions) {
window.cancelAnimationFrame(scrollToBottomFrame);
scrollToBottomFrame = null;
}
observedContainer?.removeEventListener('scroll', updateNearBottomState);
observedContainer = null;
stopContainerWatch();
};
/** 消息/思考态变化时自动滚动(思考结束滚到用户问题,否则贴底) */
@@ -79,15 +124,21 @@ export function useChatScroll(options: UseChatScrollOptions) {
void scrollToUserQuestion();
} else {
if (isThinking.value) wasThinking = true;
scheduleScrollToBottom();
if (isNearBottom.value) scheduleScrollToBottom();
else window.requestAnimationFrame(updateNearBottomState);
}
},
{ deep: false },
);
};
onBeforeUnmount(dispose);
return {
isNearBottom,
showScrollToBottom,
scrollToBottom,
scrollToBottomSmooth,
scrollToUserQuestion,
scheduleScrollToBottom,
setupThinkingScrollWatch,