超管登录对接

This commit is contained in:
柳清爽
2025-04-09 16:41:05 +08:00
parent c7062445ab
commit c24f6541b6
3 changed files with 13 additions and 17 deletions

View File

@@ -17,28 +17,26 @@ export default function DashboardPage() {
const adminInfo = localStorage.getItem("admin_info")
if (adminInfo) {
try {
const { name } = JSON.parse(adminInfo)
setUserName(name || "管理员")
const userData = JSON.parse(adminInfo)
setUserName(userData.name || "管理员")
} catch (err) {
console.error("解析用户信息失败:", err)
setUserName("管理员")
}
}
// 获取当前时间
const hour = new Date().getHours()
let timeGreeting = ""
if (hour >= 5 && hour < 12) {
timeGreeting = "上午好"
setGreeting("上午好")
} else if (hour >= 12 && hour < 14) {
timeGreeting = "中午好"
setGreeting("中午好")
} else if (hour >= 14 && hour < 18) {
timeGreeting = "下午好"
setGreeting("下午好")
} else {
timeGreeting = "晚上好"
setGreeting("晚上好")
}
setGreeting(timeGreeting)
}, [])
return (

View File

@@ -11,7 +11,7 @@ import { Label } from "@/components/ui/label"
import { md5 } from "@/lib/utils"
export default function LoginPage() {
const [username, setUsername] = useState("")
const [account, setAccount] = useState("")
const [password, setPassword] = useState("")
const [isLoading, setIsLoading] = useState(false)
const [error, setError] = useState("")
@@ -33,7 +33,7 @@ export default function LoginPage() {
"Content-Type": "application/json",
},
body: JSON.stringify({
account: username,
account,
password: encryptedPassword
}),
credentials: "include"
@@ -70,12 +70,12 @@ export default function LoginPage() {
<form onSubmit={handleLogin}>
<CardContent className="space-y-4">
<div className="space-y-2">
<Label htmlFor="username"></Label>
<Label htmlFor="account"></Label>
<Input
id="username"
id="account"
placeholder="请输入账号"
value={username}
onChange={(e) => setUsername(e.target.value)}
value={account}
onChange={(e) => setAccount(e.target.value)}
required
/>
</div>