feat: 添加环境配置和动态主页URL
This commit is contained in:
32
lib/config/app_config.dart
Normal file
32
lib/config/app_config.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
enum Environment {
|
||||
production,
|
||||
}
|
||||
|
||||
class AppConfig {
|
||||
static const Environment currentEnvironment = Environment.production;
|
||||
|
||||
static final Map<Environment, List<String>> _environmentHosts = {
|
||||
Environment.production: [
|
||||
'h5-im.imharry.work',
|
||||
],
|
||||
};
|
||||
|
||||
static List<String> get environmentHosts {
|
||||
return _environmentHosts[currentEnvironment] ?? const [];
|
||||
}
|
||||
|
||||
static String get homeUrl {
|
||||
final host = environmentHosts.isNotEmpty
|
||||
? environmentHosts.first
|
||||
: 'h5-im.imharry.work';
|
||||
return _normalizeHomeUrl(host);
|
||||
}
|
||||
|
||||
static String _normalizeHomeUrl(String host) {
|
||||
final value = host.trim();
|
||||
if (value.startsWith('http://') || value.startsWith('https://')) {
|
||||
return value.endsWith('/') ? value : '$value/';
|
||||
}
|
||||
return 'https://$value/';
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,9 @@ import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:webview_flutter_android/webview_flutter_android.dart';
|
||||
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart';
|
||||
|
||||
const _homeUrl = 'https://h5-im.imharry.work/';
|
||||
import 'config/app_config.dart';
|
||||
|
||||
final _homeUrl = AppConfig.homeUrl;
|
||||
const _stopWebMediaScript = r'''
|
||||
(() => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user