diff --git a/src/components/admin/DataTable.tsx b/src/components/admin/DataTable.tsx index f0928c7..2b43541 100644 --- a/src/components/admin/DataTable.tsx +++ b/src/components/admin/DataTable.tsx @@ -14,7 +14,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; -import { useEffect, useMemo, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { Card } from "../ui/card"; import { ScrollArea } from "@radix-ui/react-scroll-area"; import PageTransition from "../PageTransition"; @@ -51,15 +51,14 @@ export default function DataTable({ const { data, isLoading, error, mutate } = useSWR<{ data: []; total: number; - }>(dynamicUrl, fetcher, { - refreshInterval: 2000, - }); + }>(dynamicUrl, fetcher); useEffect(() => { if (data) { setTotal(data.total); } }, [data]); useEffect(() => { + // 监听从父组件的传来的表格左下角的功能区的动态mutateFlag,从而refetch数据 mutate(); console.log("mutate"); }, [mutateFlag]); diff --git a/src/context/ReportDetailsProvider.tsx b/src/context/ReportDetailsProvider.tsx index 70ed6a1..a61e2b0 100644 --- a/src/context/ReportDetailsProvider.tsx +++ b/src/context/ReportDetailsProvider.tsx @@ -52,6 +52,7 @@ export default function ReportDetailsProvider({ const { mutate } = useUncompletedReports(); const [workers, setWorkers] = useState([]); const [selectedWorker, setSelectedWorker] = useState(""); + // 加载维修工人菜单 useEffect(() => { fetch("/api/workers") .then((res) => res.json())