feat: 添加环境配置区分本地和生产环境
- 使用 --dart-define=ENV=prod 构建生产版本 - 生产环境: http://8.155.172.147:5010 - 本地环境: http://localhost:5010 - 更新 web 构建产物 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1 +1 @@
|
|||||||
cd059bcd8df9e9b2b7bfff5ee9fb7ba7
|
2b1d2ed877ca1d041aef5d6561fbfcf5
|
||||||
@@ -37,6 +37,6 @@ _flutter.buildConfig = {"engineRevision":"e4b8dca3f1b4ede4c30371002441c88c12187e
|
|||||||
|
|
||||||
_flutter.loader.load({
|
_flutter.loader.load({
|
||||||
serviceWorkerSettings: {
|
serviceWorkerSettings: {
|
||||||
serviceWorkerVersion: "2672737280" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
|
serviceWorkerVersion: "3100103420" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,16 @@
|
|||||||
class ApiEndpoints {
|
class ApiEndpoints {
|
||||||
ApiEndpoints._();
|
ApiEndpoints._();
|
||||||
|
|
||||||
/// 基础URL
|
/// 环境类型
|
||||||
static const String baseUrl = 'http://localhost:5010';
|
static const String _env = String.fromEnvironment('ENV', defaultValue: 'dev');
|
||||||
|
|
||||||
|
/// 基础URL - 根据环境自动切换
|
||||||
|
static const String baseUrl = _env == 'prod'
|
||||||
|
? 'http://8.155.172.147:5010'
|
||||||
|
: 'http://localhost:5010';
|
||||||
|
|
||||||
|
/// 是否为生产环境
|
||||||
|
static const bool isProduction = _env == 'prod';
|
||||||
|
|
||||||
// ==================== 用户模块 ====================
|
// ==================== 用户模块 ====================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user