Files
jiang13-bbs/frontend/lib/serverData.ts

13 lines
644 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { cache } from "react";
import { fetchMe, fetchPublicSettings, fetchSiteState } from "./api";
// 同一 SSR 请求内去重:layout 与页面可能同时需要当前用户,
// 相同 Cookie 头参数下只产生一次 /api/me 调用。
export const getMeCached = cache((cookieHeader?: string) => fetchMe(cookieHeader));
// 同请求内去重:layout 注入主题 CSS 变量、后台页读取当前配置共用
export const getPublicSettingsCached = cache(() => fetchPublicSettings());
// 同请求内去重:注册/找回密码页读取开放状态与提示文案
export const getSiteStateCached = cache(() => fetchSiteState());