diff --git a/apps/admin/src/view/Course/Create/Guide/index.tsx b/apps/admin/src/view/Course/Create/Guide/index.tsx index cc84c27..29fac5e 100644 --- a/apps/admin/src/view/Course/Create/Guide/index.tsx +++ b/apps/admin/src/view/Course/Create/Guide/index.tsx @@ -85,35 +85,65 @@ export default function Guide(props: IProps) { }; useEffect(() => { - if (props.defaultValue) - vditorRef.current = new Vditor("vditor", { - height: 600, - cache: { - id: props.id, - enable: false, + vditorRef.current = new Vditor("vditor", { + height: 600, + cache: { + id: props.id, + enable: false, + }, + toolbar: [...toolbar, "|", submitTool], + value: props.defaultValue ?? "", + hint: { delay: 200, emoji }, + counter: { enable: true }, + preview: { actions: ["desktop", "mobile"] }, + after: () => console.log("[info] vditor init success..."), + upload: { + accept: "image/*", + url: "/api/vod/oss/image/upload", + multiple: false, + success(_, res) { + const { code, data, msg } = JSON.parse(res); + if (code === 10000) { + message.success("上传成功"); + const { name, url } = data; + vditorRef.current?.insertValue(`![${name}](${url})`); + } else { + message.error(msg); + } }, - toolbar: [...toolbar, "|", submitTool], - value: props.defaultValue ?? "", - hint: { delay: 200, emoji }, - counter: { enable: true }, - preview: { actions: ["desktop", "mobile"] }, - after: () => console.log("[info] vditor init success..."), - upload: { - accept: "image/*", - url: "/api/vod/oss/image/upload", - multiple: false, - success(_, res) { - const { code, data, msg } = JSON.parse(res); - if (code === 10000) { - message.success("上传成功"); - const { name, url } = data; - vditorRef.current?.insertValue(`![${name}](${url})`); - } else { - message.error(msg); - } - }, + }, + }); + }, []); + + useEffect(() => { + vditorRef.current = new Vditor("vditor", { + height: 600, + cache: { + id: props.id, + enable: false, + }, + toolbar: [...toolbar, "|", submitTool], + value: props.defaultValue ?? "", + hint: { delay: 200, emoji }, + counter: { enable: true }, + preview: { actions: ["desktop", "mobile"] }, + after: () => console.log("[info] vditor init success..."), + upload: { + accept: "image/*", + url: "/api/vod/oss/image/upload", + multiple: false, + success(_, res) { + const { code, data, msg } = JSON.parse(res); + if (code === 10000) { + message.success("上传成功"); + const { name, url } = data; + vditorRef.current?.insertValue(`![${name}](${url})`); + } else { + message.error(msg); + } }, - }); + }, + }); }, [props.defaultValue]); return ( diff --git a/apps/web/src/view/Course/components/Timeline/index.tsx b/apps/web/src/view/Course/components/Timeline/index.tsx index c68e963..34a46c0 100644 --- a/apps/web/src/view/Course/components/Timeline/index.tsx +++ b/apps/web/src/view/Course/components/Timeline/index.tsx @@ -80,7 +80,7 @@ function Timeline(props: IProps) { }, [cursorStatic.top]); useEffect(() => { - if (props.data && orbitRef.current) { + if (props.data.length > 0 && orbitRef.current) { setTimelineData(filterYearOnce(props.data)); // 全部的月份数数量平均划分 const avg = orbitRef.current.clientHeight / props.data.length; @@ -90,7 +90,7 @@ function Timeline(props: IProps) { useEffect(() => { window.addEventListener("resize", () => { - if (props.data && orbitRef.current) { + if (props.data.length > 0 && orbitRef.current) { setTimelineData(filterYearOnce(props.data)); // 全部的月份数数量平均划分 const avg = orbitRef.current.clientHeight / props.data.length; @@ -98,7 +98,7 @@ function Timeline(props: IProps) { } }); return () => window.removeEventListener("resize", () => {}); - }, []); + }, [props.data]); return (
{ const { top, height } = p; - //左侧区域高度 - const { scrollHeight, clientHeight } = thumbnailRef.current!; - scale.current = (scrollHeight - clientHeight) / height; - thumbnailRef.current!.scrollTop = top * scale.current; + if (thumbnailRef.current) { + //左侧区域高度 + const { scrollHeight, clientHeight } = thumbnailRef.current; + if (scrollHeight === clientHeight) return; + scale.current = (scrollHeight - clientHeight) / height; + thumbnailRef.current!.scrollTop = top * scale.current; + } }; /**