refactor(frontend): 重构前端第二版

This commit is contained in:
sophie committed 2026-06-11 13:47:06 +08:00
1 parent 2631f78b00
commit 4b562cfa82
205 files changed
+15399 -12015

No files matched your search

@@ -0,0 +1,24 @@
/**
* 出货聊天:任务编号提取(纯函数)。
*
* 从消息正文匹配 SHIPPING_TASK_ID_RE,或从侧栏会话标题模糊查找。
*/
import { SHIPPING_TASK_ID_RE } from '../constants/shipping';
import type { ChatSessionItem } from '../types/chat.types';
export function findLatestShippingTaskId(msgs: Array<{ content?: string }>): string {
for (let i = msgs.length - 1; i >= 0; i -= 1) {
const match = String(msgs[i]?.content || '').match(SHIPPING_TASK_ID_RE);
if (match?.[0]) return match[0].toUpperCase();
}
return '';
}
export function findHistorySessionForShippingTask(
history: ChatSessionItem[],
taskId: string,
): ChatSessionItem | null {
const needle = taskId.trim().toUpperCase();
if (!needle) return null;
return history.find((item) => String(item.title || '').toUpperCase().includes(needle)) || null;
}