修复useSearchParams()编译错误添加 Suspense 边界&切换标签页时移除不必要的 mac 参数
This commit is contained in:
@@ -37,11 +37,11 @@ CREATE TABLE `users` (
|
|||||||
`name` varchar(191) DEFAULT NULL,
|
`name` varchar(191) DEFAULT NULL,
|
||||||
`createdAt` datetime(3) NOT NULL DEFAULT current_timestamp(3),
|
`createdAt` datetime(3) NOT NULL DEFAULT current_timestamp(3),
|
||||||
`password` varchar(191) NOT NULL,
|
`password` varchar(191) NOT NULL,
|
||||||
`phone` varchar(191) NOT NULL,
|
`account` varchar(191) NOT NULL,
|
||||||
`updatedAt` datetime(3) NOT NULL,
|
`updatedAt` datetime(3) NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `users_phone_key` (`phone`)
|
UNIQUE KEY `users_phone_key` (`account`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
-- jdbox.verification_codes definition
|
-- jdbox.verification_codes definition
|
||||||
|
|
||||||
@@ -57,4 +57,4 @@ CREATE TABLE `verification_codes` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
-- 插入初始用户
|
-- 插入初始用户
|
||||||
INSERT INTO users(phone, password, name) VALUES('admin', '$2a$10$k.p3.s28OdLmGCMtuvBoqOxABp03h0Zhmop4eqqlR8sIjkThCcsnS', '管理员');
|
INSERT INTO users(account, password, name) VALUES('admin', '$2a$10$k.p3.s28OdLmGCMtuvBoqOxABp03h0Zhmop4eqqlR8sIjkThCcsnS', '管理员');
|
||||||
@@ -148,12 +148,12 @@ model Session {
|
|||||||
|
|
||||||
model VerificationCode {
|
model VerificationCode {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
phone String
|
account String
|
||||||
code String
|
code String
|
||||||
type String
|
type String
|
||||||
expiresAt DateTime
|
expiresAt DateTime
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
|
|
||||||
@@index([phone, type])
|
@@index([account, type])
|
||||||
@@map("verification_codes")
|
@@map("verification_codes")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState, Suspense } from 'react'
|
||||||
import { useSearchParams } from 'next/navigation'
|
import { useSearchParams } from 'next/navigation'
|
||||||
|
|
||||||
interface GatewayConfig {
|
interface GatewayConfig {
|
||||||
@@ -13,7 +13,7 @@ interface GatewayConfig {
|
|||||||
isonline: number
|
isonline: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GatewayConfig() {
|
function GatewayConfigContent() {
|
||||||
const [data, setData] = useState<GatewayConfig[]>([])
|
const [data, setData] = useState<GatewayConfig[]>([])
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [macAddress, setMacAddress] = useState('')
|
const [macAddress, setMacAddress] = useState('')
|
||||||
@@ -279,4 +279,19 @@ export default function GatewayConfig() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function GatewayConfig() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={
|
||||||
|
<div className="bg-white shadow rounded-lg p-6">
|
||||||
|
<div className="text-center py-12">
|
||||||
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto"></div>
|
||||||
|
<p className="mt-4 text-gray-600">加载搜索参数...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}>
|
||||||
|
<GatewayConfigContent />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect, Suspense } from 'react'
|
||||||
import { useRouter, useSearchParams } from 'next/navigation'
|
import { useRouter, useSearchParams } from 'next/navigation'
|
||||||
import Gatewayinfo from './components/gatewayinfo'
|
import Gatewayinfo from './components/gatewayinfo'
|
||||||
import GatewayConfig from './components/gatewayConfig'
|
import GatewayConfig from './components/gatewayConfig'
|
||||||
@@ -19,7 +19,7 @@ const tabs = [
|
|||||||
{ id: 'setting', label: '设置'}
|
{ id: 'setting', label: '设置'}
|
||||||
]
|
]
|
||||||
|
|
||||||
export default function Dashboard() {
|
function DashboardContent() {
|
||||||
const [activeTab, setActiveTab] = useState('gatewayInfo')
|
const [activeTab, setActiveTab] = useState('gatewayInfo')
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -58,7 +58,7 @@ export default function Dashboard() {
|
|||||||
const handleTabClick = (tabId: string) => {
|
const handleTabClick = (tabId: string) => {
|
||||||
setActiveTab(tabId)
|
setActiveTab(tabId)
|
||||||
// 更新 URL 参数
|
// 更新 URL 参数
|
||||||
const params = new URLSearchParams(searchParams.toString())
|
const params = new URLSearchParams()
|
||||||
params.set('tab', tabId)
|
params.set('tab', tabId)
|
||||||
router.push(`/dashboard?${params.toString()}`)
|
router.push(`/dashboard?${params.toString()}`)
|
||||||
}
|
}
|
||||||
@@ -115,4 +115,19 @@ export default function Dashboard() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Dashboard() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={
|
||||||
|
<div className="min-h-screen bg-gray-100 flex items-center justify-center">
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto"></div>
|
||||||
|
<p className="mt-4 text-gray-600">加载中...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}>
|
||||||
|
<DashboardContent />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user