From cb29e913f882575580c66136b41a49d9f8a769f4 Mon Sep 17 00:00:00 2001 From: wmp <17516219072@163.com> Date: Wed, 17 Sep 2025 10:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DuseSearchParams()=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=94=99=E8=AF=AF=E6=B7=BB=E5=8A=A0=20Suspense=20?= =?UTF-8?q?=E8=BE=B9=E7=95=8C&=E5=88=87=E6=8D=A2=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E9=A1=B5=E6=97=B6=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=20mac=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/init.sql | 8 +++---- prisma/schema.prisma | 4 ++-- .../dashboard/components/gatewayConfig.tsx | 19 +++++++++++++++-- src/app/dashboard/page.tsx | 21 ++++++++++++++++--- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/prisma/init.sql b/prisma/init.sql index 70f3e1e..561d816 100644 --- a/prisma/init.sql +++ b/prisma/init.sql @@ -37,11 +37,11 @@ CREATE TABLE `users` ( `name` varchar(191) DEFAULT NULL, `createdAt` datetime(3) NOT NULL DEFAULT current_timestamp(3), `password` varchar(191) NOT NULL, - `phone` varchar(191) NOT NULL, + `account` varchar(191) NOT NULL, `updatedAt` datetime(3) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `users_phone_key` (`phone`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + UNIQUE KEY `users_phone_key` (`account`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- jdbox.verification_codes definition @@ -57,4 +57,4 @@ CREATE TABLE `verification_codes` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 插入初始用户 -INSERT INTO users(phone, password, name) VALUES('admin', '$2a$10$k.p3.s28OdLmGCMtuvBoqOxABp03h0Zhmop4eqqlR8sIjkThCcsnS', '管理员'); \ No newline at end of file +INSERT INTO users(account, password, name) VALUES('admin', '$2a$10$k.p3.s28OdLmGCMtuvBoqOxABp03h0Zhmop4eqqlR8sIjkThCcsnS', '管理员'); \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 476a30f..c7b0e3c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -148,12 +148,12 @@ model Session { model VerificationCode { id Int @id @default(autoincrement()) - phone String + account String code String type String expiresAt DateTime createdAt DateTime @default(now()) - @@index([phone, type]) + @@index([account, type]) @@map("verification_codes") } diff --git a/src/app/dashboard/components/gatewayConfig.tsx b/src/app/dashboard/components/gatewayConfig.tsx index b5a8214..9829a4a 100644 --- a/src/app/dashboard/components/gatewayConfig.tsx +++ b/src/app/dashboard/components/gatewayConfig.tsx @@ -1,5 +1,5 @@ 'use client' -import { useEffect, useState } from 'react' +import { useEffect, useState, Suspense } from 'react' import { useSearchParams } from 'next/navigation' interface GatewayConfig { @@ -13,7 +13,7 @@ interface GatewayConfig { isonline: number } -export default function GatewayConfig() { +function GatewayConfigContent() { const [data, setData] = useState([]) const [loading, setLoading] = useState(false) const [macAddress, setMacAddress] = useState('') @@ -279,4 +279,19 @@ export default function GatewayConfig() { )} ) +} + +export default function GatewayConfig() { + return ( + +
+
+

加载搜索参数...

+
+ + }> + +
+ ) } \ No newline at end of file diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index c211554..4726ee4 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -1,6 +1,6 @@ 'use client' -import { useState, useEffect } from 'react' +import { useState, useEffect, Suspense } from 'react' import { useRouter, useSearchParams } from 'next/navigation' import Gatewayinfo from './components/gatewayinfo' import GatewayConfig from './components/gatewayConfig' @@ -19,7 +19,7 @@ const tabs = [ { id: 'setting', label: '设置'} ] -export default function Dashboard() { +function DashboardContent() { const [activeTab, setActiveTab] = useState('gatewayInfo') const [isLoading, setIsLoading] = useState(false) const router = useRouter() @@ -58,7 +58,7 @@ export default function Dashboard() { const handleTabClick = (tabId: string) => { setActiveTab(tabId) // 更新 URL 参数 - const params = new URLSearchParams(searchParams.toString()) + const params = new URLSearchParams() params.set('tab', tabId) router.push(`/dashboard?${params.toString()}`) } @@ -115,4 +115,19 @@ export default function Dashboard() { ) +} + +export default function Dashboard() { + return ( + +
+
+

加载中...

+
+ + }> + +
+ ) } \ No newline at end of file