diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index 59b2a1c9..000d4695 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -569,9 +569,28 @@ const syncLeaveDuration = (form: LeaveRequestFormData) => { const getLeaveIntentNormalized = (content: string) => (content || '').replace(/\s+/g, ''); -const isLeaveIntent = (content: string) => { +const isStrongLeaveIntent = (content: string) => { const normalized = getLeaveIntentNormalized(content); - return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|我要走请假流程|请假流程)/.test(normalized); + return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|我要走请假流程)/.test(normalized); +}; + +const startLocalLeaveFlow = (content: string) => { + const formId = newLocalMessageId('leave-form'); + const payload: LeaveFormPayload = { + formId, + form: createLeaveFormData(), + submitting: false, + confirmationGenerated: false, + }; + messages.value.push({ role: 'user', content, type: 'text' }); + messages.value.push({ + role: 'assistant', + type: 'leave-form', + content: '已为你生成请假申请表,请直接在下方填写并提交。', + payload, + local_id: formId, + local_only: true, + }); }; const getLeaveFormPayload = (msg: any): LeaveFormPayload | null => ( @@ -726,26 +745,11 @@ const handleSend = async (textOrEvent?: string | Event) => { // Clear input if sending from input box (not resending/regenerating) if (typeof textOrEvent !== 'string') input.value = ''; - if (isLeaveIntent(content)) { - const formId = newLocalMessageId('leave-form'); - const payload: LeaveFormPayload = { - formId, - form: createLeaveFormData(), - submitting: false, - confirmationGenerated: false, - }; - messages.value.push({ role: 'user', content, type: 'text' }); - messages.value.push({ - role: 'assistant', - type: 'leave-form', - content: '已为你生成请假申请表,请直接在下方填写并提交。', - payload, - local_id: formId, - local_only: true, - }); + if (isStrongLeaveIntent(content)) { + startLocalLeaveFlow(content); return; } - + await sendMessage(content, agentId, selectedKb.value); // 发送完成后刷新历史记录,确保新会话出现