import { Routes, Route, HashRouter } from "react-router-dom"; import About from "./About"; import Rules from "./Rules"; import Setting from "./Setting"; import Layout from "./Layout"; import SyncSetting from "./SyncSetting"; import { StoragesProvider } from "../../hooks/Storage"; import ThemeProvider from "../../hooks/Theme"; import { useEffect, useState } from "react"; import { isGm } from "../../libs/browser"; import { sleep } from "../../libs/utils"; import CircularProgress from "@mui/material/CircularProgress"; import { syncAll } from "../../libs/sync"; import { AlertProvider } from "../../hooks/Alert"; export default function Options() { const [error, setError] = useState(false); const [ready, setReady] = useState(false); useEffect(() => { (async () => { if (isGm) { // 等待GM注入 let i = 0; for (;;) { if (window.APP_NAME === process.env.REACT_APP_NAME) { setReady(true); break; } if (++i > 8) { setError(true); break; } await sleep(1000); } } // 同步数据 syncAll(); })(); }, []); if (error) { return (

Please confirm whether to install or enable{" "} KISS Translator{" "} GreaseMonkey script?

Click here{" "} to install, or click here{" "} for help.

); } if (isGm && !ready) { return (
); } return ( }> } /> } /> } /> } /> ); }