Add pre-fetch data handling for resources, users, and comments

This commit is contained in:
2025-07-14 11:47:59 +08:00
parent 6188b88917
commit 0ef8e14587
6 changed files with 60 additions and 13 deletions

View File

@@ -14,6 +14,7 @@ import {
MdOutlinePhotoAlbum,
} from "react-icons/md";
import { useTranslation } from "react-i18next";
import { app } from "../app.ts";
export default function UserPage() {
const [user, setUser] = useState<User | null>(null);
@@ -50,6 +51,11 @@ export default function UserPage() {
};
useEffect(() => {
const preFetchData = app.getPreFetchData();
if (preFetchData?.user?.username === username) {
setUser(preFetchData.user);
return;
}
network.getUserInfo(username || "").then((res) => {
if (res.success) {
setUser(res.data!);