后台可注入全站 CSS/JS(SSR 生效,CSS 可热换);发帖/编辑改为锁一屏工作室;经济看板增加存量健康度;主题令牌与弹层误关一并收紧。 Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState, Suspense } from "react";
|
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
import { apiMe } from "@/lib/api";
|
|
import PostComposer from "@/components/PostComposer";
|
|
|
|
function ComposeInner() {
|
|
const router = useRouter();
|
|
const searchParams = useSearchParams();
|
|
const initialBoardId = Number(searchParams.get("board")) || 0;
|
|
const [ready, setReady] = useState(false);
|
|
|
|
useEffect(() => {
|
|
apiMe()
|
|
.then((res) => {
|
|
if (!res.user) {
|
|
const q = initialBoardId > 0 ? `?board=${initialBoardId}` : "";
|
|
router.push(`/login?redirect=${encodeURIComponent(`/compose${q}`)}`);
|
|
return;
|
|
}
|
|
setReady(true);
|
|
})
|
|
.catch(() => {
|
|
router.push("/login?redirect=/compose");
|
|
});
|
|
}, [router, initialBoardId]);
|
|
|
|
if (!ready) {
|
|
return (
|
|
<div className="j13-compose-stage is-studio px-8 py-16 text-center">
|
|
<p className="meta">正在准备发帖…</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <PostComposer mode="create" initialBoardId={initialBoardId} />;
|
|
}
|
|
|
|
export default function ComposePage() {
|
|
return (
|
|
<div className="j13-compose-page">
|
|
<Suspense
|
|
fallback={
|
|
<div className="j13-compose-stage is-studio px-8 py-16 text-center">
|
|
<p className="meta">正在准备发帖…</p>
|
|
</div>
|
|
}
|
|
>
|
|
<ComposeInner />
|
|
</Suspense>
|
|
</div>
|
|
);
|
|
}
|