feat(core): add centralized app constants module
Introduce AppConstants class to consolidate application-wide constant values previously scattered across the Dart codebase. Includes env-aware getters for appTitle and appUrl using getAppEnv(), with NEXT_PUBLIC_* env overrides for OAuth client IDs and sensible fallbacks for local development.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 应用常量类
|
||||
*
|
||||
* 集中管理应用中使用的常量值
|
||||
* 原始 Dart: lib/res/constants.dart
|
||||
*
|
||||
* 注意:
|
||||
* - `facebookAppId` / `googleClientId` 优先从 `process.env.NEXT_PUBLIC_*` 读取,
|
||||
* 缺省回退到 Dart 端的硬编码值(与 `lib/auth/config.ts` 的 `?? ""` 行为不同——
|
||||
* 此处保留默认值便于未配 env 的本地开发)。
|
||||
* - `appTitle` / `appUrl` 复用 `core/net/config/api_config.ts` 的 `getAppEnv()`,
|
||||
* 其底层为 `process.env.NEXT_PUBLIC_APP_ENV`(三态:`development` / `test` / `production`),
|
||||
* 与 `.env.example` 的约定一致。
|
||||
*/
|
||||
import { getAppEnv } from "@/core/net/config/api_config";
|
||||
|
||||
export class AppConstants {
|
||||
private constructor() {}
|
||||
|
||||
/** 隐私政策文档链接 */
|
||||
static readonly privacyPolicyUrl =
|
||||
"https://docs.google.com/document/d/1KyNkbnZ5-2gNUFlE0Jd9eqp-MGKOc95OBAa6hrxK1wg/edit?usp=sharing";
|
||||
|
||||
/** 服务条款文档链接 */
|
||||
static readonly termsOfServiceUrl =
|
||||
"https://docs.google.com/document/d/1ZL5-uDKLNQrkNnWNKlVFi5atwA9hBpNVyoXzzXf1GHs/edit?usp=sharing";
|
||||
|
||||
/** Facebook App ID(env 覆盖优先,缺省回退到 Dart 端硬编码值) */
|
||||
static readonly facebookAppId =
|
||||
process.env.NEXT_PUBLIC_FACEBOOK_APP_ID ?? "26934819589512827";
|
||||
|
||||
/** Google Auth Client ID(env 覆盖优先,缺省回退到 Dart 端硬编码值) */
|
||||
static readonly googleClientId =
|
||||
process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID ??
|
||||
"351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com";
|
||||
|
||||
/** 开发环境 APP 标题 */
|
||||
static readonly appTitleDevelopment = "Develop";
|
||||
|
||||
/** 测试环境 APP 标题 */
|
||||
static readonly appTitleTest = "Test";
|
||||
|
||||
/** 生产环境 APP 标题 */
|
||||
static readonly appTitleProduction = "Cozsweet";
|
||||
|
||||
/** 根据当前环境获取 APP 标题 */
|
||||
static get appTitle(): string {
|
||||
const env = getAppEnv();
|
||||
if (env === "production") return AppConstants.appTitleProduction;
|
||||
if (env === "test") return AppConstants.appTitleTest;
|
||||
return AppConstants.appTitleDevelopment;
|
||||
}
|
||||
|
||||
/** APP 站点 URL(按环境区分:生产用主站域名,其余用前端测试域名) */
|
||||
static get appUrl(): string {
|
||||
return getAppEnv() === "production"
|
||||
? "https://cozsweet.banlv-ai.com"
|
||||
: "https://frontend-test.banlv-ai.com";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user