add liaohui
This commit is contained in:
parent
f5825dc962
commit
ab6727e23b
|
@ -16,7 +16,7 @@ function useGetTaxonomy({ type }): GetTaxonomyProps {
|
||||||
taxonomy: {
|
taxonomy: {
|
||||||
slug: type,
|
slug: type,
|
||||||
},
|
},
|
||||||
parentId : null
|
parentId: null
|
||||||
},
|
},
|
||||||
take: 11, // 只取前10个
|
take: 11, // 只取前10个
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,15 +12,7 @@ import toast from "react-hot-toast";
|
||||||
export default function StaffForm() {
|
export default function StaffForm() {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { create, update } = useStaff(); // Ensure you have these methods in your hooks
|
const { create, update } = useStaff(); // Ensure you have these methods in your hooks
|
||||||
const {
|
const {formLoading,modalOpen,setModalOpen,domainId,setDomainId,form,setFormLoading,} = useContext(UserEditorContext);
|
||||||
formLoading,
|
|
||||||
modalOpen,
|
|
||||||
setModalOpen,
|
|
||||||
domainId,
|
|
||||||
setDomainId,
|
|
||||||
form,
|
|
||||||
setFormLoading,
|
|
||||||
} = useContext(UserEditorContext);
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
@ -76,6 +68,8 @@ export default function StaffForm() {
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
console.log('cc',data);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
form.setFieldValue("username", data.username);
|
form.setFieldValue("username", data.username);
|
||||||
form.setFieldValue("showname", data.showname);
|
form.setFieldValue("showname", data.showname);
|
||||||
|
|
|
@ -35,12 +35,8 @@ interface CourseFormProviderProps {
|
||||||
editId?: string; // 添加 editId 参数
|
editId?: string; // 添加 editId 参数
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CourseDetailContext =
|
export const CourseDetailContext =createContext<CourseDetailContextType | null>(null);
|
||||||
createContext<CourseDetailContextType | null>(null);
|
export function CourseDetailProvider({children,editId}: CourseFormProviderProps) {
|
||||||
export function CourseDetailProvider({
|
|
||||||
children,
|
|
||||||
editId,
|
|
||||||
}: CourseFormProviderProps) {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { read } = useVisitor();
|
const { read } = useVisitor();
|
||||||
const { user, hasSomePermissions } = useAuth();
|
const { user, hasSomePermissions } = useAuth();
|
||||||
|
@ -61,6 +57,7 @@ export function CourseDetailProvider({
|
||||||
{ enabled: Boolean(editId) }
|
{ enabled: Boolean(editId) }
|
||||||
);
|
);
|
||||||
const canEdit = useMemo(() => {
|
const canEdit = useMemo(() => {
|
||||||
|
//先判断登陆再判断是否是作者,三个条件满足一个就有编辑权限
|
||||||
const isAuthor = user?.id === course?.authorId;
|
const isAuthor = user?.id === course?.authorId;
|
||||||
const isDept = course?.depts
|
const isDept = course?.depts
|
||||||
?.map((dept) => dept.id)
|
?.map((dept) => dept.id)
|
||||||
|
@ -68,6 +65,7 @@ export function CourseDetailProvider({
|
||||||
const isRoot = hasSomePermissions(RolePerms?.MANAGE_ANY_POST);
|
const isRoot = hasSomePermissions(RolePerms?.MANAGE_ANY_POST);
|
||||||
return isAuthor || isDept || isRoot;
|
return isAuthor || isDept || isRoot;
|
||||||
}, [user, course]);
|
}, [user, course]);
|
||||||
|
|
||||||
const [selectedLectureId, setSelectedLectureId] = useState<
|
const [selectedLectureId, setSelectedLectureId] = useState<
|
||||||
string | undefined
|
string | undefined
|
||||||
>(lectureId || undefined);
|
>(lectureId || undefined);
|
||||||
|
|
|
@ -13,14 +13,13 @@ import dayjs from "dayjs";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
|
||||||
export const CourseDetailDescription: React.FC = () => {
|
export const CourseDetailDescription: React.FC = () => {
|
||||||
const { course, isLoading, selectedLectureId, setSelectedLectureId } =
|
const { course,canEdit, isLoading, selectedLectureId, setSelectedLectureId } =
|
||||||
useContext(CourseDetailContext);
|
useContext(CourseDetailContext);
|
||||||
const { Paragraph, Title } = Typography;
|
const { Paragraph, Title } = Typography;
|
||||||
const firstLectureId = useMemo(() => {
|
const firstLectureId = useMemo(() => {
|
||||||
return course?.sections?.[0]?.lectures?.[0]?.id;
|
return course?.sections?.[0]?.lectures?.[0]?.id;
|
||||||
}, [course]);
|
}, [course]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { canEdit } = useContext(CourseDetailContext);
|
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
return (
|
return (
|
||||||
<div className="w-full bg-white shadow-md rounded-lg border border-gray-200 p-5 my-4">
|
<div className="w-full bg-white shadow-md rounded-lg border border-gray-200 p-5 my-4">
|
||||||
|
|
Loading…
Reference in New Issue