mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-05-09 00:34:17 +08:00
Exception handling for loading app config
This commit is contained in:
@@ -38,6 +38,14 @@ import 'network/util/logger.dart';
|
||||
void main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
//多窗口
|
||||
if (args.firstOrNull == 'multi_window') {
|
||||
final windowId = int.parse(args[1]);
|
||||
final argument = args[2].isEmpty ? const {} : jsonDecode(args[2]) as Map<String, dynamic>;
|
||||
runApp(FluentApp(multiWindow(windowId, argument), (await AppConfiguration.instance)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Platform.isWindows) {
|
||||
await WindowsSingleInstance.ensureSingleInstance([], "ProxyPin", onSecondWindow: (args) {
|
||||
logger.d('WindowsSingleInstance onSecondWindow $args');
|
||||
@@ -46,14 +54,6 @@ void main(List<String> args) async {
|
||||
}
|
||||
|
||||
var instance = AppConfiguration.instance;
|
||||
//多窗口
|
||||
if (args.firstOrNull == 'multi_window') {
|
||||
final windowId = int.parse(args[1]);
|
||||
final argument = args[2].isEmpty ? const {} : jsonDecode(args[2]) as Map<String, dynamic>;
|
||||
runApp(FluentApp(multiWindow(windowId, argument), (await instance)));
|
||||
return;
|
||||
}
|
||||
|
||||
var configuration = Configuration.instance;
|
||||
//移动端
|
||||
if (Platforms.isMobile()) {
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
@@ -93,9 +92,14 @@ class AppConfiguration {
|
||||
|
||||
static Future<AppConfiguration> get instance async {
|
||||
if (_instance == null) {
|
||||
AppConfiguration configuration = AppConfiguration._();
|
||||
await configuration.initConfig();
|
||||
_instance = configuration;
|
||||
try {
|
||||
AppConfiguration configuration = AppConfiguration._();
|
||||
await configuration.initConfig();
|
||||
_instance = configuration;
|
||||
} catch (e) {
|
||||
logger.e("load config error: $e");
|
||||
_instance = AppConfiguration._();
|
||||
}
|
||||
}
|
||||
return _instance!;
|
||||
}
|
||||
@@ -145,7 +149,7 @@ class AppConfiguration {
|
||||
Future<File> get _path async {
|
||||
if (Platforms.isDesktop()) {
|
||||
var userHome = Platform.environment['HOME'] ?? Platform.environment['USERPROFILE'];
|
||||
return File('$userHome/.proxypin/ui_config.json');
|
||||
return File('$userHome${Platform.pathSeparator}.proxypin${Platform.pathSeparator}ui_config.json');
|
||||
}
|
||||
|
||||
final directory = await getApplicationSupportDirectory();
|
||||
@@ -225,13 +229,10 @@ class AppConfiguration {
|
||||
'upgradeNoticeV17': upgradeNoticeV17,
|
||||
"language": _language?.languageCode,
|
||||
"headerExpanded": headerExpanded,
|
||||
|
||||
if (memoryCleanupThreshold != null) 'memoryCleanupThreshold': memoryCleanupThreshold,
|
||||
|
||||
if (Platforms.isMobile()) 'pipEnabled': pipEnabled.value,
|
||||
if (Platforms.isMobile()) 'pipIcon': pipIcon.value ? true : null,
|
||||
if (Platforms.isMobile()) 'bottomNavigation': bottomNavigation,
|
||||
|
||||
if (Platforms.isDesktop())
|
||||
"windowSize": windowSize == null ? null : {"width": windowSize?.width, "height": windowSize?.height},
|
||||
if (Platforms.isDesktop())
|
||||
|
||||
@@ -412,17 +412,18 @@ class _DomainRequestsState extends State<DomainRequests> {
|
||||
if (!changing) {
|
||||
changing = true;
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
setState(() {
|
||||
changing = false;
|
||||
});
|
||||
transitionState.currentState?.show();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
changing = false;
|
||||
});
|
||||
transitionState.currentState?.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Column(children: [
|
||||
_hostWidget(widget.domain),
|
||||
Offstage(offstage: !selected, child: Column(children: widget.body.toList()))
|
||||
|
||||
@@ -24,7 +24,7 @@ dependencies:
|
||||
url: https://gitee.com/wanghongenpin/flutter-plugins.git
|
||||
path: packages/desktop_multi_window
|
||||
path_provider: ^2.1.5
|
||||
file_picker: ^9.0.2
|
||||
file_picker: ^9.2.3
|
||||
proxy_manager: ^0.0.3
|
||||
permission_handler: ^11.3.1
|
||||
flutter_toastr: ^1.0.3
|
||||
@@ -36,7 +36,7 @@ dependencies:
|
||||
ref: secure-keyboard
|
||||
flutter_desktop_context_menu: ^0.2.0
|
||||
device_info_plus: ^11.2.1
|
||||
shared_preferences: ^2.3.5
|
||||
shared_preferences: ^2.5.3
|
||||
image_pickers: ^2.0.5+2
|
||||
url_launcher: ^6.3.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user