fix: harden real backend admin workflows and ui

This commit is contained in:
hectorzhao
2026-07-03 19:29:56 +08:00
parent dd09d91c1e
commit 8cca361441
71 changed files with 5111 additions and 4439 deletions
+28 -4
View File
@@ -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={[
{
-5
View File
@@ -9,7 +9,6 @@ import {
LogOut,
PanelLeftClose,
PanelLeftOpen,
Search,
} from 'lucide-react';
import { NavLink, Outlet, useNavigate } from 'react-router-dom';
import { clearSession } from '@/api/session';
@@ -144,10 +143,6 @@ export function AppShell({
>
<ToggleIcon size={18} />
</button>
<label className="topbar-search">
<Search size={17} />
<input placeholder="搜索模板、客户、发送记录" />
</label>
</div>
<div className="topbar-actions">