From fba31f29a37362ac59ea7acec9a1376d04822070 Mon Sep 17 00:00:00 2001 From: token <239573049@qq.com> Date: Fri, 5 Apr 2024 01:21:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=80=BC=E8=A2=AB=E8=A6=86=E7=9B=96=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=BB=91=E7=99=BD=E5=90=8D=E5=8D=95=E8=A2=AB=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FastGateway/Services/ProtectionService.cs | 11 +++++++++++ web/src/pages/http-proxy/features/CreateHttpProxy.tsx | 8 +++++--- web/src/pages/http-proxy/features/UpdateHttpProxy.tsx | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/FastGateway/Services/ProtectionService.cs b/src/FastGateway/Services/ProtectionService.cs index 7776ad1..4a54fff 100644 --- a/src/FastGateway/Services/ProtectionService.cs +++ b/src/FastGateway/Services/ProtectionService.cs @@ -119,6 +119,9 @@ public static class ProtectionService await masterDbContext.SaveChangesAsync(); + // 重新加载黑白名单 + await LoadBlacklistAndWhitelistAsync(masterDbContext); + return ResultDto.SuccessResult(); } @@ -207,6 +210,8 @@ public static class ProtectionService .SetProperty(i => i.Enable, blacklist.Enable) .SetProperty(i => i.Type, blacklist.Type)); + // 重新加载黑白名单 + await LoadBlacklistAndWhitelistAsync(masterDbContext); return ResultDto.SuccessResult(); } @@ -217,6 +222,9 @@ public static class ProtectionService .ExecuteDeleteAsync(); await masterDbContext.SaveChangesAsync(); + + // 重新加载黑白名单 + await LoadBlacklistAndWhitelistAsync(masterDbContext); } public static async Task>> GetBlacklistListAsync( @@ -240,5 +248,8 @@ public static class ProtectionService await masterDbContext.BlacklistAndWhitelists.Where(x => x.Id == id) .ExecuteUpdateAsync(x => x.SetProperty(i => i.Enable, enable)); + + // 重新加载黑白名单 + await LoadBlacklistAndWhitelistAsync(masterDbContext); } } \ No newline at end of file diff --git a/web/src/pages/http-proxy/features/CreateHttpProxy.tsx b/web/src/pages/http-proxy/features/CreateHttpProxy.tsx index 674653d..b826310 100644 --- a/web/src/pages/http-proxy/features/CreateHttpProxy.tsx +++ b/web/src/pages/http-proxy/features/CreateHttpProxy.tsx @@ -21,6 +21,7 @@ export default function CreateHttpProxy({ onClose, onOk, }: ICreateHttpProxyProps) { + return ( { values.enableBlacklist = v; formApi.setValues(values); @@ -182,6 +184,8 @@ export default function CreateHttpProxy({ values.enableWhitelist = v; formApi.setValues(values); }} + initValue={values.enableWhitelist} + defaultChecked={values.enableWhitelist} label={"白名单:" + (values.enableWhitelist ? '启用' : '停用')} style={{ marginTop: '5px', @@ -247,8 +251,6 @@ export default function CreateHttpProxy({ message: '域名不能为空', }]} onChange={(v: any) => { - console.log(v); - arrayField.serviceNames = v; formApi.setValues(values); }} diff --git a/web/src/pages/http-proxy/features/UpdateHttpProxy.tsx b/web/src/pages/http-proxy/features/UpdateHttpProxy.tsx index cd0db25..8d63aa0 100644 --- a/web/src/pages/http-proxy/features/UpdateHttpProxy.tsx +++ b/web/src/pages/http-proxy/features/UpdateHttpProxy.tsx @@ -136,7 +136,7 @@ export default function UpdateHttpProxy({ { values.enableBlacklist = v; formApi.setValues(values);