feat(admin, settlement, dashboard): strengthen permission gating and billing workflows

This commit is contained in:
2026-06-09 13:44:19 +08:00
parent 7e65c53732
commit b7278e68a4
41 changed files with 900 additions and 199 deletions

View File

@@ -6,15 +6,22 @@ import { useEffect, useRef, type DependencyList } from "react";
* 在依赖变化时执行异步副作用factory 始终用最新闭包,但不必把 `t` 等不稳定引用放进 deps。
*/
export function useAsyncEffect(
factory: () => void | Promise<void>,
factory: () => void | (() => void) | Promise<void>,
deps: DependencyList,
): void {
const factoryRef = useRef(factory);
factoryRef.current = factory;
useEffect(() => {
let cleanup: void | (() => void);
queueMicrotask(() => {
void factoryRef.current();
void Promise.resolve(factoryRef.current()).then((result) => {
cleanup = result;
});
});
return () => {
cleanup?.();
};
}, deps);
}