diff --git a/App.jsx b/App.jsx index f21b657..c80a45e 100644 --- a/App.jsx +++ b/App.jsx @@ -2015,6 +2015,7 @@ const Styles = () => ( .crm-sidebar-overlay { display: none; } @media (max-width: 880px) { + .crm-shell { flex-direction: column; } .crm-topbar-mobile { display: flex; } .crm-sidebar { position: fixed; top: 0; left: -260px; height: 100vh; width: 240px; z-index: 40; @@ -2471,6 +2472,8 @@ export default function CustomerCRM() { }); } + const focus = useMemo(() => { try { const q = new URLSearchParams(window.location.search); return q.get('chat') ? { sid: q.get('chat'), k: q.get('k') || '' } : null; } catch (e) { return null; } }, []); + if (focus && (focus.k || authState === 'in')) return ; if (authState === 'checking') { return (
@@ -9843,7 +9846,9 @@ function ChatCenter({ onNotify, onSaveCustomer, initialSid }) { ); } -function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, onDeleted }) { +function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, onDeleted, k, focus, authed = true }) { + const kq = k ? `?k=${encodeURIComponent(k)}` : ''; + const [noteMode, setNoteMode] = useState(false); const [text, setText] = useState(''); const [note, setNote] = useState(''); const [translate, setTranslate] = useState(true); @@ -9855,18 +9860,18 @@ function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, on const lastId = conv.msgs.length ? conv.msgs[conv.msgs.length - 1].id : 0; useEffect(() => { if (bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollHeight; }, [lastId, conv.typing, conv.sid]); useEffect(() => { setText(''); setNote(''); setPreview(''); }, [conv.sid]); - const act = async (p, body, ok) => { try { await chApi('POST', `/api/chat/admin/${conv.sid}/${p}`, body); if (ok) onNotify(ok); onReload(); } catch (e) { onNotify('失败:' + e.message); } }; + const act = async (p, body, ok) => { try { await chApi('POST', `/api/chat/admin/${conv.sid}/${p}${kq}`, body); if (ok) onNotify(ok); onReload(); } catch (e) { onNotify('失败:' + e.message); } }; const send = async () => { const v = text.trim(); if (!v) return; setBusy(true); - try { await chApi('POST', `/api/chat/admin/${conv.sid}/send`, { text: v, translate }); setText(''); setPreview(''); onReload(); } + try { await chApi('POST', `/api/chat/admin/${conv.sid}/send${kq}`, { text: v, translate }); setText(''); setPreview(''); onReload(); } catch (e) { onNotify('发送失败:' + e.message); } setBusy(false); }; const doPreview = async () => { if (!text.trim()) return; setBusy(true); - try { const j = await chApi('POST', `/api/chat/admin/${conv.sid}/translate`, { text }); setPreview(j.text); } catch (e) { onNotify('翻译失败:' + e.message); } + try { const j = await chApi('POST', `/api/chat/admin/${conv.sid}/translate${kq}`, { text }); setPreview(j.text); } catch (e) { onNotify('翻译失败:' + e.message); } setBusy(false); }; const saveExample = async (m) => { @@ -9881,7 +9886,19 @@ function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, on const t = CH_TIER[l.tier || 'unknown'] || CH_TIER.unknown; const human = conv.mode === 'human'; return ( -
+
+ {focus ? ( +
+ {focus.back && ‹} +
setLeadOpen((v) => !v)}> + {chFlag(conv.ipCountry)} {l.company || l.name || l.country || '访客'} + {t[0]} {l.score ? `${l.score} 分 · ` : ''}{human ? '你在接待' : conv.typing ? 'AI 正在输入…' : 'AI 接待中'} +
+ + + {human ? : } +
+ ) : (
@@ -9894,10 +9911,12 @@ function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, on
-
+ )} + {focus && l.needsHuman && !human &&
AI 建议人工介入{l.handoff ? `:${l.handoff}` : ''}
} + {!focus &&
{human ? ● 你在接待,AI 已暂停 : ● AI 正在接待{conv.typing ? '(正在输入…)' : ''}} {l.needsHuman && !human && AI 建议人工介入{l.handoff ? `:${l.handoff}` : ''}} -
+
}
{conv.msgs.map((m) => ( @@ -9907,7 +9926,7 @@ function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, on

{chLink(!showOrig && m.zh && m.from !== 'human' ? m.zh : m.text)}

{m.from === 'human' && m.zh && 你写的:{m.zh}} {!showOrig && m.zh && m.from !== 'human' && {m.text}} - {m.from === 'human' && } + {m.from === 'human' && authed && }
) ))} @@ -9924,14 +9943,30 @@ function ChatConversation({ conv, onBack, onNotify, onSaveCustomer, onReload, on
语言{conv.custLang || conv.lang}
{conv.pages && conv.pages.length > 0 &&
看过的页面{conv.pages.slice(-6).map((p, i) => {p.page.replace(/^https?:\/\/[^/]+/, '')})}
}
- + {onSaveCustomer && } {['importer', 'project', 'reseller', 'personal', 'spam'].map((k) => l.tier !== k && )} - + {authed && onDeleted && }
)}
+ {focus ? ( +
+ {preview &&
客户会看到:{preview}
} +
+