diff --git a/ui/lib/providers/settings.dart b/ui/lib/providers/settings.dart index 6954a88..a3d6d63 100644 --- a/ui/lib/providers/settings.dart +++ b/ui/lib/providers/settings.dart @@ -290,6 +290,10 @@ class DownloadClient { data["remove_failed_downloads"] = removeFailedDownloads; return data; } + + bool idExists() { + return id != null && id != 0; + } } class StorageSettingData extends AutoDisposeAsyncNotifier> { diff --git a/ui/lib/settings/downloader.dart b/ui/lib/settings/downloader.dart index 98fe3ef..a75f146 100644 --- a/ui/lib/settings/downloader.dart +++ b/ui/lib/settings/downloader.dart @@ -68,11 +68,13 @@ class _DownloaderState extends ConsumerState { children: [ FormBuilderTextField( name: "name", + enabled: client.idExists(), decoration: const InputDecoration(labelText: "名称"), validator: FormBuilderValidators.required(), autovalidateMode: AutovalidateMode.onUserInteraction), FormBuilderTextField( name: "url", + enabled: client.idExists(), decoration: const InputDecoration( labelText: "地址", hintText: "http://127.0.0.1:9091"), autovalidateMode: AutovalidateMode.onUserInteraction, @@ -80,6 +82,7 @@ class _DownloaderState extends ConsumerState { ), FormBuilderTextField( name: "priority", + enabled: client.idExists(), decoration: const InputDecoration( labelText: "优先级", helperText: "1-50, 1最高优先级,50最低优先级"), validator: FormBuilderValidators.integer(), @@ -96,6 +99,7 @@ class _DownloaderState extends ConsumerState { children: [ FormBuilderSwitch( name: "auth", + enabled: client.idExists(), title: const Text("需要认证"), initialValue: _enableAuth, onChanged: (v) { @@ -162,7 +166,7 @@ class _DownloaderState extends ConsumerState { } return showSettingDialog( - context, title, client.id != null, body, onSubmit, onDelete); + context, title, client.idExists(), body, onSubmit, onDelete); } Future showSelections() { diff --git a/ui/run.bat b/ui/run.bat index 485cc01..718eaa7 100644 --- a/ui/run.bat +++ b/ui/run.bat @@ -1 +1 @@ -flutter run -d edge --no-web-resources-cdn --web-browser-flag "--disable-web-security" \ No newline at end of file +flutter run -d chrome --no-web-resources-cdn --web-browser-flag "--disable-web-security" \ No newline at end of file