feat: 添加财务摘要接口,更新管理员抽奖模块和导航,优化权限管理逻辑
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useMemo } from "react";
|
||||
import { SparklesIcon } from "lucide-react";
|
||||
|
||||
import {
|
||||
@@ -22,7 +23,9 @@ import {
|
||||
adminNavIconBySegment,
|
||||
LogIn,
|
||||
} from "@/modules/_config/admin-nav-icons";
|
||||
import { adminNavItemVisible } from "@/lib/admin-nav-visibility";
|
||||
import { adminShellNavItems, ADMIN_BASE } from "@/modules/_config/admin-nav";
|
||||
import { useAdminProfile } from "@/stores/admin-session";
|
||||
|
||||
function isActive(pathname: string, item: { href: string; activeMatchPrefix?: string }): boolean {
|
||||
const { href, activeMatchPrefix } = item;
|
||||
@@ -35,6 +38,14 @@ function isActive(pathname: string, item: { href: string; activeMatchPrefix?: st
|
||||
|
||||
export function AdminAppSidebar() {
|
||||
const pathname = usePathname();
|
||||
const profile = useAdminProfile();
|
||||
const visibleNav = useMemo(
|
||||
() =>
|
||||
adminShellNavItems.filter((item) =>
|
||||
adminNavItemVisible(item, profile?.permissions),
|
||||
),
|
||||
[profile?.permissions],
|
||||
);
|
||||
|
||||
return (
|
||||
<Sidebar collapsible="icon" variant="inset">
|
||||
@@ -63,7 +74,7 @@ export function AdminAppSidebar() {
|
||||
<SidebarGroupLabel>工作台</SidebarGroupLabel>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
{adminShellNavItems.map((item) => {
|
||||
{visibleNav.map((item) => {
|
||||
const Icon = adminNavIconBySegment[item.segment];
|
||||
return (
|
||||
<SidebarMenuItem key={item.segment}>
|
||||
|
||||
Reference in New Issue
Block a user