超管后台 - 将整个前端部分页面处理id的方式,由使用 params.id 的方式全部迁移到 React.use(params) 这种方式

This commit is contained in:
柳清爽
2025-04-22 18:23:58 +08:00
parent c18a81e22d
commit 793ee5cb4f
7 changed files with 477 additions and 422 deletions

View File

@@ -60,7 +60,7 @@ export default function EditAdminPage({ params }: { params: { id: string } }) {
if (adminResponse.code === 200 && adminResponse.data) {
const adminData = adminResponse.data;
setAdminInfo(adminData)
setAccount(adminData.account)
setAccount(adminData.account || adminData.name || adminData.username || "")
setUserName(adminData.username || "")
const isEditingSelf = currentAdminInfo && parseInt(id) === currentAdminInfo.id
@@ -122,6 +122,7 @@ export default function EditAdminPage({ params }: { params: { id: string } }) {
const updateData: any = {
account: account,
username: username,
name: account,
}
if (password) {

View File

@@ -1,6 +1,6 @@
"use client"
import { useEffect, useState } from "react"
import { useEffect, useState, use } from "react"
import Link from "next/link"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
@@ -55,6 +55,8 @@ const detailData = {
}
export default function CustomerDetailPage({ params }: { params: { id: string } }) {
const { id } = use(params)
const [customer, setCustomer] = useState<CustomerDetail | null>(null)
const [isLoading, setIsLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
@@ -63,7 +65,7 @@ export default function CustomerDetailPage({ params }: { params: { id: string }
const fetchCustomerDetail = async () => {
try {
setIsLoading(true)
const response = await getCustomerDetail(params.id)
const response = await getCustomerDetail(id)
if (response.code === 200) {
setCustomer(response.data)
setError(null)
@@ -78,7 +80,7 @@ export default function CustomerDetailPage({ params }: { params: { id: string }
}
fetchCustomerDetail()
}, [params.id])
}, [id])
if (isLoading) {
return <div className="flex items-center justify-center min-h-screen">...</div>

View File

@@ -1,7 +1,7 @@
"use client"
import type React from "react"
import { useState, useEffect } from "react"
import { useState, useEffect, use } from "react"
import { useRouter } from "next/navigation"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
@@ -18,7 +18,7 @@ interface Device {
}
export default function EditProjectPage({ params }: { params: { id: string } }) {
const id = params.id
const { id } = use(params)
const router = useRouter()
const [isSubmitting, setIsSubmitting] = useState(false)

View File

@@ -1,6 +1,6 @@
"use client"
import { useState } from "react"
import { useState, use } from "react"
import Link from "next/link"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
@@ -31,6 +31,8 @@ const projectData = {
}
export default function ProjectDetailPage({ params }: { params: { id: string } }) {
const { id } = use(params)
const [activeTab, setActiveTab] = useState("overview")
return (
@@ -45,7 +47,7 @@ export default function ProjectDetailPage({ params }: { params: { id: string } }
<h1 className="text-2xl font-bold">{projectData.name}</h1>
</div>
<Button asChild>
<Link href={`/dashboard/projects/${params.id}/edit`}>
<Link href={`/dashboard/projects/${id}/edit`}>
<Edit className="mr-2 h-4 w-4" />
</Link>
</Button>

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@
"embla-carousel-react": "8.5.1",
"input-otp": "1.4.1",
"lucide-react": "^0.454.0",
"next": "15.2.4",
"next": "^15.3.1",
"next-themes": "^0.4.4",
"react": "^19",
"react-day-picker": "8.10.1",
@@ -67,4 +67,4 @@
"tailwindcss": "^3.4.17",
"typescript": "^5"
}
}
}

View File

@@ -1,5 +0,0 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false