add
This commit is contained in:
parent
0597b4f5b3
commit
fb026e1fde
|
@ -1,6 +1,7 @@
|
||||||
import { api } from "@nice/client";
|
import { api } from "@nice/client";
|
||||||
import { courseDetailSelect, CourseDto } from "@nice/common";
|
import { courseDetailSelect, CourseDto } from "@nice/common";
|
||||||
import React, { createContext, ReactNode, useState } from "react";
|
import React, { createContext, ReactNode, useEffect, useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
interface CourseDetailContextType {
|
interface CourseDetailContextType {
|
||||||
editId?: string; // 添加 editId
|
editId?: string; // 添加 editId
|
||||||
|
@ -21,7 +22,7 @@ export function CourseDetailProvider({
|
||||||
children,
|
children,
|
||||||
editId,
|
editId,
|
||||||
}: CourseFormProviderProps) {
|
}: CourseFormProviderProps) {
|
||||||
|
const navigate = useNavigate();
|
||||||
const { data: course, isLoading }: { data: CourseDto; isLoading: boolean } =
|
const { data: course, isLoading }: { data: CourseDto; isLoading: boolean } =
|
||||||
(api.post as any).findFirst.useQuery(
|
(api.post as any).findFirst.useQuery(
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,10 @@ export function CourseDetailProvider({
|
||||||
const [selectedLectureId, setSelectedLectureId] = useState<
|
const [selectedLectureId, setSelectedLectureId] = useState<
|
||||||
string | undefined
|
string | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
useEffect(() => {
|
||||||
|
navigate(``)
|
||||||
|
|
||||||
|
}, [selectedLectureId, editId]);
|
||||||
const [isHeaderVisible, setIsHeaderVisible] = useState(true); // 新增
|
const [isHeaderVisible, setIsHeaderVisible] = useState(true); // 新增
|
||||||
return (
|
return (
|
||||||
<CourseDetailContext.Provider
|
<CourseDetailContext.Provider
|
||||||
|
|
Loading…
Reference in New Issue