chore: 去掉未上线前的旧兼容垫片,板块流收口到首页
鉴权只认 cookie、SEO 只走 Next、sort 与推荐对齐;删除 Bearer、Go sitemap、post_type 回填等冗余路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -134,6 +134,32 @@ export interface OverviewResponse {
|
||||
checkin?: CheckinStatus | null;
|
||||
}
|
||||
|
||||
/** 板块右栏:管理员公开资料 */
|
||||
export interface BoardModerator {
|
||||
id: number;
|
||||
username: string;
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
}
|
||||
|
||||
/** 板块右栏:板级统计 */
|
||||
export interface BoardSidebarStats {
|
||||
post_count: number;
|
||||
today_posts: number;
|
||||
comment_count: number;
|
||||
today_comments: number;
|
||||
}
|
||||
|
||||
/** 首页选中板块后的右栏聚合 */
|
||||
export interface BoardSidebarResponse {
|
||||
board: BoardWithCount;
|
||||
moderators: BoardModerator[];
|
||||
stats: BoardSidebarStats;
|
||||
hot: PostListItem[];
|
||||
active_users: ActiveUser[];
|
||||
checkin?: CheckinStatus | null;
|
||||
}
|
||||
|
||||
export interface PostListItem {
|
||||
id: number;
|
||||
board_id: number;
|
||||
@@ -462,7 +488,7 @@ export async function fetchPosts(
|
||||
page = 1,
|
||||
size = 20,
|
||||
boardId?: number,
|
||||
sort = "latest",
|
||||
sort = "latest", // latest | recommended | new
|
||||
keyword = "",
|
||||
recommended = false,
|
||||
cookieHeader?: string
|
||||
@@ -483,6 +509,19 @@ export async function fetchOverview(cookieHeader?: string): Promise<OverviewResp
|
||||
return res.json();
|
||||
}
|
||||
|
||||
/** SSR 板块右栏;失败时抛错,由首页降级 */
|
||||
export async function fetchBoardSidebar(
|
||||
boardId: number,
|
||||
cookieHeader?: string
|
||||
): Promise<BoardSidebarResponse> {
|
||||
const res = await fetch(
|
||||
`${API_BASE}/api/boards/${boardId}/sidebar`,
|
||||
ssrInit(cookieHeaders(cookieHeader))
|
||||
);
|
||||
if (!res.ok) throw new Error("获取板块侧栏失败");
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function fetchBoards(): Promise<{ boards: BoardWithCount[] }> {
|
||||
const res = await fetch(`${API_BASE}/api/boards`, ssrInit());
|
||||
if (!res.ok) throw new Error("获取板块失败");
|
||||
@@ -1375,7 +1414,7 @@ export async function apiAdminUserAuditMessages(
|
||||
// ===== 站点外观设置 =====
|
||||
|
||||
export async function apiGetSettings(): Promise<PublicSettings> {
|
||||
// no-store:主题同步轮询必须读到管理员刚保存的最新配色,不走浏览器缓存
|
||||
// no-store:主题同步必须读到管理员刚保存的最新配色,不走浏览器缓存
|
||||
const res = await fetchWithRefresh("/api/settings", { method: "GET", cache: "no-store" });
|
||||
if (!res.ok) throw new Error("获取站点设置失败");
|
||||
return res.json();
|
||||
|
||||
@@ -23,7 +23,7 @@ export const BOUNTY_EXPIRE_DAYS = [3, 7, 14, 30] as const;
|
||||
export const LOTTERY_EXPIRE_DAYS = [1, 3, 7, 14] as const;
|
||||
|
||||
export function normalizePostType(t?: string): PostTypeValue {
|
||||
if (t === "normal" || !t) return "discussion";
|
||||
if (!t) return "discussion";
|
||||
if (POST_TYPES.some((x) => x.value === t)) return t as PostTypeValue;
|
||||
return "discussion";
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// - 在线集合:hello 帧给 staff 全量快照,之后 presence:update 增量维护。
|
||||
// - 群聊:进入群详情页调用 joinRoom(roomID) 订阅 chat:{id} 房间,
|
||||
// 重连后会自动重订当前已订阅集合;离开页面/退出群调用 leaveRoom。
|
||||
// - 轮询仅作兜底:回前台 / 进页时 HTTP 校准;实时靠 WS(通知、待审、主题、群聊未读)。
|
||||
// - HTTP 仅作回前台 / 进页校准;实时靠 WS(通知、待审、主题、群聊未读)。
|
||||
|
||||
export const RT_HELLO = "hello";
|
||||
export const RT_PONG = "pong";
|
||||
|
||||
Reference in New Issue
Block a user