From 707376c2bdbab76e083f6a04bf11cef34c5adc28 Mon Sep 17 00:00:00 2001 From: meoacgx Date: Sat, 20 Dec 2025 05:26:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B4=A6=E5=8F=B7=E5=90=AF=E7=94=A8/?= =?UTF-8?q?=E5=81=9C=E7=94=A8=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TelegramPanel.Web/Components/Pages/Accounts.razor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/TelegramPanel.Web/Components/Pages/Accounts.razor b/src/TelegramPanel.Web/Components/Pages/Accounts.razor index 278e533..9b85e01 100644 --- a/src/TelegramPanel.Web/Components/Pages/Accounts.razor +++ b/src/TelegramPanel.Web/Components/Pages/Accounts.razor @@ -535,9 +535,13 @@ { try { - await AccountManagement.SetAccountActiveStatusAsync(account.Id, !account.IsActive); - account.IsActive = !account.IsActive; - Snackbar.Add($"账号已{(account.IsActive ? "启用" : "停用")}", Severity.Success); + var newIsActive = !account.IsActive; + await AccountManagement.SetAccountActiveStatusAsync(account.Id, newIsActive); + + // 注意:Account 实体可能被同一个 DbContext 跟踪,SetAccountActiveStatusAsync 内部已更新该实例。 + // 这里用 newIsActive 赋值/提示,避免出现“又反转一次”的提示错误。 + account.IsActive = newIsActive; + Snackbar.Add($"账号已{(newIsActive ? "启用" : "停用")}", Severity.Success); } catch (Exception ex) {