fix: #589 improve unauthorized tips

This commit is contained in:
Yidadaa
2023-04-09 23:51:12 +08:00
parent 4a492264a1
commit 0e05733bbb
6 changed files with 66 additions and 48 deletions

View File

@@ -9,6 +9,7 @@ export interface AccessControlStore {
updateToken: (_: string) => void;
updateCode: (_: string) => void;
enabledAccessControl: () => boolean;
isAuthorized: () => boolean;
}
export const ACCESS_KEY = "access-control";
@@ -27,10 +28,13 @@ export const useAccessStore = create<AccessControlStore>()(
updateToken(token: string) {
set((state) => ({ token }));
},
isAuthorized() {
return !!get().token || !!get().accessCode;
},
}),
{
name: ACCESS_KEY,
version: 1,
}
)
},
),
);