177 lines
6.4 KiB
TypeScript
177 lines
6.4 KiB
TypeScript
import {
|
|
useCallback,
|
|
useEffect,
|
|
useState,
|
|
} from 'react';
|
|
import {
|
|
Activity,
|
|
BarChart3,
|
|
Building2,
|
|
FileCheck2,
|
|
FileText,
|
|
FilePenLine,
|
|
Gauge,
|
|
Hash,
|
|
ImageIcon,
|
|
ListChecks,
|
|
Layers3,
|
|
MessageSquare,
|
|
Phone,
|
|
RefreshCw,
|
|
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 [pendingAudits, setPendingAudits] = useState({ enterpriseCertifications: 0, smsAudits: 0, templates: 0, signatures: 0 });
|
|
const [downstreamAlertCount, setDownstreamAlertCount] = useState(0);
|
|
const loadPendingAuditCount = useCallback(() => {
|
|
adminApi.getDashboard()
|
|
.then((dashboard) => {
|
|
setPendingAudits(dashboard.pendingAudits ?? { enterpriseCertifications: 0, smsAudits: 0, templates: 0, signatures: 0 });
|
|
setDownstreamAlertCount(dashboard.downstreamDeliverySummary?.alertCount ?? 0);
|
|
})
|
|
.catch(() => {
|
|
setPendingAudits({ enterpriseCertifications: 0, smsAudits: 0, templates: 0, signatures: 0 });
|
|
setDownstreamAlertCount(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: pendingAudits.enterpriseCertifications, to: '/admin/enterprise-audit' },
|
|
{ label: '短信审核待审', count: pendingAudits.smsAudits, to: '/admin/sms-audit' },
|
|
{ label: '模板待审', count: pendingAudits.templates, to: '/admin/templates' },
|
|
{ label: '签名待审', count: pendingAudits.signatures, to: '/admin/enterprise-signatures' },
|
|
{ label: '下游投递告警', count: downstreamAlertCount, to: '/admin/downstream-deliveries' },
|
|
]}
|
|
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: FilePenLine },
|
|
],
|
|
},
|
|
{
|
|
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/downstream-deliveries', icon: Send },
|
|
{ label: '恢复状态管理', to: '/admin/downstream-recovery-statuses', icon: RefreshCw },
|
|
{ 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 },
|
|
],
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
}
|