chat请假优化

This commit is contained in:
runny committed 2026-05-12 08:09:50 +08:00
1 parent 84010c25bf
commit 86f07cdd5b
1 file changed
+24 -20
+24 -20
View File
@@ -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);
// 发送完成后刷新历史记录,确保新会话出现