1655769827
BASE_URL/PUBLIC_URL/ABOUT_URL 默认值改为线上,flutter run 不带 --dart-define 即连生产;需本地后端时显式 --dart-define 覆盖。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bupi8Kdqkfx2N5acFsHTx5
46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
/// 集中管理应用配置,通过 --dart-define=KEY=value 注入环境变量
|
|
///
|
|
/// 默认值 = 线上服务(jiu.51yanmei.com):本地 flutter run 不带 define 也连生产。
|
|
/// 需连本地后端时显式覆盖:flutter run \
|
|
/// --dart-define=BASE_URL=http://localhost:8080 \
|
|
/// --dart-define=PUBLIC_URL=http://localhost:8081
|
|
class AppConfig {
|
|
const AppConfig._();
|
|
|
|
static const _baseUrl = String.fromEnvironment(
|
|
'BASE_URL',
|
|
defaultValue: 'https://jiu.51yanmei.com',
|
|
);
|
|
|
|
static const _publicUrl = String.fromEnvironment(
|
|
'PUBLIC_URL',
|
|
defaultValue: 'https://jiu.51yanmei.com',
|
|
);
|
|
|
|
static const shopName = String.fromEnvironment(
|
|
'SHOP_NAME',
|
|
defaultValue: '酒库管理系统',
|
|
);
|
|
|
|
static const shopAddress = String.fromEnvironment(
|
|
'SHOP_ADDRESS',
|
|
defaultValue: '',
|
|
);
|
|
|
|
static const shopPhone = String.fromEnvironment(
|
|
'SHOP_PHONE',
|
|
defaultValue: '',
|
|
);
|
|
|
|
static const aboutUrl = String.fromEnvironment(
|
|
'ABOUT_URL',
|
|
defaultValue: 'https://jiu.51yanmei.com',
|
|
);
|
|
|
|
static String get baseUrl => _baseUrl;
|
|
static String get apiBaseUrl => '$_baseUrl/api/v1';
|
|
static String get healthUrl => '$_baseUrl/health';
|
|
static String get versionUrl => '$_baseUrl/version';
|
|
static String get publicBaseUrl => _publicUrl;
|
|
}
|