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; return result;
} }
async update(args: Prisma.PostUpdateArgs, staff?: UserProfile) { async update(args: Prisma.PostUpdateArgs, staff?: UserProfile) {
args.data.authorId = staff?.id; //args.data.authorId = staff?.id;
args.data.updatedAt = dayjs().toDate(); args.data.updatedAt = dayjs().toDate();
const result = await super.update(args); const result = await super.update(args);
EventBus.emit('dataChanged', { EventBus.emit('dataChanged', {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.