mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-09 02:05:59 +08:00
refactor: build/runtime/client configs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import { queryMeta } from "../utils";
|
||||
import { getClientSideConfig } from "../config/client";
|
||||
|
||||
export interface AccessControlStore {
|
||||
accessCode: string;
|
||||
@@ -20,7 +20,7 @@ export const useAccessStore = create<AccessControlStore>()(
|
||||
token: "",
|
||||
accessCode: "",
|
||||
enabledAccessControl() {
|
||||
return queryMeta("access") === "enabled";
|
||||
return !!getClientSideConfig()?.needCode;
|
||||
},
|
||||
updateCode(code: string) {
|
||||
set((state) => ({ accessCode: code }));
|
||||
@@ -30,7 +30,9 @@ export const useAccessStore = create<AccessControlStore>()(
|
||||
},
|
||||
isAuthorized() {
|
||||
// has token or has code or disabled access control
|
||||
return !!get().token || !!get().accessCode || !get().enabledAccessControl();
|
||||
return (
|
||||
!!get().token || !!get().accessCode || !get().enabledAccessControl()
|
||||
);
|
||||
},
|
||||
}),
|
||||
{
|
||||
|
Reference in New Issue
Block a user