refactor: prefetch basic data and window visibility change event in streaming

This commit is contained in:
Tristan Yang
2023-08-23 23:06:12 +08:00
parent 1ae9b0e55f
commit 488b9b301c
12 changed files with 452 additions and 285 deletions
+2
View File
@@ -20,6 +20,7 @@ import UserIcon from "@/assets/icons/user.svg";
import Menu from "./Menu";
import MobileNavs from "./MobileNavs";
import User from "./User";
import StreamStatus from "@/components/StreamStatus";
function HomePage() {
const { t } = useTranslation();
@@ -65,6 +66,7 @@ function HomePage() {
const linkClass = `flex items-center gap-2.5 px-3 py-2 font-semibold text-sm text-gray-600 rounded-lg md:hover:bg-gray-800/10`;
return (
<>
<StreamStatus />
{roleChanged && <ReLoginModal />}
{!guest && <UnreadTabTip />}
{!guest && <Voice />}
+3 -1
View File
@@ -17,6 +17,7 @@ import NotFoundPage from "./404";
import InvitePrivate from "./invitePrivate";
import LazyIt from "./lazy";
import InviteInMobile from "./reg/InviteInMobile";
import usePrefetchData from "@/hooks/usePrefetchData";
const RegBasePage = lazy(() => import("./reg"));
const RegWithUsernamePage = lazy(() => import("./reg/RegWithUsername"));
@@ -47,7 +48,8 @@ const PageRoutes = () => {
}, isEqual);
// 提前获取device token
useDeviceToken(vapidKey);
// 初始化元信息
usePrefetchData();
// 掉线检测
useEffect(() => {
if (!online) {