From f97a94bc7f0a55e10ad65a17e53be34f7f1d69b0 Mon Sep 17 00:00:00 2001 From: Booker Date: Tue, 19 May 2026 17:34:48 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=92=8C=E5=8A=A8=E6=80=81=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config/app_config.dart | 32 ++++++++++++++++++++++++++++++++ lib/main.dart | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lib/config/app_config.dart diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart new file mode 100644 index 0000000..6286a1c --- /dev/null +++ b/lib/config/app_config.dart @@ -0,0 +1,32 @@ +enum Environment { + production, +} + +class AppConfig { + static const Environment currentEnvironment = Environment.production; + + static final Map> _environmentHosts = { + Environment.production: [ + 'h5-im.imharry.work', + ], + }; + + static List 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/'; + } +} diff --git a/lib/main.dart b/lib/main.dart index 868e74d..78ef398 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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 {