From ffd7cfabbcfa7f07d9ceee4adae9c38b476bf5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E4=BA=91?= Date: Wed, 2 Apr 2025 21:40:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20js=20=E9=80=9A=E7=9F=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20(#1376)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: js 通知支持 * feat: 添加全局或者在配置组中单独禁用js的通知功能 --- .../Core/Script/Dependence/Notification.cs | 114 ++++++++++++++++++ .../Core/Script/EngineExtend.cs | 1 + .../Core/Script/Group/ScriptGroupProject.cs | 4 + BetterGenshinImpact/GameTask/TaskContext.cs | 2 + .../Model/Enum/NotificationEvent.cs | 2 + .../Notification/NotificationConfig.cs | 4 + BetterGenshinImpact/Service/ScriptService.cs | 2 + .../View/Pages/NotificationSettingsPage.xaml | 25 ++++ .../Editable/ScriptGroupProjectEditor.xaml | 15 +++ .../Editable/ScriptGroupProjectEditor.xaml.cs | 5 +- .../ViewModel/Pages/ScriptControlViewModel.cs | 10 +- .../ScriptGroupProjectEditorViewModel.cs | 63 ++++++++++ 12 files changed, 244 insertions(+), 3 deletions(-) create mode 100644 BetterGenshinImpact/Core/Script/Dependence/Notification.cs create mode 100644 BetterGenshinImpact/ViewModel/Windows/Editable/ScriptGroupProjectEditorViewModel.cs diff --git a/BetterGenshinImpact/Core/Script/Dependence/Notification.cs b/BetterGenshinImpact/Core/Script/Dependence/Notification.cs new file mode 100644 index 00000000..2274476f --- /dev/null +++ b/BetterGenshinImpact/Core/Script/Dependence/Notification.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using BetterGenshinImpact.Core.Config; +using BetterGenshinImpact.GameTask; +using BetterGenshinImpact.Service.Notification; +using BetterGenshinImpact.Service.Notification.Model.Enum; +using Microsoft.Extensions.Logging; + +namespace BetterGenshinImpact.Core.Script.Dependence; + +public class Notification +{ + private readonly AllConfig _config = TaskContext.Instance().Config; + private readonly ILogger _logger = App.GetLogger(); + private readonly TimeSpan _timeWindow = TimeSpan.FromMinutes(1); + private readonly int _maxNotifications = 5; + private readonly Queue _callRecords = new(); + + private static readonly string[] _forbiddenPatterns = + [ + "