添加客户查询页面包括导航权限控制 & 删除多余代码
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
"use client"
|
||||
import {
|
||||
BadgeQuestionMarkIcon,
|
||||
BellIcon,
|
||||
ChevronDownIcon,
|
||||
ChevronRightIcon,
|
||||
InboxIcon,
|
||||
LogOutIcon,
|
||||
SearchIcon,
|
||||
SettingsIcon,
|
||||
UserIcon,
|
||||
} from "lucide-react"
|
||||
@@ -16,36 +13,12 @@ import { usePathname, useRouter } from "next/navigation"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { logout } from "@/actions/auth"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import type { Admin } from "@/models/admin"
|
||||
|
||||
export default function Appbar(props: { admin: Admin }) {
|
||||
const router = useRouter()
|
||||
const [showDropdown, setShowDropdown] = useState(false)
|
||||
const [showNotifications, setShowNotifications] = useState(false)
|
||||
const [notifications] = useState([
|
||||
{
|
||||
id: 1,
|
||||
title: "系统通知",
|
||||
content: "您有新的待审核内容",
|
||||
time: "10分钟前",
|
||||
read: false,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "安全提醒",
|
||||
content: "您的账号于昨天登录了新设备",
|
||||
time: "1小时前",
|
||||
read: true,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: "系统更新",
|
||||
content: "系统将在今晚进行例行维护",
|
||||
time: "2小时前",
|
||||
read: true,
|
||||
},
|
||||
])
|
||||
|
||||
const pathname = usePathname()
|
||||
const dropdownRef = useRef<HTMLDivElement>(null)
|
||||
@@ -119,7 +92,6 @@ export default function Appbar(props: { admin: Admin }) {
|
||||
}
|
||||
|
||||
const breadcrumbs = generateBreadcrumbs()
|
||||
const unreadCount = notifications.filter(n => !n.read).length
|
||||
const doLogout = async () => {
|
||||
const resp = await logout()
|
||||
if (resp.success) {
|
||||
@@ -153,88 +125,6 @@ export default function Appbar(props: { admin: Admin }) {
|
||||
|
||||
{/* 右侧用户信息和工具栏 */}
|
||||
<div className="flex items-center space-x-4">
|
||||
{/* 搜索框 */}
|
||||
<div className="hidden md:block relative">
|
||||
<div className="relative">
|
||||
<SearchIcon className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="搜索..."
|
||||
className="pl-10 pr-4 py-2 bg-gray-100 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent w-56"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 通知图标 */}
|
||||
<div className="relative" ref={notificationRef}>
|
||||
<Button
|
||||
onClick={() => setShowNotifications(!showNotifications)}
|
||||
className="relative p-2 rounded-full text-gray-600 bg-gray-100 hover:bg-gray-100 hover:text-gray-800 transition-colors"
|
||||
aria-label="通知"
|
||||
>
|
||||
<BellIcon />
|
||||
{unreadCount > 0 && (
|
||||
<span className="absolute top-1 right-1 h-4 w-4 text-xs flex items-center justify-center rounded-full bg-red-500 text-white">
|
||||
{unreadCount}
|
||||
</span>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{/* 通知下拉面板 */}
|
||||
{showNotifications && (
|
||||
<div className="absolute right-0 mt-2 w-80 bg-white rounded-md shadow-lg py-1 z-20 border border-gray-200">
|
||||
<div className="px-4 py-2 border-b border-gray-100 flex justify-between items-center">
|
||||
<h3 className="font-medium text-gray-800">通知</h3>
|
||||
<Button className="text-xs text-blue-600 hover:text-blue-800">
|
||||
全部标为已读
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="max-h-72 overflow-y-auto">
|
||||
{notifications.length > 0 ? (
|
||||
notifications.map(notification => (
|
||||
<div
|
||||
key={notification.id}
|
||||
className={`px-4 py-3 border-b border-gray-100 hover:bg-gray-50 ${
|
||||
notification.read ? "bg-white" : "bg-blue-50"
|
||||
}`}
|
||||
>
|
||||
<div className="flex justify-between items-start">
|
||||
<h4 className="text-sm font-medium text-gray-800">
|
||||
{notification.title}
|
||||
</h4>
|
||||
<span className="text-xs text-gray-500">
|
||||
{notification.time}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-gray-600 mt-1">
|
||||
{notification.content}
|
||||
</p>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<div className="py-8 px-4 text-center">
|
||||
<InboxIcon size={18} />
|
||||
<p className="mt-2 text-sm text-gray-500">暂无通知</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="border-t border-gray-100 p-2 text-center">
|
||||
<Link
|
||||
href="/notifications"
|
||||
className="text-xs text-blue-600 hover:text-blue-800"
|
||||
>
|
||||
查看全部通知
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 分隔线 */}
|
||||
<div className="hidden md:block h-8 w-px bg-gray-200"></div>
|
||||
|
||||
{/* 用户下拉菜单 */}
|
||||
<div className="relative" ref={dropdownRef}>
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user