This commit is contained in:
Rao 2025-03-28 13:20:54 +08:00
parent 1fc1aa368c
commit f9533623d2
12 changed files with 23 additions and 5 deletions

View File

@ -134,7 +134,7 @@ export class PostService extends BaseTreeService<Prisma.PostDelegate> {
return result;
}
async update(args: Prisma.PostUpdateArgs, staff?: UserProfile) {
args.data.authorId = staff?.id;
//args.data.authorId = staff?.id;
args.data.updatedAt = dayjs().toDate();
const result = await super.update(args);
EventBus.emit('dataChanged', {

View File

@ -13,6 +13,7 @@ export function CoursesContainer() {
pageSize: 12,
where: {
type: PostType.COURSE,
deletedAt: null,
...termsCondition,
...searchCondition,
},

View File

@ -92,6 +92,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({
page: 1,
pageSize: initialVisibleCoursesCount,
where: {
deletedAt:null,
terms: !(selectedCategory === "全部")
? {
some: {

View File

@ -14,6 +14,7 @@ export default function MyDutyPathContainer() {
params={{
pageSize: 12,
where: {
deletedAt: null,
type: PostType.PATH,
authorId: user?.id,
...termsCondition,

View File

@ -15,6 +15,7 @@ export default function MyDutyListContainer() {
params={{
pageSize: 12,
where: {
deletedAt:null,
type: PostType.COURSE,
authorId: user.id,
...termsCondition,

View File

@ -15,6 +15,7 @@ export default function MyLearningListContainer() {
params={{
pageSize: 12,
where: {
deletedAt: null,
type: PostType.COURSE,
students: {
some: {

View File

@ -22,7 +22,7 @@ export default function MyPathListContainer() {
id: user?.id,
},
},
deletedAt: null,
...termsCondition,
...searchCondition,
},

View File

@ -16,6 +16,7 @@ export function PathListContainer() {
type: PostType.PATH,
...termsCondition,
...searchCondition,
deletedAt:null
},
}}
cols={4}></PostList>

View File

@ -25,6 +25,7 @@ export default function SearchListContainer() {
type: searchMode === "both" ? undefined : searchMode,
...termsCondition,
...searchCondition,
deletedAt: null,
},
}}
cols={4}></PostList>

View File

@ -39,6 +39,11 @@ export default function MindEditor({ id }: { id?: string }) {
const { isAuthenticated, user, hasSomePermissions } = useAuth();
const { read } = useVisitor();
const queryClient = useQueryClient();
useEffect(()=>{
console.log("post",post)
console.log("user",user)
console.log(canEdit)
})
// const { data: post, isLoading }: { data: PathDto; isLoading: boolean } =
// api.post.findFirst.useQuery(
// {
@ -56,11 +61,13 @@ export default function MindEditor({ id }: { id?: string }) {
})
const canEdit: boolean = useMemo(() => {
const isAuth = isAuthenticated && user?.id === post?.author?.id;
return (
isAuthenticated &&
(!id || isAuth || hasSomePermissions(RolePerms.MANAGE_ANY_POST))
);
}, [user]);
}, [user,post]);
const navigate = useNavigate();
const { create, update } = usePost();
@ -141,12 +148,14 @@ export default function MindEditor({ id }: { id?: string }) {
//挂载实例
setInstance(mind);
}, [canEdit]);
}, [canEdit,post]);
useEffect(() => {
handleIcon()
});
useEffect(() => {
if ((!id || post) && instance) {
containerRef.current.style.height = `${Math.floor(window.innerHeight - 271)}px`;
containerRef.current.style.width = `100%`;
containerRef.current.hidden = false;
instance.toCenter();
if ((post as any as PathDto)?.meta?.nodeData) {
@ -154,6 +163,7 @@ export default function MindEditor({ id }: { id?: string }) {
}
}
}, [id, post, instance]);
//保存 按钮 函数
const handleSave = async () => {
if (!instance) return;
@ -175,6 +185,7 @@ export default function MindEditor({ id }: { id?: string }) {
id,
},
data: {
//authorId: post.authorId,
title: data.nodeData.topic,
meta: {
...data,

View File

@ -62,7 +62,7 @@ export default function PostSelect({
where: safeOR([
{ ...idCondition },
{ ...searchCondition, ...(params?.where || {}) },
{...(params?.where || {}), ...searchCondition },
]),
select: { ...postDetailSelect, ...(params?.select || {}) },
take: 15,

Binary file not shown.