From 716eeca4bb41fa49951883ea02456e65cd8c23b3 Mon Sep 17 00:00:00 2001 From: Falcon <12919280+falconfly@user.noreply.gitee.com> Date: Thu, 19 Nov 2026 14:58:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AA=97=E4=BD=93socpe?= =?UTF-8?q?=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrivateBox/Forms/MainForm.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PrivateBox/Forms/MainForm.cs b/PrivateBox/Forms/MainForm.cs index 646e55a..d224c19 100644 --- a/PrivateBox/Forms/MainForm.cs +++ b/PrivateBox/Forms/MainForm.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using Falcon.SugarCore.DbContextExtensions; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using PrivateBox.DataContext; using PrivateBox.Encryption; @@ -15,7 +16,6 @@ namespace PrivateBox public AppRunTimeSettings Settings { get; set; } public ILogger Logger { get; set; } - /// /// 默认分组名 /// @@ -28,8 +28,13 @@ namespace PrivateBox /// private bool EnableRefreshKeyList = true; - public MainForm(IServiceProvider provider) { + public MainForm(IServiceScopeFactory factory) { InitializeComponent(); + var serviceScope = factory.CreateScope(); + this.FormClosing += (s,d) => { + serviceScope?.Dispose(); + }; + var provider = serviceScope.ServiceProvider; this.Encrytion = provider.GetRequiredService(); this.Db = provider.GetRequiredService(); this.Settings = provider.GetRequiredService(); @@ -41,6 +46,7 @@ namespace PrivateBox RefreshKeyList(); }; + this.lbKeyList.SelectedIndexChanged += LbKeyList_SelectedIndexChanged; this.clb_group.ItemCheck += (s,e) => { this.BeginInvoke(new Action(() => {