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 &&
}
-
+ {onSaveCustomer && }
{['importer', 'project', 'reseller', 'personal', 'spam'].map((k) => l.tier !== k && )}
-
+ {authed && onDeleted && }
)}
+ {focus ? (
+
+ {preview &&
客户会看到:{preview}
}
+
+
+
+
+ {!noteMode && translate && /[\u4e00-\u9fff]/.test(text) && }
+
+
+
+
+ ) : (
+ )}
);
}
@@ -10061,6 +10097,37 @@ function ChatSettings({ onNotify }) {
);
}
+// 手机推送链接打开的"只看这个对话"页面:全屏、不显示菜单和其他功能
+function ChatFocus({ sid, k, authed }) {
+ const [conv, setConv] = useState(null);
+ const [err, setErr] = useState('');
+ const [toast, setToast] = useState('');
+ const verRef = useRef(0);
+ const kq = k ? `k=${encodeURIComponent(k)}` : '';
+ const load = async () => { try { const j = await chApi('GET', `/api/chat/admin/conv/${sid}?${kq}`); setConv(j.conv); verRef.current = j.conv.ver || verRef.current; setErr(''); } catch (e) { setErr(e.message); } };
+ useEffect(() => {
+ let alive = true;
+ (async () => {
+ await load();
+ while (alive) {
+ try { const j = await chApi('GET', `/api/chat/admin/conv/${sid}/wait?ver=${verRef.current}&${kq}`); if (!alive) break; if (j.ver !== verRef.current) { verRef.current = j.ver; await load(); } }
+ catch (e) { await new Promise((r) => setTimeout(r, 4000)); }
+ }
+ })();
+ return () => { alive = false; };
+ }, [sid]);
+ const notify = (m) => { setToast(m); setTimeout(() => setToast(''), 2000); };
+ return (
+