6e51cb7d16
- Updated comments in various components, schemas, and repositories to remove references to original Dart files. - Ensured consistency in documentation while maintaining the context of the code.
37 lines
836 B
TypeScript
37 lines
836 B
TypeScript
/**
|
|
* 应用环境检测
|
|
*
|
|
*
|
|
*
|
|
* 基于 `.env*` 中的 `NEXT_PUBLIC_APP_ENV` 判断当前业务环境。
|
|
*
|
|
* 注意:该变量带 `NEXT_PUBLIC_` 前缀,可同时用于服务端和客户端代码。
|
|
*/
|
|
export type AppEnv = "development" | "test" | "production";
|
|
|
|
export class AppEnvUtil {
|
|
private constructor() {}
|
|
|
|
static get current(): AppEnv {
|
|
const env = process.env.NEXT_PUBLIC_APP_ENV;
|
|
if (env === "production" || env === "test") return env;
|
|
return "development";
|
|
}
|
|
|
|
static isDevelopment(): boolean {
|
|
return AppEnvUtil.current === "development";
|
|
}
|
|
|
|
static isProduction(): boolean {
|
|
return AppEnvUtil.current === "production";
|
|
}
|
|
|
|
static isTest(): boolean {
|
|
return AppEnvUtil.current === "test";
|
|
}
|
|
|
|
static canOutputLogs(): boolean {
|
|
return !AppEnvUtil.isProduction();
|
|
}
|
|
}
|