Files
jiang13-forum/frontend/src/utils/openPost.ts
freefire 9e134916a4 fix: 软刷新齐套前保留旧画面,避免一点击就卸光
Logo/下拉静默预热后一次覆盖;commit 不再先 reset/loading;顺带会话预取与可配置 Feed 排序标签。
2026-09-01 04:56:10 +08:00

24 lines
720 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 type { NavigateFunction } from 'react-router-dom';
import { postPath, type PermalinkOpts } from './permalink';
import { transitionTo } from './spaTransition';
export type OpenForumPostOpts = PermalinkOpts & {
/** 跳转到指定楼层(#floor-N */
floor?: number;
};
/** 按站点配置打开帖子详情(当前页跳转或新标签) */
export function openForumPost(
nav: NavigateFunction,
postId: number,
openInNewTab: boolean,
opts?: OpenForumPostOpts,
) {
const path = postPath(postId, opts) + (opts?.floor && opts.floor > 0 ? `#floor-${opts.floor}` : '');
if (openInNewTab) {
window.open(path, '_blank', 'noopener,noreferrer');
return;
}
void transitionTo(nav, path);
}