feat: 添加环境配置和动态主页URL

This commit is contained in:
Booker
2026-05-19 17:34:48 +07:00
parent 1635eef857
commit f97a94bc7f
2 changed files with 35 additions and 1 deletions

View 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/';
}
}

View File

@@ -8,7 +8,9 @@ import 'package:webview_flutter/webview_flutter.dart';
import 'package:webview_flutter_android/webview_flutter_android.dart'; import 'package:webview_flutter_android/webview_flutter_android.dart';
import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.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''' const _stopWebMediaScript = r'''
(() => { (() => {
try { try {