diff --git a/SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx b/SuperAdmin/app/dashboard/projects/[id]/edit/page.tsx index 91a3ccb4..7ec4c486 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 f5b9e064..d0ac9f7c 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 () => {