- 修复 folder-aciton.ts 文件名拼写错误为 folder-action.ts - 修复所有导入路径中的拼写错误 - 添加 repoGetPublicFolderById 和 actionGetPublicFolderById - 创建 ExploreDetailClient 详情页组件 - /explore/[id] 现在显示文件夹详情和链接到 /folders/[id] - 添加 exploreDetail 中英文翻译
38 lines
1023 B
TypeScript
38 lines
1023 B
TypeScript
import { redirect } from "next/navigation";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { InFolder } from "./InFolder";
|
|
import { auth } from "@/auth";
|
|
import { headers } from "next/headers";
|
|
import { actionGetFolderVisibility } from "@/modules/folder/folder-action";
|
|
|
|
export default async function FoldersPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ folder_id: number; }>;
|
|
}) {
|
|
const session = await auth.api.getSession({ headers: await headers() });
|
|
const { folder_id } = await params;
|
|
const t = await getTranslations("folder_id");
|
|
|
|
if (!folder_id) {
|
|
redirect("/folders");
|
|
}
|
|
|
|
const folderInfo = (await actionGetFolderVisibility(Number(folder_id))).data;
|
|
|
|
if (!folderInfo) {
|
|
redirect("/folders");
|
|
}
|
|
|
|
const isOwner = session?.user?.id === folderInfo.userId;
|
|
const isPublic = folderInfo.visibility === "PUBLIC";
|
|
|
|
if (!isOwner && !isPublic) {
|
|
redirect("/folders");
|
|
}
|
|
|
|
const isReadOnly = !isOwner;
|
|
|
|
return <InFolder folderId={Number(folder_id)} isReadOnly={isReadOnly} />;
|
|
}
|