mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	feat: add "Hide_Balance_Query" environment variable
This commit is contained in:
		@@ -27,3 +27,8 @@ HIDE_USER_API_KEY=
 | 
				
			|||||||
# Default: Empty
 | 
					# Default: Empty
 | 
				
			||||||
# If you do not want users to use GPT-4, set this value to 1.
 | 
					# If you do not want users to use GPT-4, set this value to 1.
 | 
				
			||||||
DISABLE_GPT4=
 | 
					DISABLE_GPT4=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# (optional)
 | 
				
			||||||
 | 
					# Default: Empty
 | 
				
			||||||
 | 
					# If you do not want users to query balance, set this value to 1.
 | 
				
			||||||
 | 
					Hide_Balance_Query=
 | 
				
			||||||
@@ -185,6 +185,12 @@ If you do not want users to input their own API key, set this value to 1.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
If you do not want users to use GPT-4, set this value to 1.
 | 
					If you do not want users to use GPT-4, set this value to 1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `Hide_Balance_Query` (optional)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> Default: Empty
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you do not want users to query balance, set this value to 1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Requirements
 | 
					## Requirements
 | 
				
			||||||
 | 
					
 | 
				
			||||||
NodeJS >= 18, Docker >= 20
 | 
					NodeJS >= 18, Docker >= 20
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,6 +98,10 @@ OpenAI 接口代理 URL,如果你手动配置了 openai 接口代理,请填
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
如果你不想让用户使用 GPT-4,将此环境变量设置为 1 即可。
 | 
					如果你不想让用户使用 GPT-4,将此环境变量设置为 1 即可。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `Hide_Balance_Query` (可选)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					如果你不想让用户查询余额,将此环境变量设置为 1 即可。
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## 开发
 | 
					## 开发
 | 
				
			||||||
 | 
					
 | 
				
			||||||
