feat(chat): 完善附件预览与订单提取交互
- 优化聊天附件上传、预览及 PDF.js 加载 - 完善订单文档画布与审核预览体验 - 优化订单提取运行状态及发送流程 - 增强会话附件接口与相关测试覆盖 - 更新 Nginx 配置、技术文档及四语言文案
This commit is contained in:
1 parent
104afa3844
commit
9d2fa522fa
29 files changed
+584
-140
No files matched your search
@@ -4,6 +4,7 @@
|
||||
* 依赖:统一 BusinessError、剪贴板工具、Chat 消息与附件参数类型。
|
||||
* 逻辑:附件上传成功后调用 Dify SSE;仅在消息发送成功后清空附件,失败时保留供重试。
|
||||
* 兼容:依次处理货代附件、采购合同、请假与货代文本前置拦截。
|
||||
* 货代路径另受 hasBlockingNoticeIntake / isOrderExtractionSubmitting 约束 canSendMessage。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
@@ -83,10 +84,26 @@ export interface ChatPageSendContext {
|
||||
copiedIndex: Ref<number | null>;
|
||||
getChatContext?: () => { task_id?: string; shipping_temporary_inventory_asset_no?: string; shipping_temporary_inventory_session_no?: string; display_query?: string };
|
||||
onAssistantMessageFinished?: (message: ChatMessage, runMessages: ChatMessage[]) => void | Promise<void>;
|
||||
/** 货代 Intake 仍在上传/解析时返回 true,用于早禁用发送。 */
|
||||
hasBlockingNoticeIntake?: () => boolean;
|
||||
/** 订单抽取统一提交进行中;为 true 时禁用发送并展示 Loader。 */
|
||||
isOrderExtractionSubmitting?: Ref<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装聊天页发送 API:canSendMessage / handleSend / 复制 / 重新生成。
|
||||
* 核心逻辑:货代 blocking/submitting 优先禁用;附件失败保留、成功后清空。
|
||||
* @param ctx - 页面发送所需的响应式状态与业务钩子。
|
||||
* @returns 发送相关计算属性与方法。
|
||||
*/
|
||||
export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
/**
|
||||
* 是否允许点击发送。
|
||||
* 核心逻辑:上传中、订单抽取提交中、或 Intake 阻塞解析时一律 false;其余沿用输入/附件/thinking 规则。
|
||||
*/
|
||||
const canSendMessage = computed(() => {
|
||||
if (ctx.isOrderExtractionSubmitting?.value) return false;
|
||||
if (ctx.hasBlockingNoticeIntake?.()) return false;
|
||||
const allowSendWhileThinking = canContinueSendWhileThinking(ctx.messages.value);
|
||||
if (ctx.isUploadingAttachments.value) return false;
|
||||
if (ctx.input.value.trim()) return !ctx.isThinking.value || allowSendWhileThinking;
|
||||
@@ -99,11 +116,19 @@ export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 处理发送:依次尝试货代附件自动流、采购合同、请假、货代文本,否则走通用 SSE。
|
||||
* @param textOrEvent - 可选字符串覆盖输入框内容,或来自 UI 事件。
|
||||
*/
|
||||
const handleSend = async (textOrEvent?: string | Event) => {
|
||||
const content = (typeof textOrEvent === 'string' ? textOrEvent : null) || ctx.input.value;
|
||||
const trimmed = content.trim();
|
||||
const hasAttachments = ctx.attachmentPolicy.value.anyEnabled && ctx.attachments.value.length > 0;
|
||||
const allowSendWhileThinking = canContinueSendWhileThinking(ctx.messages.value);
|
||||
// [STEP 0] 提交中禁止重复触发(含 Enter);Intake 阻塞仍交给货代 handler 提示,不在此静默吞掉。
|
||||
if (ctx.isOrderExtractionSubmitting?.value) {
|
||||
return;
|
||||
}
|
||||
if (await ctx.tryHandleShippingAttachmentAutoFlow(textOrEvent, content, trimmed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user