feat: 可配置站点 URL 风格
- 新增 urlStyle 工具与测试:postPath/userPath/sitePagePath 统一生成链接 - 管理端新增 UrlStylePanel 设置面板,settings 服务与 handler 适配 - 全站路由链接与 JSON-LD/sitemap 切换为统一 URL 生成 - middleware 与相关组件适配
This commit is contained in:
@@ -35,6 +35,8 @@ import DeadlinePicker, {
|
||||
} from "@/components/DeadlinePicker";
|
||||
import Modal from "@/components/Modal";
|
||||
import { realtime, RT_SETTINGS_CHANGED, type RtSettingsData } from "@/lib/realtime";
|
||||
import { postPath } from "@/lib/urlStyle";
|
||||
import { useUrlStyle } from "@/components/SiteBrandProvider";
|
||||
|
||||
const TITLE_MAX = 256;
|
||||
/** 帖子正文字符上限(与后端 handler/post.go 校验一致) */
|
||||
@@ -179,6 +181,7 @@ export type PostComposerProps = CreateProps | EditProps;
|
||||
|
||||
export default function PostComposer(props: PostComposerProps) {
|
||||
const router = useRouter();
|
||||
const urlStyle = useUrlStyle();
|
||||
const isCreate = props.mode === "create";
|
||||
|
||||
const [boards, setBoards] = useState<Board[]>([]);
|
||||
@@ -828,7 +831,7 @@ export default function PostComposer(props: PostComposerProps) {
|
||||
} else {
|
||||
toast("发布成功", "ok");
|
||||
}
|
||||
router.push(`/post/${res.post.id}`);
|
||||
router.push(postPath(urlStyle, res.post.id));
|
||||
} else {
|
||||
const mapped = mapPostError(res.error || "发帖失败");
|
||||
reportSubmitError(
|
||||
|
||||
Reference in New Issue
Block a user