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}>
|
||||
|
||||
@@ -37,8 +37,6 @@ import {
|
||||
} from "@/stores/admin-session";
|
||||
import type { AdminProfile } from "@/types/api/admin-auth";
|
||||
|
||||
const ADMIN_ROLE_LABEL = "超级管理员";
|
||||
|
||||
/** 暂未接入通知中心时的占位未读数(与设计稿一致可改为接口数据) */
|
||||
const NOTIFICATION_PLACEHOLDER_COUNT = 6;
|
||||
|
||||
@@ -95,6 +93,8 @@ export function ShellToolbar() {
|
||||
adminProfile?.username?.trim() ||
|
||||
"管理员";
|
||||
|
||||
const permissionCount = adminProfile?.permissions?.length ?? 0;
|
||||
|
||||
function onLogout() {
|
||||
clearSession();
|
||||
toast.success("已退出登录");
|
||||
@@ -175,7 +175,9 @@ export function ShellToolbar() {
|
||||
{displayName}
|
||||
</span>
|
||||
<span className="truncate text-xs text-muted-foreground">
|
||||
{ADMIN_ROLE_LABEL}
|
||||
{permissionCount > 0
|
||||
? `${permissionCount} 项功能权限 · 菜单已按角色过滤`
|
||||
: "重新登录可同步权限与侧栏菜单"}
|
||||
</span>
|
||||
</span>
|
||||
<ChevronDownIcon className="hidden size-4 shrink-0 text-muted-foreground sm:block" />
|
||||
|
||||
Reference in New Issue
Block a user