fix: #1444 async load google fonts

This commit is contained in:
Yidadaa
2023-05-14 23:25:22 +08:00
parent 6da3aab046
commit 03163d6a61
3 changed files with 16 additions and 6 deletions

View File

@@ -23,7 +23,6 @@ import {
} from "react-router-dom";
import { SideBar } from "./sidebar";
import { useAppConfig } from "../store/config";
import { useMaskStore } from "../store/mask";
export function Loading(props: { noLogo?: boolean }) {
return (
@@ -91,12 +90,24 @@ const useHasHydrated = () => {
return hasHydrated;
};
const loadAsyncGoogleFont = () => {
const linkEl = document.createElement("link");
linkEl.rel = "stylesheet";
linkEl.href =
"/google-fonts/css2?family=Noto+Sans+SC:wght@300;400;700;900&display=swap";
document.head.appendChild(linkEl);
};
function Screen() {
const config = useAppConfig();
const location = useLocation();
const isHome = location.pathname === Path.Home;
const isMobileScreen = useMobileScreen();
useEffect(() => {
loadAsyncGoogleFont();
}, []);
return (
<div
className={