fix: harden real backend admin workflows and ui
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useState,
|
||||
} from 'react';
|
||||
import {
|
||||
Activity,
|
||||
BarChart3,
|
||||
@@ -25,11 +30,33 @@ import {
|
||||
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 />;
|
||||
}
|
||||
@@ -43,10 +70,7 @@ export function AdminLayout() {
|
||||
userName={session.user.displayName}
|
||||
userRole="平台管理员"
|
||||
auditNotifications={[
|
||||
{ label: '企业认证审核', count: 3, to: '/admin/enterprise-audit' },
|
||||
{ label: '短信审核', count: 8, to: '/admin/sms-audit' },
|
||||
{ label: '短信模板审核', count: 5, to: '/admin/templates' },
|
||||
{ label: '签名审核', count: 2, to: '/admin/enterprise-signatures' },
|
||||
{ label: '待处理审核', count: pendingAuditCount, to: '/admin/sms-audit' },
|
||||
]}
|
||||
navSections={[
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user