Files
shanghai-residences/src/main.tsx
T
2025-12-29 19:19:10 +08:00

35 lines
958 B
TypeScript

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App";
// 在开发模式的移动端启用 vConsole(需先安装 vconsole 依赖)
if (import.meta.env.DEV && typeof window !== "undefined") {
const ua = window.navigator.userAgent.toLowerCase();
const isMobile = /iphone|ipad|ipod|android|mobile/.test(ua);
if (isMobile) {
// 动态加载,避免生产环境打包 & 未安装时报错
import("vconsole")
.then((mod) => {
const VConsole = (mod as any).default || (mod as any);
// eslint-disable-next-line no-new
new VConsole();
})
.catch(() => {
// vconsole 未安装或加载失败时静默忽略
});
}
}
const rootElement = document.getElementById("root");
if (!rootElement) {
throw new Error("Root element not found");
}
createRoot(rootElement).render(
<StrictMode>
<App />
</StrictMode>
);