//全局变量 import './Global'; import React from 'react'; import ReactDOM from 'react-dom/client'; import App from './App'; import { BrowserRouter } from 'react-router-dom'; import { ThemeProvider } from '@contexts/themeContext'; import { ShopProvider } from '@contexts/shopContext'; import { Provider } from 'react-redux'; import store from './app/store'; import * as Sentry from "@sentry/react"; import { Capacitor } from '@capacitor/core'; import { TextZoom } from '@capacitor/text-zoom'; import { installClientErrorLogging } from '@utils/clientLog'; installClientErrorLogging(); // Explicitly retain the current v6 behaviour while silencing the opt-in notices. // Revisit these flags together with the eventual React Router v7 migration. const routerFuture = { v7_startTransition: false, v7_relativeSplatPath: false, }; if (!Capacitor.isNativePlatform()) { // 只有在纯浏览器/PWA 才注册 SW window.addEventListener('load', () => { navigator.serviceWorker?.register('/service-worker.js') .catch(err => console.error('SW register failed', err)); }); } else { TextZoom.set({ value: 1 }); } global.dispatch = store.dispatch; Sentry.init({ dsn: "https://4686ef0d926e140fb482e63efcde1cdf@o4507102375641088.ingest.us.sentry.io/4507102380687360", integrations: [ Sentry.browserTracingIntegration(), Sentry.feedbackIntegration({ // Additional SDK configuration goes in here, for example: colorScheme: "dark", autoInject: false, isEmailRequired: true, }), ], sampleRate: 0.02, tracesSampleRate: 0.001, replaysSessionSampleRate: 0, replaysOnErrorSampleRate: 0.01, beforeSend(event) { const level = event.level || "error"; if (level !== "error" && level !== "fatal") return null; const exception = event.exception?.values?.[0]; if (!exception) return null; const handled = exception.mechanism?.handled; if (handled === true) return null; return event; }, }); const root = ReactDOM.createRoot(document.getElementById('root')); root.render( );