From d760bcb09f1d1b373ffd417d322bc91a08c63b21 Mon Sep 17 00:00:00 2001
From: shimai <shimai@example.com>
Date: Mon, 09 Mar 2026 17:23:31 +0800
Subject: [PATCH] Merge branch 'master' of http://120.79.193.119:9090/r/~chengmw/cloud-melody-front into test/shimai.huang/260309
---
web-app/src/components/dashboard/TopSection.jsx | 4
web-app/src/services/ProcessAPIService.js | 2
web-app/src/config/env.js | 2
web-app/src/contexts/CaseDataContext.jsx | 30 ++++++-
document/原型/index.html | 4
web-app/src/components/common/OutboundCallWidget.jsx | 149 ++++++++++++++++++++----------------
6 files changed, 114 insertions(+), 77 deletions(-)
diff --git "a/document/\345\216\237\345\236\213/index.html" "b/document/\345\216\237\345\236\213/index.html"
index a585dad..0e34c7f 100644
--- "a/document/\345\216\237\345\236\213/index.html"
+++ "b/document/\345\216\237\345\236\213/index.html"
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>"云小调"劳动争议AI调解智能体</title>
+ <title>"解纷智能体"劳动争议AI调解智能体</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<style>
:root {
@@ -1336,7 +1336,7 @@
<img style="width: 36px" src="http://gz.hugeinfo.com.cn/dyh/wx414ae04ac3f10b4e/images/pngAI_logo.png" alt="" srcset="" />
</div>
<div class="title-text">
- <h1>"云小调"劳动争议AI调解智能体</h1>
+ <h1>"解纷智能体"劳动争议AI调解智能体</h1>
<div class="title-subtitle">
<div class="subtitle-text">AI调解员驾驶舱 - 全自动调解系统</div>
<div class="ai-status-tag">
diff --git a/web-app/src/components/common/OutboundCallWidget.jsx b/web-app/src/components/common/OutboundCallWidget.jsx
index c10d531..f189e73 100644
--- a/web-app/src/components/common/OutboundCallWidget.jsx
+++ b/web-app/src/components/common/OutboundCallWidget.jsx
@@ -28,10 +28,11 @@
*/
const OutboundCallWidget = ({ onSwitchTab, onRefreshData }) => {
const { caseData } = useCaseData();
- const [isVisible, setIsVisible] = useState(false); // 默认隐藏
+ const [isVisible, setIsVisible] = useState(false); // 默认不显示,有任务时自动显示
const [isMinimized, setIsMinimized] = useState(false); // 默认展开(非最小化)
const [calls, setCalls] = useState([]);
const isMountedRef = useRef(true);
+ const fetchCallStatusRef = useRef(null); // 用于存储最新的 fetchCallStatus 函数引用
// 轮询间隔(毫秒)
const POLL_INTERVAL = 10000; // 10秒
@@ -39,7 +40,7 @@
// 最大重试次数
const MAX_RETRY_COUNT = 10;
- // 获取 caseId
+ // 获取 caseIdg
const caseId = caseData?.caseId || caseData?.case_id;
// 格式化通话时长
@@ -58,11 +59,12 @@
// 读取成功的任务
const storedSuccess = localStorage.getItem(OUTBOUND_JOBS_KEY);
const successJobs = storedSuccess ? JSON.parse(storedSuccess) : [];
+ console.log('读取成功任务:', successJobs.length, successJobs);
// 读取失败的任务
const storedFailed = localStorage.getItem(`${OUTBOUND_JOBS_KEY}_failed`);
const failedJobs = storedFailed ? JSON.parse(storedFailed) : [];
- console.log('读取失败任务:', failedJobs);
+ console.log('读取失败任务:', failedJobs.length, failedJobs);
// 清理失败任务 - 按 errorCode 不同策略
const now = Date.now();
@@ -213,22 +215,40 @@
* 查询通话状态
*/
const fetchCallStatus = useCallback(async () => {
+ console.log('fetchCallStatus 被调用');
+
// 从 localStorage 读取任务
const storedJobs = loadJobsFromStorage();
+ console.log('从 localStorage 读取的所有任务:', storedJobs);
// 分离成功任务和失败任务
const successJobs = storedJobs.filter(job => !job.errorCode && isActiveStatus(job.callStatus));
const failedJobs = storedJobs.filter(job => job.errorCode > 0);
+ console.log('成功任务数量:', successJobs.length, '失败任务数量:', failedJobs.length);
+
if (successJobs.length === 0) {
// 没有活跃任务,更新状态并返回
if (isMountedRef.current) {
setCalls([...failedJobs]);
- if (failedJobs.length > 0 && !isVisible) {
+ if (failedJobs.length > 0) {
setIsVisible(true);
}
}
return;
+ }
+
+ // 立即显示气泡(不等待 API 返回)
+ console.log('isMountedRef.current:', isMountedRef.current);
+ if (isMountedRef.current) {
+ // 先合并当前的成功任务和失败任务,立即显示
+ const immediateJobs = [...successJobs, ...failedJobs.filter(f => !successJobs.some(s => s.personId === f.personId))];
+ console.log('准备设置 calls:', immediateJobs);
+ setCalls(immediateJobs);
+ setIsVisible(true);
+ console.log('立即显示气泡,任务数:', immediateJobs.length, 'isVisible 设置为 true');
+ } else {
+ console.log('组件未挂载,跳过显示气泡');
}
// 收集需要更新到后端的任务(状态变化且原状态不是Scheduling)
@@ -320,21 +340,32 @@
// 保存到 localStorage
saveJobsToStorage(cleanedJobs);
- // 合并成功任务和失败任务
- const allJobs = [...cleanedJobs, ...failedJobs];
+ // 合并成功任务和失败任务,按 personId 去重(成功任务优先)
+ const successPersonIds = new Set(cleanedJobs.map(job => job.personId));
+ // 过滤掉已有成功任务的 personId 对应的失败任务
+ const filteredFailedJobs = failedJobs.filter(job => !successPersonIds.has(job.personId));
+ const allJobs = [...cleanedJobs, ...filteredFailedJobs];
// 更新组件状态
if (isMountedRef.current) {
setCalls(allJobs);
- // 如果有任务,显示气泡
- if (allJobs.length > 0 && !isVisible) {
+ // 如果有任务,显示气泡(使用函数式更新避免依赖 isVisible)
+ if (allJobs.length > 0) {
setIsVisible(true);
}
}
- }, [isVisible, triggerPageUpdate]);
+ }, [triggerPageUpdate]);
+
+ // 将最新的 fetchCallStatus 存储到 ref 中
+ useEffect(() => {
+ fetchCallStatusRef.current = fetchCallStatus;
+ }, [fetchCallStatus]);
// 定时轮询通话状态
useEffect(() => {
+ // 组件挂载时设置为 true
+ isMountedRef.current = true;
+
// 初始加载
fetchCallStatus();
@@ -347,6 +378,39 @@
isMountedRef.current = false;
};
}, [fetchCallStatus]);
+
+ // 监听 localStorage 变化,外呼成功后立即刷新
+ useEffect(() => {
+ const handleStorageChange = (e) => {
+ // 监听外呼任务存储的变化
+ if (e.key === OUTBOUND_JOBS_KEY || e.key === `${OUTBOUND_JOBS_KEY}_failed`) {
+ console.log('localStorage 变化,刷新外呼状态');
+ if (fetchCallStatusRef.current) {
+ fetchCallStatusRef.current();
+ }
+ }
+ };
+
+ // 监听 storage 事件(跨标签页同步)
+ window.addEventListener('storage', handleStorageChange);
+
+ // 同页面内的 localStorage 变化需要手动触发
+ // 创建自定义事件监听 - 使用 ref 避免依赖问题
+ const handleCustomStorageChange = () => {
+ console.log('同页面 localStorage 变化,刷新外呼状态');
+ if (fetchCallStatusRef.current) {
+ fetchCallStatusRef.current();
+ }
+ };
+ window.addEventListener('outbound-jobs-updated', handleCustomStorageChange);
+
+ console.log('事件监听器已设置: outbound-jobs-updated');
+
+ return () => {
+ window.removeEventListener('storage', handleStorageChange);
+ window.removeEventListener('outbound-jobs-updated', handleCustomStorageChange);
+ };
+ }, []); // 空依赖数组,只在组件挂载时设置一次
// 关闭气泡
const handleClose = (e) => {
@@ -384,6 +448,15 @@
// 其他状态的任务正常显示
return true;
});
+
+ // 添加调试日志
+ console.log('渲染检查 - calls:', calls.length, 'activeCalls:', activeCalls.length, 'isVisible:', isVisible, 'isMinimized:', isMinimized);
+
+ // 如果没有任务,不渲染任何内容
+ if (activeCalls.length === 0) {
+ console.log('无活跃任务,不渲染气泡');
+ return null;
+ }
// 如果最小化,显示AI客服图标
if (isMinimized) {
@@ -585,64 +658,6 @@
)}
</div>
))}
-
- {/* 无通话时的占位提示 */}
- {activeCalls.length === 0 && isVisible && (
- <div
- style={{
- background: 'linear-gradient(135deg, #1A6FB8 0%, #0d4a8a 100%)',
- borderRadius: 12,
- padding: '16px 20px',
- color: 'white',
- boxShadow: '0 4px 16px rgba(26, 111, 184, 0.3)',
- position: 'relative',
- minWidth: 280,
- }}
- >
- {/* 关闭按钮 */}
- <button
- onClick={handleClose}
- style={{
- position: 'absolute',
- top: 8,
- right: 8,
- width: 24,
- height: 24,
- borderRadius: '50%',
- border: 'none',
- background: 'rgba(255,255,255,0.2)',
- color: 'white',
- cursor: 'pointer',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- fontSize: 14,
- }}
- >
- <i className="fas fa-times" />
- </button>
-
- <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
- <div
- style={{
- width: 36,
- height: 36,
- borderRadius: '50%',
- background: 'rgba(255,255,255,0.2)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- }}
- >
- <i className="fas fa-robot" style={{ fontSize: 18 }} />
- </div>
- <div>
- <div style={{ fontSize: 16, fontWeight: 600 }}>智能外呼系统</div>
- <div style={{ fontSize: 13, opacity: 0.85 }}>暂无进行中的通话</div>
- </div>
- </div>
- </div>
- )}
{/* CSS 动画 */}
<style>{`
diff --git a/web-app/src/components/dashboard/TopSection.jsx b/web-app/src/components/dashboard/TopSection.jsx
index bc55e94..3e49bb9 100644
--- a/web-app/src/components/dashboard/TopSection.jsx
+++ b/web-app/src/components/dashboard/TopSection.jsx
@@ -24,11 +24,11 @@
<img
style={{ width: 36 }}
src="http://gz.hugeinfo.com.cn/dyh/wx414ae04ac3f10b4e/images/pngAI_logo.png"
- alt="云小调"
+ alt="解纷智能体"
/>
</div>
<div className="title-text">
- <h1>"云小调"劳动争议AI调解智能体</h1>
+ <h1>"解纷智能体"劳动争议AI调解智能体</h1>
<div className="title-subtitle">
<div className="subtitle-text">AI调解员驾驶舱 - 全自动调解系统</div>
<div className="ai-status-tag">
diff --git a/web-app/src/config/env.js b/web-app/src/config/env.js
index 206123d..ae2b2c9 100644
--- a/web-app/src/config/env.js
+++ b/web-app/src/config/env.js
@@ -25,7 +25,7 @@
},
[ENV_TYPES.SIT]: {
// 集成测试环境
- baseURL: 'http://sit-api.example.com:9015',
+ baseURL: 'http://192.168.3.114:9015',
timeout: 30000,
withCredentials: true,
name: '集成测试环境'
diff --git a/web-app/src/contexts/CaseDataContext.jsx b/web-app/src/contexts/CaseDataContext.jsx
index 723ed7b..7a26b74 100644
--- a/web-app/src/contexts/CaseDataContext.jsx
+++ b/web-app/src/contexts/CaseDataContext.jsx
@@ -113,6 +113,10 @@
});
// 处理响应
+ console.log('triggerOutboundCall API 响应:', response);
+ console.log('response.data:', response?.data);
+ console.log('response.data 是数组:', Array.isArray(response?.data));
+
if (response?.data && Array.isArray(response.data)) {
const successJobs = [];
const failedJobs = [];
@@ -128,7 +132,7 @@
caseId: String(caseId), // 添加 caseId 字段用于轮询
perClassName: item.perClassName || '', // 添加人员类型名称
trueName: item.trueName || '', // 添加真实姓名
- startTime: item.createdTime || item.start_time,
+ startTime: item.createTime || item.createdTime || item.start_time,
pollStartTime: Date.now(),
retryCount: 0
});
@@ -146,8 +150,16 @@
// 存储成功的任务到 localStorage
if (successJobs.length > 0) {
- localStorage.setItem(OUTBOUND_JOBS_KEY, JSON.stringify(successJobs));
- console.log('存储外呼任务成功,数量:', successJobs.length);
+ // 读取现有的成功任务,合并而不是覆盖
+ const existingJobs = JSON.parse(localStorage.getItem(OUTBOUND_JOBS_KEY) || '[]');
+ // 按 jobId 去重,新任务优先
+ const existingJobIds = new Set(successJobs.map(job => job.jobId));
+ const filteredExistingJobs = existingJobs.filter(job => !existingJobIds.has(job.jobId));
+ const mergedJobs = [...successJobs, ...filteredExistingJobs];
+
+ localStorage.setItem(OUTBOUND_JOBS_KEY, JSON.stringify(mergedJobs));
+ console.log('存储外呼任务成功,新增:', successJobs.length, '总数:', mergedJobs.length);
+ console.log('存储的任务:', JSON.stringify(mergedJobs, null, 2));
// 外呼成功后,清除对应的失败记录
const storedFailedJobs = JSON.parse(localStorage.getItem(`${OUTBOUND_JOBS_KEY}_failed`) || '[]');
@@ -159,6 +171,12 @@
localStorage.setItem(`${OUTBOUND_JOBS_KEY}_failed`, JSON.stringify(remainingFailedJobs));
console.log('外呼成功后清除失败记录,清除数量:', storedFailedJobs.length - remainingFailedJobs.length);
}
+
+ // 延迟触发自定义事件,确保监听器已经设置好
+ setTimeout(() => {
+ console.log('触发 outbound-jobs-updated 事件');
+ window.dispatchEvent(new CustomEvent('outbound-jobs-updated'));
+ }, 300);
}
// 存储失败的任务到 localStorage(用于气泡显示)
@@ -188,6 +206,9 @@
localStorage.setItem(`${OUTBOUND_JOBS_KEY}_failed`, JSON.stringify(cleanedFailedJobs));
console.log('存储外呼失败任务,数量:', cleanedFailedJobs.length);
+
+ // 触发自定义事件通知 OutboundCallWidget 组件刷新
+ window.dispatchEvent(new CustomEvent('outbound-jobs-updated'));
}
// 提示失败的任务
@@ -286,7 +307,8 @@
params.caseId,
{
caseTypeFirst: params.caseTypeFirst,
- platform_code: params.platform_code
+ platform_code: params.platform_code,
+ authorization: params.auth_token
}
);
diff --git a/web-app/src/services/ProcessAPIService.js b/web-app/src/services/ProcessAPIService.js
index 91ec9ad..e71488f 100644
--- a/web-app/src/services/ProcessAPIService.js
+++ b/web-app/src/services/ProcessAPIService.js
@@ -119,7 +119,7 @@
}
/**
- * 人工接管API
+ * 人工接管API·
* PUT /api/v1/mediation-timeline/v2/case/{caseId}/takeover
* @param {string} caseId - 案件ID
* @param {Object} data - 请求数据
--
Gitblit v1.8.0