tony.cheng
2026-03-13 22ae69256f66f4e413f577a32732e9de200e73e5
feat: 实现URL auth_token 转换为 Authorization 请求头传递
2 files added
5 files modified
21029 ■■■■■ changed files
cloud-melody-front-build.zip patch | view | raw | blame | history
web-app/package-lock.json 18009 ●●●●● patch | view | raw | blame | history
web-app/src/components/common/OutboundCallWidget.jsx 8 ●●●●● patch | view | raw | blame | history
web-app/src/config/env.js 8 ●●●● patch | view | raw | blame | history
web-app/src/contexts/CaseDataContext.jsx 11 ●●●●● patch | view | raw | blame | history
web-app/src/services/ProcessAPIService.js 23 ●●●● patch | view | raw | blame | history
web-app/yarn.lock 2970 ●●●● patch | view | raw | blame | history
cloud-melody-front-build.zip
Binary files differ
web-app/package-lock.json
New file
Diff too large
web-app/src/components/common/OutboundCallWidget.jsx
@@ -341,9 +341,17 @@
    // 设置轮询定时器(10秒间隔)
    const interval = setInterval(fetchCallStatus, POLL_INTERVAL);
    
    // 监听外呼任务更新事件(立即刷新)
    const handleOutboundJobsUpdated = () => {
      console.log('收到外呼任务更新事件,立即刷新');
      fetchCallStatus();
    };
    window.addEventListener('outbound-jobs-updated', handleOutboundJobsUpdated);
    // 清理函数
    return () => {
      clearInterval(interval);
      window.removeEventListener('outbound-jobs-updated', handleOutboundJobsUpdated);
      isMountedRef.current = false;
    };
  }, [fetchCallStatus]);
web-app/src/config/env.js
@@ -25,9 +25,9 @@
  },
  [ENV_TYPES.SIT]: {
    // 集成测试环境 - 通过 Nginx 代理访问后端,避免跨域
    baseURL: 'http://localhost:9015',
    baseURL: '',  // 使用相对路径,通过Nginx代理转发
    timeout: 30000,
    withCredentials: true,
    withCredentials: false,
    name: '集成测试环境'
  },
  [ENV_TYPES.UAT]: {
@@ -38,8 +38,8 @@
    name: '用户验收环境'
  },
  [ENV_TYPES.PRD]: {
    // 生产环境
    baseURL: 'https://api.example.com',
    // 生产环境 - 通过 Nginx 代理访问后端
    baseURL: '',  // 使用相对路径,通过Nginx代理转发
    timeout: 30000,
    withCredentials: true,
    name: '生产环境'
web-app/src/contexts/CaseDataContext.jsx
@@ -143,6 +143,7 @@
              personId: item.personId,
              mediationId: item.mediationId,
              caseId: String(caseId), // 添加 caseId 字段用于轮询
              perTypeName: item.perTypeName || '', // 当事人类型名称(申请方当事人/被申请方当事人)
              perClassName: item.perClassName || '', // 添加人员类型名称
              trueName: item.trueName || '', // 添加真实姓名
              startTime: item.createdTime || item.start_time,
@@ -153,6 +154,7 @@
            failedJobs.push({
              personId: item.personId,
              message: item.message || '未知错误',
              perTypeName: item.perTypeName || '', // 当事人类型名称(申请方当事人/被申请方当事人)
              perClassName: item.perClassName || '', // 添加人员类型名称
              trueName: item.trueName || '', // 添加真实姓名
              errorCode: item.errorCode, // 添加错误码
@@ -176,6 +178,11 @@
            localStorage.setItem(`${OUTBOUND_JOBS_KEY}_failed`, JSON.stringify(remainingFailedJobs));
            console.log('外呼成功后清除失败记录,清除数量:', storedFailedJobs.length - remainingFailedJobs.length);
          }
          // 触发自定义事件,通知 OutboundCallWidget 组件立即刷新
          setTimeout(() => {
            window.dispatchEvent(new CustomEvent('outbound-jobs-updated'));
          }, 300);
        }
        // 存储失败的任务到 localStorage(用于气泡显示)
@@ -384,11 +391,13 @@
      }
      // 调用API获取数据
      // 将URL中的auth_token转换为authorization传入API
      const response = await ProcessAPIService.getCaseProcessInfo(
        params.caseId,
        {
          caseTypeFirst: params.caseTypeFirst,
          platform_code: params.platform_code
          platform_code: params.platform_code,
          authorization: params.auth_token || params.authorization || ''
        }
      );
web-app/src/services/ProcessAPIService.js
@@ -39,10 +39,14 @@
   * @param {Object} params - 查询参数
   * @param {string} params.caseTypeFirst - 案件一级分类
   * @param {string} params.platform_code - 外部平台编号
   * @param {string} params.authorization - 授权token
   * @returns {Promise} 调解时间线数据
   */
  static getMediationTimeline(caseId, params = {}) {
    return request.get(`/api/v1/mediation-timeline/v2/case/${caseId}`, params);
    const { authorization, ...queryParams } = params;
    queryParams.authorization = authorization;
    const config = authorization ? { headers: { Authorization: authorization } } : {};
    return request.get(`/api/v1/mediation-timeline/v2/case/${caseId}`, queryParams, config);
  }
  /**
@@ -52,10 +56,13 @@
   * @param {string} params.caseTypeFirst - 案件一级分类
   * @param {string} params.platformCode - 外部平台编号
   * @param {string} params.caseId - 案件ID
   * @param {string} params.authorization - 授权token
   * @returns {Promise} 流程节点列表
   */
  static getProcessNodes(params = {}) {
    return request.get('/api/v1/process/node', params);
    const { authorization, ...queryParams } = params;
    const config = authorization ? { headers: { Authorization: authorization } } : {};
    return request.get('/api/v1/process/node', queryParams, config);
  } 
@@ -65,6 +72,7 @@
   * @param {Object} params - 查询参数
   * @param {string} params.caseTypeFirst - 案件一级分类
   * @param {string} params.platform_code - 外部平台编号
   * @param {string} params.authorization - 授权token(来自URL的auth_token)
   * @returns {Promise} 完整流程信息
   */
  static async getCaseProcessInfo(caseId, params = {}) {
@@ -74,13 +82,18 @@
      const nodeParams = {
        caseTypeFirst: params.caseTypeFirst,
        platformCode: params.platform_code,
        caseId
        caseId,
        authorization: params.authorization
      };
      
      // 提取authorization用于子请求
      const { authorization, ...timelineParams } = params;
      console.log('Timeline params:', timelineParams);
      timelineParams.authorization = authorization;
      // 并行获取时间线和流程节点
      const promises = [
        this.getMediationTimeline(caseId, params),
        this.getProcessNodes(nodeParams)
        this.getMediationTimeline(caseId, { ...timelineParams, authorization }),
        this.getProcessNodes({ ...nodeParams, authorization })
      ];
      const results = await Promise.all(promises);
web-app/yarn.lock
Diff too large