超管登录对接
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
INSERT INTO `tk_administrators` (`name`, `account`, `password`, `status`, `createTime`, `updateTime`)
|
|
||||||
VALUES ('超级管理员', 'admin', MD5('123456'), 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
|
|
||||||
@@ -17,28 +17,26 @@ export default function DashboardPage() {
|
|||||||
const adminInfo = localStorage.getItem("admin_info")
|
const adminInfo = localStorage.getItem("admin_info")
|
||||||
if (adminInfo) {
|
if (adminInfo) {
|
||||||
try {
|
try {
|
||||||
const { name } = JSON.parse(adminInfo)
|
const userData = JSON.parse(adminInfo)
|
||||||
setUserName(name || "管理员")
|
setUserName(userData.name || "管理员")
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("解析用户信息失败:", err)
|
console.error("解析用户信息失败:", err)
|
||||||
|
setUserName("管理员")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
const hour = new Date().getHours()
|
const hour = new Date().getHours()
|
||||||
let timeGreeting = ""
|
|
||||||
|
|
||||||
if (hour >= 5 && hour < 12) {
|
if (hour >= 5 && hour < 12) {
|
||||||
timeGreeting = "上午好"
|
setGreeting("上午好")
|
||||||
} else if (hour >= 12 && hour < 14) {
|
} else if (hour >= 12 && hour < 14) {
|
||||||
timeGreeting = "中午好"
|
setGreeting("中午好")
|
||||||
} else if (hour >= 14 && hour < 18) {
|
} else if (hour >= 14 && hour < 18) {
|
||||||
timeGreeting = "下午好"
|
setGreeting("下午好")
|
||||||
} else {
|
} else {
|
||||||
timeGreeting = "晚上好"
|
setGreeting("晚上好")
|
||||||
}
|
}
|
||||||
|
|
||||||
setGreeting(timeGreeting)
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { Label } from "@/components/ui/label"
|
|||||||
import { md5 } from "@/lib/utils"
|
import { md5 } from "@/lib/utils"
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const [username, setUsername] = useState("")
|
const [account, setAccount] = useState("")
|
||||||
const [password, setPassword] = useState("")
|
const [password, setPassword] = useState("")
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [error, setError] = useState("")
|
const [error, setError] = useState("")
|
||||||
@@ -33,7 +33,7 @@ export default function LoginPage() {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
account: username,
|
account,
|
||||||
password: encryptedPassword
|
password: encryptedPassword
|
||||||
}),
|
}),
|
||||||
credentials: "include"
|
credentials: "include"
|
||||||
@@ -70,12 +70,12 @@ export default function LoginPage() {
|
|||||||
<form onSubmit={handleLogin}>
|
<form onSubmit={handleLogin}>
|
||||||
<CardContent className="space-y-4">
|
<CardContent className="space-y-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="username">账号</Label>
|
<Label htmlFor="account">账号</Label>
|
||||||
<Input
|
<Input
|
||||||
id="username"
|
id="account"
|
||||||
placeholder="请输入账号"
|
placeholder="请输入账号"
|
||||||
value={username}
|
value={account}
|
||||||
onChange={(e) => setUsername(e.target.value)}
|
onChange={(e) => setAccount(e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user