feat(frontend/admin): M10 后台管理面板(/admin hash 路由 + 15 大模块 + RBAC(owner/admin/viewer) + 审计 + Miuix);Docs/api-client.md v0.3 契约补全;tsc+vite build 通过
This commit is contained in:
1 parent
4c48e94659
commit
f43eb17030
26 files changed
+2253
-4
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { create } from "zustand";
|
||||
import type { AuditRecord } from "../lib/types";
|
||||
import { getStoredRole } from "../lib/api";
|
||||
import { now, uid } from "../lib/util";
|
||||
|
||||
/**
|
||||
* Client-side audit trail. Every admin write the panel performs is pushed here
|
||||
* with who/what/when/result so the 可观测性 → 审计 tab has real content even
|
||||
* before the backend exposes an audit endpoint. It is also the visual front of
|
||||
* the "主代理代审 + 审计日志" red line.
|
||||
*/
|
||||
|
||||
interface AuditStore {
|
||||
records: AuditRecord[];
|
||||
log: (what: string, result: "ok" | "error") => void;
|
||||
clear: () => void;
|
||||
}
|
||||
|
||||
export const useAuditStore = create<AuditStore>((set) => ({
|
||||
records: [],
|
||||
log: (what, result) =>
|
||||
set((s) => ({
|
||||
records: [
|
||||
{
|
||||
id: uid(),
|
||||
who: getStoredRole() ?? "anonymous",
|
||||
what,
|
||||
when: new Date(now()).toISOString(),
|
||||
result,
|
||||
},
|
||||
...s.records,
|
||||
].slice(0, 200),
|
||||
})),
|
||||
clear: () => set({ records: [] }),
|
||||
}));
|
||||
Reference in new issue
Block a user