add
This commit is contained in:
parent
779e6ede72
commit
9e348fcfc3
|
@ -66,8 +66,6 @@ export async function updatePostViewCount(id: string, type: VisitType) {
|
|||
where: { id },
|
||||
select: { id: true, meta: true, type: true },
|
||||
});
|
||||
console.log(post?.type);
|
||||
console.log('updatePostViewCount');
|
||||
const metaFieldMap = {
|
||||
[VisitType.READED]: 'views',
|
||||
[VisitType.LIKE]: 'likes',
|
||||
|
@ -105,7 +103,6 @@ export async function updatePostViewCount(id: string, type: VisitType) {
|
|||
type: type,
|
||||
},
|
||||
});
|
||||
console.log(courseViews);
|
||||
await db.post.update({
|
||||
where: { id: course.id },
|
||||
data: {
|
||||
|
@ -126,7 +123,6 @@ export async function updatePostViewCount(id: string, type: VisitType) {
|
|||
type: type,
|
||||
},
|
||||
});
|
||||
console.log('totalViews', totalViews);
|
||||
await db.post.update({
|
||||
where: { id },
|
||||
data: {
|
||||
|
|
|
@ -25,14 +25,17 @@ export default function MindEditor({ id }: { id?: string }) {
|
|||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [instance, setInstance] = useState<MindElixirInstance | null>(null);
|
||||
const { isAuthenticated, user, hasSomePermissions } = useAuth();
|
||||
const { read } = useVisitor()
|
||||
const { read } = useVisitor();
|
||||
const { data: post, isLoading }: { data: PathDto; isLoading: boolean } =
|
||||
api.post.findFirst.useQuery({
|
||||
api.post.findFirst.useQuery(
|
||||
{
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
select: postDetailSelect,
|
||||
}, { enabled: Boolean(id) });
|
||||
},
|
||||
{ enabled: Boolean(id) }
|
||||
);
|
||||
const canEdit: boolean = useMemo(() => {
|
||||
const isAuth = isAuthenticated && user?.id === post?.author?.id;
|
||||
return !!id || isAuth || hasSomePermissions(RolePerms.MANAGE_ANY_POST);
|
||||
|
@ -64,8 +67,8 @@ export default function MindEditor({ id }: { id?: string }) {
|
|||
deptIds: deptIds,
|
||||
};
|
||||
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);
|
||||
}
|
||||
}, [post, form, instance, id]);
|
||||
|
@ -164,17 +167,13 @@ export default function MindEditor({ id }: { id?: string }) {
|
|||
);
|
||||
};
|
||||
useEffect(() => {
|
||||
|
||||
containerRef.current.style.height = `${Math.floor(window.innerHeight - 271)}px`;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
<div className={` flex-col flex `}>
|
||||
{canEdit && taxonomies && (
|
||||
<Form
|
||||
form={form}
|
||||
className=" bg-white p-4 border-b">
|
||||
<Form form={form} className=" bg-white p-4 border-b">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-4">
|
||||
{taxonomies.map((tax, index) => (
|
||||
|
@ -203,14 +202,16 @@ export default function MindEditor({ id }: { id?: string }) {
|
|||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
{canEdit && <Button
|
||||
{canEdit && (
|
||||
<Button
|
||||
ghost
|
||||
type="primary"
|
||||
icon={<SaveOutlined></SaveOutlined>}
|
||||
onSubmit={(e) => e.preventDefault()}
|
||||
onClick={handleSave}>
|
||||
{id ? "更新" : "保存"}
|
||||
</Button>}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Form>
|
||||
)}
|
||||
|
@ -220,24 +221,20 @@ export default function MindEditor({ id }: { id?: string }) {
|
|||
onContextMenu={(e) => e.preventDefault()}
|
||||
/>
|
||||
{canEdit && instance && <NodeMenu mind={instance} />}
|
||||
{
|
||||
isLoading && (
|
||||
{isLoading && (
|
||||
<div
|
||||
className="py-64 justify-center flex"
|
||||
style={{ height: "calc(100vh - 271px)" }}>
|
||||
<Spin size="large"></Spin>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
!post && id && !isLoading && (
|
||||
)}
|
||||
{!post && id && !isLoading && (
|
||||
<div
|
||||
className="py-64"
|
||||
style={{ height: "calc(100vh - 271px)" }}>
|
||||
<Empty></Empty>
|
||||
</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