feat(splash): load latest chat message
Docker Image / Build and Push Docker Image (push) Has been cancelled
Docker Image / Build and Push Docker Image (push) Has been cancelled
This commit is contained in:
@@ -5,6 +5,7 @@ import { useEffect } from "react";
|
||||
import { AppBottomNav, MobileShell } from "@/app/_components/core";
|
||||
import { ROUTES } from "@/router/routes";
|
||||
import { useAppNavigator } from "@/router/use-app-navigator";
|
||||
import { useAuthState } from "@/stores/auth/auth-context";
|
||||
import { pwaUtil } from "@/utils";
|
||||
|
||||
import {
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
SplashLatestMessage,
|
||||
SplashLogo,
|
||||
} from "./components";
|
||||
import { useSplashLatestMessage } from "./hooks/use-splash-latest-message";
|
||||
import styles from "./components/splash-screen.module.css";
|
||||
|
||||
// 尽量早地缓存 beforeinstallprompt,避免用户停留 splash 时浏览器事件已触发并丢失。
|
||||
@@ -23,6 +25,12 @@ if (typeof window !== "undefined") {
|
||||
|
||||
export function SplashScreen() {
|
||||
const navigator = useAppNavigator();
|
||||
const authState = useAuthState();
|
||||
const latestMessage = useSplashLatestMessage({
|
||||
hasInitialized: authState.hasInitialized,
|
||||
isAuthLoading: authState.isLoading,
|
||||
loginStatus: authState.loginStatus,
|
||||
});
|
||||
|
||||
const handleStartChat = () => {
|
||||
navigator.openChat({ replace: true });
|
||||
@@ -45,7 +53,11 @@ export function SplashScreen() {
|
||||
<div className={styles.content}>
|
||||
<SplashLogo />
|
||||
<div className={styles.spacer} />
|
||||
<SplashLatestMessage onOpenChat={handleStartChat} />
|
||||
<SplashLatestMessage
|
||||
message={latestMessage.message}
|
||||
isLoading={latestMessage.isLoading}
|
||||
onOpenChat={handleStartChat}
|
||||
/>
|
||||
<SplashContent />
|
||||
<div className={styles.buttonArea}>
|
||||
<SplashButton onStartChat={handleStartChat} />
|
||||
|
||||
Reference in New Issue
Block a user