From 8a9c14463762a03189a9b5c0bb8b5584841ac56e Mon Sep 17 00:00:00 2001 From: wandering Date: Thu, 2 Jul 2026 18:45:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E5=86=8D=E8=87=AA=E5=8A=A8=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E9=9C=80=E7=94=A8=E6=88=B7=E5=8F=91=E9=80=81'?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=BC=80=E5=A7=8B'=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - upload.js/sync.js: 移除 checkAutoStart() 自动调用 - config.js: promptMissingConfig 提示用户手动触发;sendUserMessage 识别'可以开始'等指令 - index.html: 更新欢迎消息 --- src/web/static/js/config.js | 49 ++++++++++++++++-------------------- src/web/static/js/sync.js | 2 -- src/web/static/js/upload.js | 4 +-- src/web/templates/index.html | 2 +- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/web/static/js/config.js b/src/web/static/js/config.js index 5341623..4c7f45f 100644 --- a/src/web/static/js/config.js +++ b/src/web/static/js/config.js @@ -17,34 +17,33 @@ export const CONFIG_FIELDS = { /** * 静默检查:仅当配置完整且有文件时自动开始处理。 + * 注意:上传文件后不再自动触发,需要用户发送"可以开始"等指令。 */ export function checkAutoStart() { if (App.isProcessing) return; if (App.processState === 'processing') return; - if (App.processState === 'done') { + // done 状态下有新文件时,走 supplement 流程(手动触发) + if (App.processState === 'done' && App.forceStart) { const hasNewFiles = App.allFiles.length > App.lastProcessedFileCount; - if (!hasNewFiles && !App.forceStart) return; + if (!hasNewFiles) return; App.forceStart = false; - // done 状态下有新文件时,走 supplement 流程 - if (hasNewFiles) { - App.isProcessing = true; - App.processState = 'processing'; - if (App.newFilenames.length > 0) { - const filenames = App.newFilenames; - App.newFilenames = []; - handleSupplementUpload(filenames); - } - return; + App.isProcessing = true; + App.processState = 'processing'; + if (App.newFilenames.length > 0) { + const filenames = App.newFilenames; + App.newFilenames = []; + handleSupplementUpload(filenames); } + return; } - + // awaiting_supplement 状态下不自动处理,等待用户补充文件后手动触发 if (App.processState === 'awaiting_supplement') { return; } - // idle 状态下有补充文件时,走 supplement 流程 + // idle 状态下有补充文件时,走 supplement 流程(手动触发) if (App.processState === 'idle' && App.newFilenames.length > 0) { App.isProcessing = true; App.processState = 'processing'; @@ -54,16 +53,7 @@ export function checkAutoStart() { return; } - const allKeys = Object.keys(CONFIG_FIELDS); - const missing = allKeys.filter(k => !App.sessionConfig[k]); - - if (missing.length) return; - - App.pendingConfigKey = null; - - if (!App.allFiles.length) return; - - startProcess(); + // 不再自动开始处理,需要用户发送"可以开始"等指令 } /** @@ -89,8 +79,7 @@ export function promptMissingConfig() { App.pendingConfigKey = null; if (App.allFiles.length) { - showStatus('配置信息已完整,开始处理发票……'); - startProcess(); + showStatus('配置信息已完整,请发送"可以开始"或"处理发票"来启动处理流程'); } } @@ -116,6 +105,12 @@ export async function sendUserMessage() { addChatMessage(text, 'user', true); input.value = ''; + // 检查是否是开始处理指令(如"可以开始"、"处理发票"等) + if (text.includes('可以开始') || text.includes('开始处理') || text.includes('处理发票') || text.includes('开始')) { + startProcess(); + return; + } + // 检查是否是强制提交指令 if (text.includes('直接提交') || text.includes('强制提交') || text.includes('继续提交')) { await handleForceSubmit(); @@ -134,7 +129,7 @@ export async function sendUserMessage() { return; } - showStatus('请通过上传区补充文件,或输入"直接提交"跳过校验'); + showStatus('请发送"可以开始"或"处理发票"来启动处理流程'); } export function handleChatKey(event) { diff --git a/src/web/static/js/sync.js b/src/web/static/js/sync.js index 3ff8b48..6f2bbc1 100644 --- a/src/web/static/js/sync.js +++ b/src/web/static/js/sync.js @@ -72,7 +72,5 @@ async function syncFiles() { } else { document.getElementById('file-zone').classList.remove('active'); } - - checkAutoStart(); } catch (e) { /* ignore */ } } \ No newline at end of file diff --git a/src/web/static/js/upload.js b/src/web/static/js/upload.js index a7ca73d..8a8135f 100644 --- a/src/web/static/js/upload.js +++ b/src/web/static/js/upload.js @@ -20,7 +20,6 @@ export async function handleFiles(input) { await _uploadNewFiles(result.newFilenames); App.newFilenames = result.newFilenames; App.processState = 'idle'; - checkAutoStart(); return; } @@ -106,13 +105,12 @@ export function initDragDrop() { App.processState = 'idle'; } - // 在 awaiting_supplement 状态下,只上传新文件并走 supplement 流程 + // 在 awaiting_supplement 状态下,只上传新文件并走 supplement 流程(手动触发) if (result.hasNewFiles && App.processState === 'awaiting_supplement') { hideAgentRequest(); await _uploadNewFiles(result.newFilenames); App.newFilenames = result.newFilenames; App.processState = 'idle'; - checkAutoStart(); return; } diff --git a/src/web/templates/index.html b/src/web/templates/index.html index 47dcfe4..859a93d 100644 --- a/src/web/templates/index.html +++ b/src/web/templates/index.html @@ -16,7 +16,7 @@
-
你好!我是财务报销助手。请先上传 config.json 配置文件,然后上传发票 PDF 或支付截图,我将自动为您处理。
+
你好!我是财务报销助手。请先上传 config.json 配置文件和发票文件,然后发送"可以开始"来启动处理流程。