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