超管后台 - 将整个前端部分页面处理id的方式,由使用 params.id 的方式全部迁移到 React.use(params) 这种方式
This commit is contained in:
@@ -60,7 +60,7 @@ export default function EditAdminPage({ params }: { params: { id: string } }) {
|
|||||||
if (adminResponse.code === 200 && adminResponse.data) {
|
if (adminResponse.code === 200 && adminResponse.data) {
|
||||||
const adminData = adminResponse.data;
|
const adminData = adminResponse.data;
|
||||||
setAdminInfo(adminData)
|
setAdminInfo(adminData)
|
||||||
setAccount(adminData.account)
|
setAccount(adminData.account || adminData.name || adminData.username || "")
|
||||||
setUserName(adminData.username || "")
|
setUserName(adminData.username || "")
|
||||||
|
|
||||||
const isEditingSelf = currentAdminInfo && parseInt(id) === currentAdminInfo.id
|
const isEditingSelf = currentAdminInfo && parseInt(id) === currentAdminInfo.id
|
||||||
@@ -122,6 +122,7 @@ export default function EditAdminPage({ params }: { params: { id: string } }) {
|
|||||||
const updateData: any = {
|
const updateData: any = {
|
||||||
account: account,
|
account: account,
|
||||||
username: username,
|
username: username,
|
||||||
|
name: account,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password) {
|
if (password) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState, use } from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
@@ -55,6 +55,8 @@ const detailData = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function CustomerDetailPage({ params }: { params: { id: string } }) {
|
export default function CustomerDetailPage({ params }: { params: { id: string } }) {
|
||||||
|
const { id } = use(params)
|
||||||
|
|
||||||
const [customer, setCustomer] = useState<CustomerDetail | null>(null)
|
const [customer, setCustomer] = useState<CustomerDetail | null>(null)
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
@@ -63,7 +65,7 @@ export default function CustomerDetailPage({ params }: { params: { id: string }
|
|||||||
const fetchCustomerDetail = async () => {
|
const fetchCustomerDetail = async () => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
const response = await getCustomerDetail(params.id)
|
const response = await getCustomerDetail(id)
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
setCustomer(response.data)
|
setCustomer(response.data)
|
||||||
setError(null)
|
setError(null)
|
||||||
@@ -78,7 +80,7 @@ export default function CustomerDetailPage({ params }: { params: { id: string }
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchCustomerDetail()
|
fetchCustomerDetail()
|
||||||
}, [params.id])
|
}, [id])
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <div className="flex items-center justify-center min-h-screen">加载中...</div>
|
return <div className="flex items-center justify-center min-h-screen">加载中...</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import type React from "react"
|
import type React from "react"
|
||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect, use } from "react"
|
||||||
import { useRouter } from "next/navigation"
|
import { useRouter } from "next/navigation"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
@@ -18,7 +18,7 @@ interface Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function EditProjectPage({ params }: { params: { id: string } }) {
|
export default function EditProjectPage({ params }: { params: { id: string } }) {
|
||||||
const id = params.id
|
const { id } = use(params)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState } from "react"
|
import { useState, use } from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
@@ -31,6 +31,8 @@ const projectData = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ProjectDetailPage({ params }: { params: { id: string } }) {
|
export default function ProjectDetailPage({ params }: { params: { id: string } }) {
|
||||||
|
const { id } = use(params)
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState("overview")
|
const [activeTab, setActiveTab] = useState("overview")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -45,7 +47,7 @@ export default function ProjectDetailPage({ params }: { params: { id: string } }
|
|||||||
<h1 className="text-2xl font-bold">{projectData.name}</h1>
|
<h1 className="text-2xl font-bold">{projectData.name}</h1>
|
||||||
</div>
|
</div>
|
||||||
<Button asChild>
|
<Button asChild>
|
||||||
<Link href={`/dashboard/projects/${params.id}/edit`}>
|
<Link href={`/dashboard/projects/${id}/edit`}>
|
||||||
<Edit className="mr-2 h-4 w-4" /> 编辑项目
|
<Edit className="mr-2 h-4 w-4" /> 编辑项目
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
869
SuperAdmin/package-lock.json
generated
869
SuperAdmin/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -45,7 +45,7 @@
|
|||||||
"embla-carousel-react": "8.5.1",
|
"embla-carousel-react": "8.5.1",
|
||||||
"input-otp": "1.4.1",
|
"input-otp": "1.4.1",
|
||||||
"lucide-react": "^0.454.0",
|
"lucide-react": "^0.454.0",
|
||||||
"next": "15.2.4",
|
"next": "^15.3.1",
|
||||||
"next-themes": "^0.4.4",
|
"next-themes": "^0.4.4",
|
||||||
"react": "^19",
|
"react": "^19",
|
||||||
"react-day-picker": "8.10.1",
|
"react-day-picker": "8.10.1",
|
||||||
|
|||||||
5
SuperAdmin/pnpm-lock.yaml
generated
5
SuperAdmin/pnpm-lock.yaml
generated
@@ -1,5 +0,0 @@
|
|||||||
lockfileVersion: '9.0'
|
|
||||||
|
|
||||||
settings:
|
|
||||||
autoInstallPeers: true
|
|
||||||
excludeLinksFromLockfile: false
|
|
||||||
Reference in New Issue
Block a user