This commit is contained in:
ditiqi 2025-02-27 19:31:49 +08:00
commit eb7206d987
5 changed files with 11 additions and 13 deletions

View File

@ -11,7 +11,7 @@ export function MainLayout() {
<MainProvider>
<div className=" min-h-screen bg-gray-100">
<MainHeader />
<Content className="min-h-screen flex-grow pt-12 bg-gray-50 ">
<Content className="min-h-screen flex-grow pt-14 bg-gray-50 ">
<Outlet />
</Content>
<MainFooter />

View File

@ -24,7 +24,7 @@ const MIND_OPTIONS = {
draggable: true,
contextMenu: true,
toolBar: true,
//nodeMenu: true,
nodeMenu: true,
keypress: true,
locale: "zh_CN" as const,
theme: {
@ -66,8 +66,8 @@ export default function MindEditor({ id }: { id?: string }) {
});
const canEdit: boolean = useMemo(() => {
//登录了且是作者、超管、无id新建模式
const isAuth = isAuthenticated && user?.id == post?.authorId;
return !id || isAuth || hasSomePermissions(RolePerms.MANAGE_ANY_POST);
const isAuth = isAuthenticated && user?.id == post?.author.id
return !Boolean(id) || isAuth || hasSomePermissions(RolePerms.MANAGE_ANY_POST);
}, [user])
const navigate = useNavigate();
const { create, update } = usePost();
@ -183,14 +183,11 @@ export default function MindEditor({ id }: { id?: string }) {
);
};
return (
<div className=" flex flex-col w-screen max-h-screen border rounded-lg overflow-hidden">
<div className="grid grid-cols-1 flex-col w-[90vw] my-5 h-[90vh] border rounded-lg mx-auto">
{canEdit && taxonomies && (
<Form
onFinish={(values) => {
console.log(values);
}}
form={form}
className=" bg-white p-2 ">
className=" bg-white p-4 ">
<div className="flex items-center justify-between gap-4">
<div className="flex items-center gap-4">
{taxonomies.map((tax, index) => (
@ -217,13 +214,13 @@ export default function MindEditor({ id }: { id?: string }) {
/>
</Form.Item>
</div>
<Button ghost type="primary" onClick={handleSave}>
<Button ghost type="primary" onSubmit={(e) => e.preventDefault()} onClick={handleSave}>
{id ? "更新" : "保存"}
</Button>
</div>
</Form>
)}
<div ref={containerRef} className="mind-editor min-h-screen" onContextMenu={(e)=>e.preventDefault()} />
<div ref={containerRef} className="mind-editor" onContextMenu={(e)=>e.preventDefault()} />
{canEdit && instance && <NodeMenu mind={instance} />}
{isLoading && (
<div

View File

@ -8,7 +8,7 @@ export default function CourseCard({ post }: { post: PostDto }) {
post={post}
onClick={() => {
navigate(`/course/${post?.id}/detail`);
window.scrollTo({ top: 0, behavior: "smooth" });
}}></PostCard>
);
}

View File

@ -9,6 +9,7 @@ export default function PathCard({ post }: { post: PostDto }) {
post={post}
onClick={() => {
navigate(`/path/editor/${post?.id}`);
window.scrollTo({ top: 0, behavior: "smooth" });
}}></PostCard>
);
}

View File

@ -162,6 +162,6 @@
}
.mind-editor {
height: calc(100vh - 285px);
height: calc(82vh);
width: 100%;
}