mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 22:33:42 +00:00
feat: add notify when new version option (#1115)
This commit is contained in:
6 files changed
+31
No files matched your search
@@ -81,6 +81,7 @@ class ExtraConfig {
|
|||||||
bool lastDeleteTaskKeep;
|
bool lastDeleteTaskKeep;
|
||||||
bool defaultDirectDownload;
|
bool defaultDirectDownload;
|
||||||
bool defaultBtClient;
|
bool defaultBtClient;
|
||||||
|
bool notifyWhenNewVersion;
|
||||||
|
|
||||||
ExtraConfigBt bt = ExtraConfigBt();
|
ExtraConfigBt bt = ExtraConfigBt();
|
||||||
|
|
||||||
@@ -90,6 +91,7 @@ class ExtraConfig {
|
|||||||
this.lastDeleteTaskKeep = false,
|
this.lastDeleteTaskKeep = false,
|
||||||
this.defaultDirectDownload = false,
|
this.defaultDirectDownload = false,
|
||||||
this.defaultBtClient = true,
|
this.defaultBtClient = true,
|
||||||
|
this.notifyWhenNewVersion = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ExtraConfig.fromJson(Map<String, dynamic>? json) =>
|
factory ExtraConfig.fromJson(Map<String, dynamic>? json) =>
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ ExtraConfig _$ExtraConfigFromJson(Map<String, dynamic> json) => ExtraConfig(
|
|||||||
lastDeleteTaskKeep: json['lastDeleteTaskKeep'] as bool? ?? false,
|
lastDeleteTaskKeep: json['lastDeleteTaskKeep'] as bool? ?? false,
|
||||||
defaultDirectDownload: json['defaultDirectDownload'] as bool? ?? false,
|
defaultDirectDownload: json['defaultDirectDownload'] as bool? ?? false,
|
||||||
defaultBtClient: json['defaultBtClient'] as bool? ?? true,
|
defaultBtClient: json['defaultBtClient'] as bool? ?? true,
|
||||||
|
notifyWhenNewVersion: json['notifyWhenNewVersion'] as bool? ?? true,
|
||||||
)..bt = ExtraConfigBt.fromJson(json['bt'] as Map<String, dynamic>);
|
)..bt = ExtraConfigBt.fromJson(json['bt'] as Map<String, dynamic>);
|
||||||
|
|
||||||
Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
||||||
@@ -83,6 +84,7 @@ Map<String, dynamic> _$ExtraConfigToJson(ExtraConfig instance) =>
|
|||||||
'lastDeleteTaskKeep': instance.lastDeleteTaskKeep,
|
'lastDeleteTaskKeep': instance.lastDeleteTaskKeep,
|
||||||
'defaultDirectDownload': instance.defaultDirectDownload,
|
'defaultDirectDownload': instance.defaultDirectDownload,
|
||||||
'defaultBtClient': instance.defaultBtClient,
|
'defaultBtClient': instance.defaultBtClient,
|
||||||
|
'notifyWhenNewVersion': instance.notifyWhenNewVersion,
|
||||||
'bt': instance.bt.toJson(),
|
'bt': instance.bt.toJson(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -506,6 +506,11 @@ class AppController extends GetxController with WindowListener, TrayListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initCheckUpdate() async {
|
Future<void> _initCheckUpdate() async {
|
||||||
|
// Check if auto check update is enabled
|
||||||
|
if (!downloaderConfig.value.extra.notifyWhenNewVersion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final versionInfo = await checkUpdate();
|
final versionInfo = await checkUpdate();
|
||||||
if (versionInfo != null) {
|
if (versionInfo != null) {
|
||||||
await showUpdateDialog(Get.context!, versionInfo);
|
await showUpdateDialog(Get.context!, versionInfo);
|
||||||
|
|||||||
@@ -531,6 +531,25 @@ class SettingView extends GetView<SettingController> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final buildAutoCheckUpdate = _buildConfigItem(
|
||||||
|
'notifyWhenNewVersion',
|
||||||
|
() =>
|
||||||
|
downloaderCfg.value.extra.notifyWhenNewVersion ? 'on'.tr : 'off'.tr,
|
||||||
|
(Key key) {
|
||||||
|
return Container(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Switch(
|
||||||
|
value: downloaderCfg.value.extra.notifyWhenNewVersion,
|
||||||
|
onChanged: (bool value) async {
|
||||||
|
downloaderCfg.update((val) {
|
||||||
|
val!.extra.notifyWhenNewVersion = value;
|
||||||
|
});
|
||||||
|
await debounceSave();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
buildThanks() {
|
buildThanks() {
|
||||||
const thankPage =
|
const thankPage =
|
||||||
'https://github.com/GopeedLab/gopeed/graphs/contributors';
|
'https://github.com/GopeedLab/gopeed/graphs/contributors';
|
||||||
@@ -957,6 +976,7 @@ class SettingView extends GetView<SettingController> {
|
|||||||
children: _addDivider([
|
children: _addDivider([
|
||||||
buildHomepage(),
|
buildHomepage(),
|
||||||
buildVersion(),
|
buildVersion(),
|
||||||
|
buildAutoCheckUpdate(),
|
||||||
buildThanks(),
|
buildThanks(),
|
||||||
]),
|
]),
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ const enUS = {
|
|||||||
'themeLight': 'Light',
|
'themeLight': 'Light',
|
||||||
'themeDark': 'Dark',
|
'themeDark': 'Dark',
|
||||||
'locale': 'Language',
|
'locale': 'Language',
|
||||||
|
'notifyWhenNewVersion': 'Notify for updates',
|
||||||
'about': 'About',
|
'about': 'About',
|
||||||
'homepage': 'Homepage',
|
'homepage': 'Homepage',
|
||||||
'version': 'Version',
|
'version': 'Version',
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const zhCN = {
|
|||||||
'themeLight': '明亮主题',
|
'themeLight': '明亮主题',
|
||||||
'themeDark': '暗黑主题',
|
'themeDark': '暗黑主题',
|
||||||
'locale': '语言',
|
'locale': '语言',
|
||||||
|
'notifyWhenNewVersion': '有新版本时提醒',
|
||||||
'about': '关于',
|
'about': '关于',
|
||||||
'homepage': '主页',
|
'homepage': '主页',
|
||||||
'version': '版本',
|
'version': '版本',
|
||||||
|
|||||||
Reference in new issue
Block a user