mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 10:00:27 +00:00
feat: support launch at startup (#532)
This commit is contained in:
12 files changed
+118
-21
No files matched your search
@@ -6,13 +6,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:launch_at_startup/launch_at_startup.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../../../api/model/downloader_config.dart';
|
||||
import '../../../../database/database.dart';
|
||||
import '../../../../i18n/message.dart';
|
||||
import '../../../../util/input_formatter.dart';
|
||||
import '../../../../util/locale_manager.dart';
|
||||
import '../../../../util/log_util.dart';
|
||||
import '../../../../util/message.dart';
|
||||
import '../../../../util/package_info.dart';
|
||||
import '../../../../util/util.dart';
|
||||
@@ -130,9 +131,36 @@ class SettingView extends GetView<SettingController> {
|
||||
"https://addons.mozilla.org/zh-CN/firefox/addon/gopeed-extension",
|
||||
),
|
||||
],
|
||||
).paddingOnly(top: 5, bottom: 5));
|
||||
).paddingOnly(top: 5));
|
||||
}
|
||||
|
||||
// Currently auto startup only support Windows and Linux
|
||||
final buildAutoStartup = !Util.isWindows() && !Util.isLinux()
|
||||
? () => null
|
||||
: _buildConfigItem('launchAtStartup'.tr, () {
|
||||
return appController.autoStartup.value ? 'on'.tr : 'off'.tr;
|
||||
}, (Key key) {
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Switch(
|
||||
value: appController.autoStartup.value,
|
||||
onChanged: (bool value) async {
|
||||
try {
|
||||
if (value) {
|
||||
await launchAtStartup.enable();
|
||||
} else {
|
||||
await launchAtStartup.disable();
|
||||
}
|
||||
appController.autoStartup.value = value;
|
||||
} catch (e) {
|
||||
showErrorMessage(e);
|
||||
logger.e('launchAtStartup fail', e);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// http config items start
|
||||
final httpConfig = downloaderCfg.value.protocolConfig.http;
|
||||
final buildHttpUa =
|
||||
@@ -784,7 +812,8 @@ class SettingView extends GetView<SettingController> {
|
||||
children: _addDivider([
|
||||
buildDownloadDir(),
|
||||
buildMaxRunning(),
|
||||
buildBrowserExtension()
|
||||
buildBrowserExtension(),
|
||||
buildAutoStartup(),
|
||||
]),
|
||||
)),
|
||||
const Text('HTTP'),
|
||||
|
||||
Reference in new issue
Block a user