Files
lislgosms/src/layouts/AdminLayout.tsx
T

163 lines
5.3 KiB
TypeScript

import {
useCallback,
useEffect,
useState,
} from 'react';
import {
Activity,
BarChart3,
Building2,
FileCheck2,
FileText,
FilePenLine,
Gauge,
Hash,
ImageIcon,
ListChecks,
Layers3,
MessageSquare,
Phone,
TrendingUp,
RadioTower,
ReceiptText,
ClipboardList,
Send,
Settings,
Shield,
ShieldOff,
ShieldCheck,
Users,
UserX,
} from 'lucide-react';
import { Navigate } from 'react-router-dom';
import { adminApi } from '@/api/adminApi';
import { readSession } from '@/api/session';
import { AppShell } from '@/layouts/AppShell';
export function AdminLayout() {
const session = readSession();
const [pendingAuditCount, setPendingAuditCount] = useState(0);
const loadPendingAuditCount = useCallback(() => {
adminApi.getDashboard()
.then((dashboard) => setPendingAuditCount(dashboard.pendingAuditCount ?? 0))
.catch(() => setPendingAuditCount(0));
}, []);
useEffect(() => {
if (session?.portal !== 'admin') {
return;
}
loadPendingAuditCount();
const timer = window.setInterval(loadPendingAuditCount, 30000);
const onFocus = () => loadPendingAuditCount();
window.addEventListener('focus', onFocus);
return () => {
window.clearInterval(timer);
window.removeEventListener('focus', onFocus);
};
}, [loadPendingAuditCount, session?.portal]);
if (session?.portal !== 'admin') {
return <Navigate to="/admin/login" replace />;
}
return (
<AppShell
title="CMPP 运营端"
subtitle="平台运营管理中心"
workspaceName="平台运营工作区"
loginPath="/admin/login"
userName={session.user.displayName}
userRole="平台管理员"
auditNotifications={[
{ label: '待处理审核', count: pendingAuditCount, to: '/admin/sms-audit' },
]}
navSections={[
{
title: '运营概览',
icon: Gauge,
items: [
{ label: '运营看板', to: '/admin', icon: Gauge },
{ label: '发送监控', to: '/admin/monitor', icon: Activity },
{ label: '数据统计', to: '/admin/analytics', icon: BarChart3 },
],
},
{
title: '客户管理',
icon: Building2,
items: [
{ label: '企业管理', to: '/admin/customer-enterprises', icon: Building2 },
{ label: '企业应用管理', to: '/admin/enterprise-applications', icon: Layers3 },
{ label: '企业签名管理', to: '/admin/enterprise-signatures', icon: FilePenLine },
{ label: '企业模板管理', to: '/admin/enterprise-templates', icon: FileCheck2 },
],
},
{
title: '审核中心',
icon: FileCheck2,
items: [
{ label: '企业认证审核', to: '/admin/enterprise-audit', icon: ShieldCheck },
{ label: '短信审核', to: '/admin/sms-audit', icon: MessageSquare },
{ label: '短信模板审核', to: '/admin/templates', icon: FileCheck2 },
{ label: '彩信模板审核', to: '/admin/signatures', icon: ImageIcon, pending: true },
],
},
{
title: '通道管理',
icon: RadioTower,
items: [
{ label: '短信通道管理', to: '/admin/channels', icon: RadioTower },
{ label: '彩信通道管理', to: '/admin/mms-channels', icon: ImageIcon, pending: true },
{ label: '短信通道组管理', to: '/admin/channel-groups', icon: Layers3 },
],
},
{
title: '报备任务',
icon: ClipboardList,
items: [
{ label: '报备任务', to: '/admin/report-tasks', icon: ClipboardList },
{ label: '报备记录', to: '/admin/report-records', icon: ListChecks },
],
},
{
title: '发送任务',
icon: Send,
items: [
{ label: '短信任务进度', to: '/admin/sms-task-progress', icon: TrendingUp },
{ label: '彩信任务进度', to: '/admin/mms-task-progress', icon: BarChart3, pending: true },
],
},
{
title: '数据详单',
icon: ReceiptText,
items: [
{ label: '短信记录', to: '/admin/sms-records', icon: MessageSquare },
{ label: '彩信记录', to: '/admin/mms-records', icon: ImageIcon, pending: true },
{ label: '短信上行记录', to: '/admin/sms-uplink-records', icon: MessageSquare },
{ label: '充值记录', to: '/admin/recharge-records', icon: ReceiptText },
],
},
{
title: '安全控制',
icon: Shield,
items: [
{ label: '企业黑名单', to: '/admin/enterprise-blacklist', icon: UserX },
{ label: '全局黑名单', to: '/admin/global-blacklist', icon: ShieldOff },
{ label: '敏感词管理', to: '/admin/sensitive-words', icon: Shield },
],
},
{
title: '系统管理',
icon: Settings,
items: [
{ label: '用户管理', to: '/admin/users', icon: Users },
{ label: '手机号段库', to: '/admin/phone-segments', icon: Phone },
{ label: '报备字段库', to: '/admin/drainage-fields', icon: Hash },
{ label: '系统日志', to: '/admin/system-logs', icon: FileText },
],
},
]}
/>
);
}