/**
 * [MOCK-004] Umi运行时配置
 * 应用启动时初始化MSW
 * 
 * @module app
 * @author AI-Frontend-Team
 * @created 2026-03-19
 */

import { RuntimeConfig } from 'umi';

/**
 * 应用启动时执行
 * 用于初始化MSW等全局配置
 */
export async function render(oldRender: () => void) {
  // 开发环境且启用Mock时，初始化MSW
  if (process.env.NODE_ENV === 'development' && process.env.REACT_APP_USE_MOCK === 'true') {
    console.log('[App] Initializing Mock Service Worker...');
    
    try {
      const { startMSW } = await import('./mock/browser');
      await startMSW({
        onUnhandledRequest: 'bypass',
      });
      console.log('[App] MSW initialized successfully');
    } catch (error) {
      console.error('[App] Failed to initialize MSW:', error);
    }
  }

  oldRender();
}