点击下方按钮,开始二次开发:
 | 
					点击下方按钮,开始二次开发:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,6 +96,10 @@ Si no desea que los usuarios rellenen la clave de API ellos mismos, establezca e
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Si no desea que los usuarios utilicen GPT-4, establezca esta variable de entorno en 1.
 | 
					Si no desea que los usuarios utilicen GPT-4, establezca esta variable de entorno en 1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `Hide_Balance_Query` (Opcional)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Si no desea que los usuarios consulte el saldo, establezca esta variable de entorno en 1.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## explotación
 | 
					## explotación
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> No se recomienda encarecidamente desarrollar o implementar localmente, debido a algunas razones técnicas, es difícil configurar el agente API de OpenAI localmente, a menos que pueda asegurarse de que puede conectarse directamente al servidor OpenAI.
 | 
					> No se recomienda encarecidamente desarrollar o implementar localmente, debido a algunas razones técnicas, es difícil configurar el agente API de OpenAI localmente, a menos que pueda asegurarse de que puede conectarse directamente al servidor OpenAI.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,6 +10,7 @@ const DANGER_CONFIG = {
 | 
				
			|||||||
  needCode: serverConfig.needCode,
 | 
					  needCode: serverConfig.needCode,
 | 
				
			||||||
  hideUserApiKey: serverConfig.hideUserApiKey,
 | 
					  hideUserApiKey: serverConfig.hideUserApiKey,
 | 
				
			||||||
  enableGPT4: serverConfig.enableGPT4,
 | 
					  enableGPT4: serverConfig.enableGPT4,
 | 
				
			||||||
 | 
					  hideBalanceQuery: serverConfig.hideBalanceQuery,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare global {
 | 
					declare global {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -522,29 +522,31 @@ export function Settings() {
 | 
				
			|||||||
            </ListItem>
 | 
					            </ListItem>
 | 
				
			||||||
          ) : null}
 | 
					          ) : null}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          <ListItem
 | 
					          {!accessStore.hideBalanceQuery ? (
 | 
				
			||||||
            title={Locale.Settings.Usage.Title}
 | 
					            <ListItem
 | 
				
			||||||
            subTitle={
 | 
					              title={Locale.Settings.Usage.Title}
 | 
				
			||||||
              showUsage
 | 
					              subTitle={
 | 
				
			||||||
                ? loadingUsage
 | 
					                showUsage
 | 
				
			||||||
                  ? Locale.Settings.Usage.IsChecking
 | 
					                  ? loadingUsage
 | 
				
			||||||
                  : Locale.Settings.Usage.SubTitle(
 | 
					                    ? Locale.Settings.Usage.IsChecking
 | 
				
			||||||
                      usage?.used ?? "[?]",
 | 
					                    : Locale.Settings.Usage.SubTitle(
 | 
				
			||||||
                      usage?.subscription ?? "[?]",
 | 
					                        usage?.used ?? "[?]",
 | 
				
			||||||
                    )
 | 
					                        usage?.subscription ?? "[?]",
 | 
				
			||||||
                : Locale.Settings.Usage.NoAccess
 | 
					                      )
 | 
				
			||||||
            }
 | 
					                  : Locale.Settings.Usage.NoAccess
 | 
				
			||||||
          >
 | 
					              }
 | 
				
			||||||
            {!showUsage || loadingUsage ? (
 | 
					            >
 | 
				
			||||||
              <div />
 | 
					              {!showUsage || loadingUsage ? (
 | 
				
			||||||
            ) : (
 | 
					                <div />
 | 
				
			||||||
              <IconButton
 | 
					              ) : (
 | 
				
			||||||
                icon={<ResetIcon></ResetIcon>}
 | 
					                <IconButton
 | 
				
			||||||
                text={Locale.Settings.Usage.Check}
 | 
					                  icon={<ResetIcon></ResetIcon>}
 | 
				
			||||||
                onClick={() => checkUsage(true)}
 | 
					                  text={Locale.Settings.Usage.Check}
 | 
				
			||||||
              />
 | 
					                  onClick={() => checkUsage(true)}
 | 
				
			||||||
            )}
 | 
					                />
 | 
				
			||||||
          </ListItem>
 | 
					              )}
 | 
				
			||||||
 | 
					            </ListItem>
 | 
				
			||||||
 | 
					          ) : null}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          {!accessStore.hideUserApiKey ? (
 | 
					          {!accessStore.hideUserApiKey ? (
 | 
				
			||||||
            <ListItem
 | 
					            <ListItem
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ declare global {
 | 
				
			|||||||
      DISABLE_GPT4?: string; // allow user to use gpt-4 or not
 | 
					      DISABLE_GPT4?: string; // allow user to use gpt-4 or not
 | 
				
			||||||
      BUILD_MODE?: "standalone" | "export";
 | 
					      BUILD_MODE?: "standalone" | "export";
 | 
				
			||||||
      BUILD_APP?: string; // is building desktop app
 | 
					      BUILD_APP?: string; // is building desktop app
 | 
				
			||||||
 | 
					      Hide_Balance_Query?: string; // allow user to query balance or not
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -46,5 +47,6 @@ export const getServerSideConfig = () => {
 | 
				
			|||||||
    isVercel: !!process.env.VERCEL,
 | 
					    isVercel: !!process.env.VERCEL,
 | 
				
			||||||
    hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
 | 
					    hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
 | 
				
			||||||
    enableGPT4: !process.env.DISABLE_GPT4,
 | 
					    enableGPT4: !process.env.DISABLE_GPT4,
 | 
				
			||||||
 | 
					    hideBalanceQuery: !!process.env.Hide_Balance_Query,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@ export interface AccessControlStore {
 | 
				
			|||||||
  needCode: boolean;
 | 
					  needCode: boolean;
 | 
				
			||||||
  hideUserApiKey: boolean;
 | 
					  hideUserApiKey: boolean;
 | 
				
			||||||
  openaiUrl: string;
 | 
					  openaiUrl: string;
 | 
				
			||||||
 | 
					  hideBalanceQuery: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  updateToken: (_: string) => void;
 | 
					  updateToken: (_: string) => void;
 | 
				
			||||||
  updateCode: (_: string) => void;
 | 
					  updateCode: (_: string) => void;
 | 
				
			||||||
@@ -36,6 +37,7 @@ export const useAccessStore = create<AccessControlStore>()(
 | 
				
			|||||||
      needCode: true,
 | 
					      needCode: true,
 | 
				
			||||||
      hideUserApiKey: false,
 | 
					      hideUserApiKey: false,
 | 
				
			||||||
      openaiUrl: DEFAULT_OPENAI_URL,
 | 
					      openaiUrl: DEFAULT_OPENAI_URL,
 | 
				
			||||||
 | 
					      hideBalanceQuery: false,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      enabledAccessControl() {
 | 
					      enabledAccessControl() {
 | 
				
			||||||
        get().fetch();
 | 
					        get().fetch();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user