refactor(auth): support async deferred actions for login gating

Allow deferred login actions to return promises and execute them safely without violating lint rules. Also initialize order detail timer state without impure render-time Date.now calls so React hook purity checks pass.
This commit is contained in:
zetaloop
2026-02-22 09:50:48 +08:00
parent f82a926b8f
commit c9dbf5037e
4 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -9,9 +9,9 @@ export function useRequireAuth() {
const openLoginDialog = useLoginDialogStore((s) => s.openLoginDialog)
const requireAuth = useCallback(
(action: () => void) => {
(action: () => void | Promise<void>) => {
if (isAuthenticated) {
action()
void action()
} else {
openLoginDialog(action)
}