feat: 优化web

This commit is contained in:
2026-04-23 18:58:13 +08:00
commit 544a2f3428
160 changed files with 27327 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
/** 供 `apiJson` 调用,避免直接依赖 React;由 AppProviders 注册实现。 */
type AuthEventsImpl = {
on401: (msg: string) => void;
on403: (msg: string) => void;
};
let impl: Partial<AuthEventsImpl> = {};
let last401At = 0;
export function registerAuthEvents(next: Partial<AuthEventsImpl>) {
impl = next;
}
/** 同一秒内合并多次 401,避免并发请求重复弹窗 */
export function emit401Unauthorized(msg: string) {
const now = Date.now();
if (now - last401At < 800) {
return;
}
last401At = now;
impl.on401?.(msg);
}
export function emit403Forbidden(msg: string) {
impl.on403?.(msg);
}