fix(app): Flutter Web 开发模式默认连接 localhost:3000 API
- app.dart: kDebugMode 下使用 AppConfig.dev (localhost:3000) - dev.mjs: flutter run 传入 --dart-define API_BASE_URL/SSE_BASE_URL
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// └─ BlocProvider<AuthBloc>
|
||||
// └─ MaterialApp.router
|
||||
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:flutter/foundation.dart' show kIsWeb, kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -37,7 +37,8 @@ class NuanjiApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 创建全局依赖(App 生命周期内单例)
|
||||
final config = AppConfig.fromEnvironment();
|
||||
// 开发模式默认使用 localhost,可通过 --dart-define 覆盖
|
||||
final config = kDebugMode ? AppConfig.dev : AppConfig.fromEnvironment();
|
||||
final apiClient = ApiClient(baseUrl: config.apiBaseUrl);
|
||||
final tokenStore = createSecureTokenStore();
|
||||
final authRepository = AuthRepository(apiClient: apiClient, tokenStore: tokenStore);
|
||||
|
||||
Reference in New Issue
Block a user