diff --git a/KnifeHub.sln b/KnifeHub.sln index 78caac3ef..cb54d3647 100644 --- a/KnifeHub.sln +++ b/KnifeHub.sln @@ -55,6 +55,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelegramPlugin", "plugins\T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DuplicatiPlugin", "plugins\DuplicatiPlugin\DuplicatiPlugin.csproj", "{81F72AD3-CE49-4886-B18F-443D491A6DB0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebMonitorPlugin", "plugins\WebMonitorPlugin\WebMonitorPlugin.csproj", "{F10458CE-D27C-41D7-A400-A81007347A93}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -153,6 +155,10 @@ Global {81F72AD3-CE49-4886-B18F-443D491A6DB0}.Debug|Any CPU.Build.0 = Debug|Any CPU {81F72AD3-CE49-4886-B18F-443D491A6DB0}.Release|Any CPU.ActiveCfg = Release|Any CPU {81F72AD3-CE49-4886-B18F-443D491A6DB0}.Release|Any CPU.Build.0 = Release|Any CPU + {F10458CE-D27C-41D7-A400-A81007347A93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F10458CE-D27C-41D7-A400-A81007347A93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F10458CE-D27C-41D7-A400-A81007347A93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F10458CE-D27C-41D7-A400-A81007347A93}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -180,6 +186,7 @@ Global {7CDB5D18-8946-4DF5-9ACB-24AC5F9A5906} = {4B4BFBBE-8CE4-453C-B05A-EAFE933B79C9} {8185E32D-32D9-462D-995F-C4522E636B86} = {4B4BFBBE-8CE4-453C-B05A-EAFE933B79C9} {81F72AD3-CE49-4886-B18F-443D491A6DB0} = {4B4BFBBE-8CE4-453C-B05A-EAFE933B79C9} + {F10458CE-D27C-41D7-A400-A81007347A93} = {4B4BFBBE-8CE4-453C-B05A-EAFE933B79C9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3F1D77E3-11F8-4B5B-BEED-EE2816D57A86} diff --git a/plugins/WebMonitorPlugin/Controllers/HomeController.cs b/plugins/WebMonitorPlugin/Controllers/HomeController.cs index bfe98b2f8..f6eb08af9 100644 --- a/plugins/WebMonitorPlugin/Controllers/HomeController.cs +++ b/plugins/WebMonitorPlugin/Controllers/HomeController.cs @@ -13,7 +13,7 @@ namespace WebMonitorPlugin.Controllers { [ApiController] - [Authorize("PluginCoreAdmin")] + [Authorize("PluginCore.Admin")] [Route($"plugins/{nameof(WebMonitorPlugin)}")] public class HomeController : ControllerBase { diff --git a/plugins/WebMonitorPlugin/README.md b/plugins/WebMonitorPlugin/README.md index c37e47df4..135fc630e 100644 --- a/plugins/WebMonitorPlugin/README.md +++ b/plugins/WebMonitorPlugin/README.md @@ -1,4 +1,9 @@ +# 介绍 + +> **注意**: **启用本插件较慢** , 请耐心等待提示 `启用成功` , 若出错, 禁用再启用即可 + +> **注意** : 本插件需要浏览器环境, 如: 此 Docker 镜像 `yiyungent/knifehub:latest-amd-chrome` 中就打包好了浏览器环境 # 基础 @@ -8,6 +13,14 @@ - [设置](/plugincore/admin/index.html#/plugins/settings/WebMonitorPlugin) 里配置提醒通知 +# 插件设置 + +`SecondsPeriod` : 一般保持默认 60 秒的监控频率, 当然若服务器压力大, 可以调高 + +`Selenium.ChromeDriverDirectory` : "" 一般保持为默认空字符串即可, 即使用 当前主程序所在目录 (/app/), 即使用 `yiyungent/knifehub:v1.0.5-amd-chrome` 等镜像 保持默认空字符串即可 + +`CommandTimeoutMinute.CommandTimeoutMinute` : 一般保持默认 5 分钟即可 + # 通知 diff --git a/plugins/WebMonitorPlugin/SettingsModel.cs b/plugins/WebMonitorPlugin/SettingsModel.cs index 4a4689728..8ff026139 100644 --- a/plugins/WebMonitorPlugin/SettingsModel.cs +++ b/plugins/WebMonitorPlugin/SettingsModel.cs @@ -11,12 +11,14 @@ public class SettingsModel : PluginSettingsModel public TelegramModel Telegram { get; set; } + public SeleniumModel Selenium { get; set; } + public class TelegramModel { public string Token { get; set; } public string ChatId { get; set; } - public bool Enable { get; set; } + public bool Enable { get; set; } } @@ -36,6 +38,11 @@ public class MailModel } + public class SeleniumModel + { + public string ChromeDriverDirectory { get; set; } + public long CommandTimeoutMinute { get; set; } + } } } diff --git a/plugins/WebMonitorPlugin/WebMonitorPlugin.cs b/plugins/WebMonitorPlugin/WebMonitorPlugin.cs index f844614a8..3511717a1 100644 --- a/plugins/WebMonitorPlugin/WebMonitorPlugin.cs +++ b/plugins/WebMonitorPlugin/WebMonitorPlugin.cs @@ -111,7 +111,17 @@ public void ExecuteTask(SettingsModel settings, TaskModel task) options.AddArgument("--ignore-certificate-errors"); options.AddArgument("--disable-gpu"); - var driver = new ChromeDriver(chromeDriverDirectory: Environment.CurrentDirectory, options, commandTimeout: TimeSpan.FromMinutes(5)); + string chromeDriverDirectory = Environment.CurrentDirectory; + long commandTimeoutMinute = 5; + if (settings.Selenium != null && settings.Selenium.CommandTimeoutMinute > 0) + { + commandTimeoutMinute = settings.Selenium.CommandTimeoutMinute; + } + if (!string.IsNullOrEmpty(settings.Selenium?.ChromeDriverDirectory)) + { + chromeDriverDirectory = settings.Selenium.ChromeDriverDirectory; + } + var driver = new ChromeDriver(chromeDriverDirectory: chromeDriverDirectory, options, commandTimeout: TimeSpan.FromMinutes(commandTimeoutMinute)); #endregion try diff --git a/plugins/WebMonitorPlugin/WebMonitorPlugin.csproj b/plugins/WebMonitorPlugin/WebMonitorPlugin.csproj index 3a4b00d3f..eb4fb7605 100644 --- a/plugins/WebMonitorPlugin/WebMonitorPlugin.csproj +++ b/plugins/WebMonitorPlugin/WebMonitorPlugin.csproj @@ -1,17 +1,22 @@  - netstandard2.0 + net6.0 + true latest - - - - - + + runtime + + + runtime + + + + @@ -25,6 +30,9 @@ Always + + Always + diff --git a/plugins/WebMonitorPlugin/WebMonitorPlugin.sqlite b/plugins/WebMonitorPlugin/WebMonitorPlugin.sqlite new file mode 100644 index 000000000..a482a34b2 Binary files /dev/null and b/plugins/WebMonitorPlugin/WebMonitorPlugin.sqlite differ diff --git a/plugins/WebMonitorPlugin/info.json b/plugins/WebMonitorPlugin/info.json index c7e4d0395..08b6d6085 100644 --- a/plugins/WebMonitorPlugin/info.json +++ b/plugins/WebMonitorPlugin/info.json @@ -3,6 +3,6 @@ "DisplayName": "网页监控", "Description": "网页监控,看文档", "Author": "yiyun", - "Version": "0.3.1", - "SupportedVersions": [ "0.1.2" ] + "Version": "0.4.1", + "SupportedVersions": [ "0.0.1" ] } \ No newline at end of file diff --git a/plugins/WebMonitorPlugin/settings.json b/plugins/WebMonitorPlugin/settings.json index 3888e33ab..b44c6a62e 100644 --- a/plugins/WebMonitorPlugin/settings.json +++ b/plugins/WebMonitorPlugin/settings.json @@ -1,8 +1,12 @@ { - "SecondsPeriod": 60, - "Telegram": { - "Token": "", - "ChatId": "", - "Enable": false - } + "SecondsPeriod": 60, + "Telegram": { + "Token": "", + "ChatId": "", + "Enable": false + }, + "Selenium": { + "ChromeDriverDirectory": "", + "CommandTimeoutMinute": 5 + } } \ No newline at end of file