422c8931d6
实现: 在rust内存里维护错误事件队列, webview调用tauri command传入, 后台任务agent工具等直接插入 把rust , webview console的日志统一写到AppData文件夹下的(滚动保存的)日志文件. rust对传入的错误进行筛选,脱敏, 防抖,后通知前端提醒用户. 用户提醒是一个不阻塞的小UI, 展开后可以选择错误上报, 可以附加文字描述 上传时附带最近日志, 错误堆栈等信息 元数据存在数据库, 考虑到字符串信息很难查询, 所以在api server打包成zip存在OSS. 管理页面新增错误报告的查看页面     --------- Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/240 Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
137 lines
3.5 KiB
TypeScript
137 lines
3.5 KiB
TypeScript
import {
|
|
Activity,
|
|
BadgeDollarSign,
|
|
Bug,
|
|
Coins,
|
|
Database,
|
|
GitBranch,
|
|
Images,
|
|
LayoutDashboard,
|
|
ListChecks,
|
|
LogOut,
|
|
ReceiptText,
|
|
ShieldCheck,
|
|
Star,
|
|
Table2,
|
|
TicketCheck,
|
|
TicketPercent,
|
|
Users,
|
|
WalletCards,
|
|
} from 'lucide-react';
|
|
import type { ReactNode } from 'react';
|
|
|
|
import type { AdminSessionPayload } from '../api/adminApiTypes';
|
|
import type { AdminRouteDefinition, AdminRouteId } from './adminRoutes';
|
|
|
|
interface AdminShellProps {
|
|
admin: AdminSessionPayload;
|
|
routeId: AdminRouteId | null;
|
|
routes: AdminRouteDefinition[];
|
|
children: ReactNode;
|
|
onRouteChange: (routeId: AdminRouteId) => void;
|
|
onLogout: () => void;
|
|
}
|
|
|
|
const routeIcons = {
|
|
dashboard: LayoutDashboard,
|
|
overview: Activity,
|
|
tables: Database,
|
|
debug: Bug,
|
|
tracking: Table2,
|
|
'error-reports': Bug,
|
|
'gray-release': GitBranch,
|
|
redeem: TicketPercent,
|
|
invite: TicketCheck,
|
|
'profile-wallet': WalletCards,
|
|
tasks: ListChecks,
|
|
'recharge-products': BadgeDollarSign,
|
|
'recharge-orders': ReceiptText,
|
|
'editor-generation-pricing': Coins,
|
|
'editor-showcase': Star,
|
|
'editor-assets': Images,
|
|
accounts: Users,
|
|
} satisfies Record<AdminRouteId, typeof LayoutDashboard>;
|
|
|
|
export function AdminShell({
|
|
admin,
|
|
routeId,
|
|
routes,
|
|
children,
|
|
onRouteChange,
|
|
onLogout,
|
|
}: AdminShellProps) {
|
|
return (
|
|
<div className="admin-shell">
|
|
<aside className="admin-sidebar">
|
|
<div className="admin-brand">
|
|
<div className="admin-brand-icon">
|
|
<ShieldCheck size={20} aria-hidden="true" />
|
|
</div>
|
|
<div>
|
|
<strong>陶泥儿后台</strong>
|
|
<span>Admin</span>
|
|
</div>
|
|
</div>
|
|
|
|
<nav className="admin-nav" aria-label="后台导航">
|
|
{routes.map((route) => {
|
|
const Icon = routeIcons[route.id];
|
|
return (
|
|
<button
|
|
className="admin-nav-button"
|
|
data-active={route.id === routeId}
|
|
key={route.id}
|
|
title={route.label}
|
|
type="button"
|
|
onClick={() => onRouteChange(route.id)}
|
|
>
|
|
<Icon size={18} aria-hidden="true" />
|
|
<span>{route.label}</span>
|
|
</button>
|
|
);
|
|
})}
|
|
</nav>
|
|
</aside>
|
|
|
|
<div className="admin-main">
|
|
<header className="admin-topbar">
|
|
<div className="admin-user">
|
|
<span>{admin.displayName || admin.username}</span>
|
|
<small>{admin.accountRole === 'owner' ? 'owner' : 'member'}</small>
|
|
</div>
|
|
<button
|
|
className="admin-icon-button"
|
|
title="退出登录"
|
|
type="button"
|
|
onClick={onLogout}
|
|
>
|
|
<LogOut size={18} aria-hidden="true" />
|
|
<span>退出</span>
|
|
</button>
|
|
</header>
|
|
|
|
<main className="admin-content">{children}</main>
|
|
</div>
|
|
|
|
<nav className="admin-bottom-nav" aria-label="后台导航">
|
|
{routes.map((route) => {
|
|
const Icon = routeIcons[route.id];
|
|
return (
|
|
<button
|
|
className="admin-bottom-nav-button"
|
|
data-active={route.id === routeId}
|
|
key={route.id}
|
|
title={route.label}
|
|
type="button"
|
|
onClick={() => onRouteChange(route.id)}
|
|
>
|
|
<Icon size={19} aria-hidden="true" />
|
|
<span>{route.label}</span>
|
|
</button>
|
|
);
|
|
})}
|
|
</nav>
|
|
</div>
|
|
);
|
|
}
|