From d3ad80380fc9eb5afefd6c168e617f19b01fa45e Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Tue, 13 Aug 2024 10:17:46 +0800 Subject: [PATCH] feat: nfo support frontend --- server/setting.go | 9 +++++++++ ui/lib/providers/settings.dart | 4 ++++ ui/lib/settings/general.dart | 12 +++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/server/setting.go b/server/setting.go index a989e62..9aec41c 100644 --- a/server/setting.go +++ b/server/setting.go @@ -19,6 +19,7 @@ type GeneralSettings struct { LogLevel string `json:"log_level"` Proxy string `json:"proxy"` EnablePlexmatch bool `json:"enable_plexmatch"` + EnableNfo bool `json:"enable_nfo"` AllowQiangban bool `json:"allow_qiangban"` } @@ -62,6 +63,12 @@ func (s *Server) SetSetting(c *gin.Context) (interface{}, error) { s.db.SetSetting(db.SettingAllowQiangban, "false") } + if in.EnableNfo { + s.db.SetSetting(db.SettingNfoSupportEnabled, "true") + } else { + s.db.SetSetting(db.SettingNfoSupportEnabled, "false") + } + return nil, nil } @@ -71,6 +78,7 @@ func (s *Server) GetSetting(c *gin.Context) (interface{}, error) { logLevel := s.db.GetSetting(db.SettingLogLevel) plexmatchEnabled := s.db.GetSetting(db.SettingPlexMatchEnabled) allowQiangban := s.db.GetSetting(db.SettingAllowQiangban) + enableNfo := s.db.GetSetting(db.SettingNfoSupportEnabled) return &GeneralSettings{ TmdbApiKey: tmdb, DownloadDir: downloadDir, @@ -78,6 +86,7 @@ func (s *Server) GetSetting(c *gin.Context) (interface{}, error) { Proxy: s.db.GetSetting(db.SettingProxy), EnablePlexmatch: plexmatchEnabled == "true", AllowQiangban: allowQiangban == "true", + EnableNfo: enableNfo == "true", }, nil } diff --git a/ui/lib/providers/settings.dart b/ui/lib/providers/settings.dart index 52db8c5..85efa97 100644 --- a/ui/lib/providers/settings.dart +++ b/ui/lib/providers/settings.dart @@ -53,6 +53,7 @@ class GeneralSetting { String? proxy; bool? enablePlexmatch; bool? allowQiangban; + bool? enableNfo; GeneralSetting( {this.tmdbApiKey, @@ -60,6 +61,7 @@ class GeneralSetting { this.logLevel, this.proxy, this.enablePlexmatch, + this.enableNfo, this.allowQiangban}); factory GeneralSetting.fromJson(Map json) { @@ -69,6 +71,7 @@ class GeneralSetting { logLevel: json["log_level"], proxy: json["proxy"], allowQiangban: json["allow_qiangban"] ?? false, + enableNfo: json["enable_nfo"] ?? false, enablePlexmatch: json["enable_plexmatch"] ?? false); } @@ -80,6 +83,7 @@ class GeneralSetting { data["proxy"] = proxy; data["enable_plexmatch"] = enablePlexmatch; data["allow_qiangban"] = allowQiangban; + data["enable_nfo"] = enableNfo; return data; } } diff --git a/ui/lib/settings/general.dart b/ui/lib/settings/general.dart index 48824e7..44efa19 100644 --- a/ui/lib/settings/general.dart +++ b/ui/lib/settings/general.dart @@ -36,6 +36,7 @@ class _GeneralState extends ConsumerState { "proxy": v.proxy, "enable_plexmatch": v.enablePlexmatch, "allow_qiangban": v.allowQiangban, + "enable_nfo": v.enableNfo, }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -92,7 +93,15 @@ class _GeneralState extends ConsumerState { width: 300, child: FormBuilderSwitch( decoration: - const InputDecoration(icon: Icon(Icons.phone_iphone)), + const InputDecoration(icon: Icon(Icons.library_books), helperText: "emby/kodi等软件刮削需要"), + name: "enable_nfo", + title: const Text("nfo 文件支持")), + ), + SizedBox( + width: 300, + child: FormBuilderSwitch( + decoration: + const InputDecoration(icon: Icon(Icons.remove_circle)), name: "allow_qiangban", title: const Text("是否下载枪版资源")), ), @@ -115,6 +124,7 @@ class _GeneralState extends ConsumerState { logLevel: values["log_level"], proxy: values["proxy"], allowQiangban: values["allow_qiangban"], + enableNfo: values["enable_nfo"], enablePlexmatch: values["enable_plexmatch"])) .then((v) => showSnakeBar("更新成功"));