增强CustomerList和MessageList组件的错误处理:在CustomerList中添加错误日志和降级逻辑以处理加载失败情况;在MessageList中优化警告条件以确保更准确的调试信息。
This commit is contained in:
@@ -25,7 +25,14 @@ const CustomerList: React.FC = () => {
|
||||
}
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(error => {
|
||||
console.error("❌ 获取客服列表失败:", error);
|
||||
// 即使加载失败,也设置为 null(表示"全部"),避免阻塞会话列表
|
||||
const current = useCustomerStore.getState().currentCustomer;
|
||||
if (current === undefined) {
|
||||
console.log("🔄 加载失败,降级为全部账号");
|
||||
updateCurrentCustomer(null);
|
||||
}
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
@@ -113,7 +113,17 @@ const MessageList: React.FC<MessageListProps> = () => {
|
||||
|
||||
// 调试日志:检查会话列表状态
|
||||
useEffect(() => {
|
||||
if (displaySessions.length === 0) {
|
||||
// 只在以下情况才警告:
|
||||
// 1. 会话列表为空
|
||||
// 2. 已经完成过至少一次加载
|
||||
// 3. currentCustomer 不是 undefined(已加载客服列表)
|
||||
// 4. 不在同步中
|
||||
if (
|
||||
displaySessions.length === 0 &&
|
||||
hasLoadedOnce &&
|
||||
currentCustomer !== undefined &&
|
||||
!syncing
|
||||
) {
|
||||
console.warn("⚠️ 会话列表为空,调试信息:", {
|
||||
storeSessionsLength: storeSessions.length,
|
||||
filteredSessionsLength: filteredSessions.length,
|
||||
|
||||
Reference in New Issue
Block a user