add
This commit is contained in:
parent
779e6ede72
commit
9e348fcfc3
|
@ -66,8 +66,6 @@ export async function updatePostViewCount(id: string, type: VisitType) {
|
||||||
where: { id },
|
where: { id },
|
||||||
select: { id: true, meta: true, type: true },
|
select: { id: true, meta: true, type: true },
|
||||||
});
|
});
|
||||||
console.log(post?.type);
|
|
||||||
console.log('updatePostViewCount');
|
|
||||||
const metaFieldMap = {
|
const metaFieldMap = {
|
||||||
[VisitType.READED]: 'views',
|
[VisitType.READED]: 'views',
|
||||||
[VisitType.LIKE]: 'likes',
|
[VisitType.LIKE]: 'likes',
|
||||||
|
@ -105,7 +103,6 @@ export async function updatePostViewCount(id: string, type: VisitType) {
|
||||||
type: type,
|
type: type,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log(courseViews);
|
|
||||||
await db.post.update({
|
await db.post.update({
|
||||||
where: { id: course.id },
|
where: { id: course.id },
|
||||||
data: {
|
data: {
|
||||||
|
@ -126,7 +123,6 @@ export async function updatePostViewCount(id: string, type: VisitType) {
|
||||||
type: type,
|
type: type,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log('totalViews', totalViews);
|
|
||||||
await db.post.update({
|
await db.post.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -25,14 +25,17 @@ export default function MindEditor({ id }: { id?: string }) {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const [instance, setInstance] = useState<MindElixirInstance | null>(null);
|
const [instance, setInstance] = useState<MindElixirInstance | null>(null);
|
||||||
const { isAuthenticated, user, hasSomePermissions } = useAuth();
|
const { isAuthenticated, user, hasSomePermissions } = useAuth();
|
||||||
const { read } = useVisitor()
|
const { read } = useVisitor();
|
||||||
const { data: post, isLoading }: { data: PathDto; isLoading: boolean } =
|
const { data: post, isLoading }: { data: PathDto; isLoading: boolean } =
|
||||||
api.post.findFirst.useQuery({
|
api.post.findFirst.useQuery(
|
||||||
where: {
|
{
|
||||||
id,
|
where: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
select: postDetailSelect,
|
||||||
},
|
},
|
||||||
select: postDetailSelect,
|
{ enabled: Boolean(id) }
|
||||||
}, { enabled: Boolean(id) });
|
);
|
||||||
const canEdit: boolean = useMemo(() => {
|
const canEdit: boolean = useMemo(() => {
|
||||||
const isAuth = isAuthenticated && user?.id === post?.author?.id;
|
const isAuth = isAuthenticated && user?.id === post?.author?.id;
|
||||||
return !!id || isAuth || hasSomePermissions(RolePerms.MANAGE_ANY_POST);
|
return !!id || isAuth || hasSomePermissions(RolePerms.MANAGE_ANY_POST);
|
||||||
|
@ -64,8 +67,8 @@ export default function MindEditor({ id }: { id?: string }) {
|
||||||
deptIds: deptIds,
|
deptIds: deptIds,
|
||||||
};
|
};
|
||||||
post.terms?.forEach((term) => {
|
post.terms?.forEach((term) => {
|
||||||
formData[term.taxonomyId] = term.id // 假设 taxonomyName是您在 Form.Item 中使用的name
|
formData[term.taxonomyId] = term.id; // 假设 taxonomyName是您在 Form.Item 中使用的name
|
||||||
})
|
});
|
||||||
form.setFieldsValue(formData);
|
form.setFieldsValue(formData);
|
||||||
}
|
}
|
||||||
}, [post, form, instance, id]);
|
}, [post, form, instance, id]);
|
||||||
|
@ -159,22 +162,18 @@ export default function MindEditor({ id }: { id?: string }) {
|
||||||
}
|
}
|
||||||
console.log(result);
|
console.log(result);
|
||||||
},
|
},
|
||||||
(error) => { },
|
(error) => {},
|
||||||
`mind-thumb-${new Date().toString()}`
|
`mind-thumb-${new Date().toString()}`
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
containerRef.current.style.height = `${Math.floor(window.innerHeight - 271)}px`;
|
containerRef.current.style.height = `${Math.floor(window.innerHeight - 271)}px`;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<div className={` flex-col flex `}>
|
<div className={` flex-col flex `}>
|
||||||
{canEdit && taxonomies && (
|
{canEdit && taxonomies && (
|
||||||
<Form
|
<Form form={form} className=" bg-white p-4 border-b">
|
||||||
form={form}
|
|
||||||
className=" bg-white p-4 border-b">
|
|
||||||
<div className="flex items-center justify-between gap-4">
|
<div className="flex items-center justify-between gap-4">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
{taxonomies.map((tax, index) => (
|
{taxonomies.map((tax, index) => (
|
||||||
|
@ -203,14 +202,16 @@ export default function MindEditor({ id }: { id?: string }) {
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
{canEdit && <Button
|
{canEdit && (
|
||||||
ghost
|
<Button
|
||||||
type="primary"
|
ghost
|
||||||
icon={<SaveOutlined></SaveOutlined>}
|
type="primary"
|
||||||
onSubmit={(e) => e.preventDefault()}
|
icon={<SaveOutlined></SaveOutlined>}
|
||||||
onClick={handleSave}>
|
onSubmit={(e) => e.preventDefault()}
|
||||||
{id ? "更新" : "保存"}
|
onClick={handleSave}>
|
||||||
</Button>}
|
{id ? "更新" : "保存"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
|
@ -220,24 +221,20 @@ export default function MindEditor({ id }: { id?: string }) {
|
||||||
onContextMenu={(e) => e.preventDefault()}
|
onContextMenu={(e) => e.preventDefault()}
|
||||||
/>
|
/>
|
||||||
{canEdit && instance && <NodeMenu mind={instance} />}
|
{canEdit && instance && <NodeMenu mind={instance} />}
|
||||||
{
|
{isLoading && (
|
||||||
isLoading && (
|
<div
|
||||||
<div
|
className="py-64 justify-center flex"
|
||||||
className="py-64 justify-center flex"
|
style={{ height: "calc(100vh - 271px)" }}>
|
||||||
style={{ height: "calc(100vh - 271px)" }}>
|
<Spin size="large"></Spin>
|
||||||
<Spin size="large"></Spin>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)
|
{!post && id && !isLoading && (
|
||||||
}
|
<div
|
||||||
{
|
className="py-64"
|
||||||
!post && id && !isLoading && (
|
style={{ height: "calc(100vh - 271px)" }}>
|
||||||
<div
|
<Empty></Empty>
|
||||||
className="py-64"
|
</div>
|
||||||
style={{ height: "calc(100vh - 271px)" }}>
|
)}
|
||||||
<Empty></Empty>
|
</div>
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</div >
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { api } from "@nice/client";
|
||||||
|
import { Select } from "antd";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
export default function PostSelect() {
|
||||||
|
api.post.findMany.useQuery({});
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Select
|
||||||
|
options={[{ value: "id1", label: <></> }]}
|
||||||
|
onSearch={(inputValue) => setSearch(inputValue)}></Select>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue