Files
vf_react/src/index.js

36 lines
1.0 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';
// 本地引入 Leaflet 样式,替代不稳定的 CDN 外链
import 'leaflet/dist/leaflet.css';
// 导入 Tailwind CSS 和 Brainwave 样式
import './styles/brainwave.css';
import './styles/brainwave-colors.css';
// Import the main App component
import App from './App';
// 启动 Mock Service Worker如果启用
async function startApp() {
// 只在开发环境启动 MSW
if (process.env.NODE_ENV === 'development' && process.env.REACT_APP_ENABLE_MOCK === 'true') {
const { startMockServiceWorker } = await import('./mocks/browser');
await startMockServiceWorker();
}
// Create root
const root = ReactDOM.createRoot(document.getElementById('root'));
// Render the app with Router wrapper
root.render(
<React.StrictMode>
<Router>
<App />
</Router>
</React.StrictMode>
);
}
// 启动应用
startApp();