From acd7e9005dc71daae75140c20df945c78747dec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Thu, 24 Apr 2025 16:29:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=95=B4=E4=B8=AA=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=A1=B5=E9=9D=A2=E5=A4=84=E7=90=86id?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F=EF=BC=8C=E7=94=B1=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20params.id=20=20=E7=9A=84=E6=96=B9=E5=BC=8F=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0=20React.use(params)=20=E8=BF=99?= =?UTF-8?q?=E7=A7=8D=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx | 12 +++++++++--- SuperAdmin/app/dashboard/projects/[id]/page.tsx | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx b/SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx index 91a3ccb4b..7ec4c4863 100644 --- a/SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx +++ b/SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx @@ -1,7 +1,7 @@ "use client" -import type React from "react" -import { useState, useEffect, use } from "react" +import * as React from "react" +import { useState, useEffect } from "react" import { useRouter } from "next/navigation" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" @@ -12,6 +12,12 @@ import { ArrowLeft, Plus, Trash } from "lucide-react" import Link from "next/link" import { toast, Toaster } from "sonner" +// 为React.use添加类型声明 +declare module 'react' { + function use(promise: Promise): T; + function use(value: T): T; +} + interface Device { id: number memo: string @@ -40,7 +46,7 @@ export default function EditProjectPage({ params }: { params: { id: string } }) const [project, setProject] = useState(null) const [password, setPassword] = useState("") const [confirmPassword, setConfirmPassword] = useState("") - const id = params.id + const { id } = React.use(params) useEffect(() => { const fetchProject = async () => { diff --git a/SuperAdmin/app/dashboard/projects/[id]/page.tsx b/SuperAdmin/app/dashboard/projects/[id]/page.tsx index f5b9e0642..d0ac9f7c3 100644 --- a/SuperAdmin/app/dashboard/projects/[id]/page.tsx +++ b/SuperAdmin/app/dashboard/projects/[id]/page.tsx @@ -1,5 +1,6 @@ "use client" +import React from "react" import { useState, useEffect } from "react" import { useRouter } from "next/navigation" import Link from "next/link" @@ -51,7 +52,14 @@ interface SubUser { typeId: number } -export default function ProjectDetailPage({ params }: { params: { id: string } }) { +interface ProjectDetailPageProps { + params: { + id: string + } +} + +export default function ProjectDetailPage({ params }: ProjectDetailPageProps) { + const { id } = use(params) const router = useRouter() const [isLoading, setIsLoading] = useState(true) const [isDevicesLoading, setIsDevicesLoading] = useState(false) @@ -60,7 +68,6 @@ export default function ProjectDetailPage({ params }: { params: { id: string } } const [devices, setDevices] = useState([]) const [subUsers, setSubUsers] = useState([]) const [activeTab, setActiveTab] = useState("overview") - const { id } = use(params) useEffect(() => { const fetchProjectProfile = async () => {