From 267cc8271d983653ec8651bdb642e76a80d7a7d0 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sat, 5 Feb 2022 00:59:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?refactor:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Ajax/AjaxService.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/BootstrapBlazor/Components/Ajax/AjaxService.cs b/src/BootstrapBlazor/Components/Ajax/AjaxService.cs index 173751793..adb94cd00 100644 --- a/src/BootstrapBlazor/Components/Ajax/AjaxService.cs +++ b/src/BootstrapBlazor/Components/Ajax/AjaxService.cs @@ -71,16 +71,10 @@ public class AjaxService } /// - /// 调用Goto方法跳转其他页面 + /// 调用 Goto 方法跳转其他页面 /// /// - public async - /// - /// 调用Goto方法跳转其他页面 - /// - /// - Task -Goto(string url) + public async Task Goto(string url) { var cb = GotoCache.FirstOrDefault().Callback; if (cb != null) -- Gitee From 0da6a80877fb3125503800472a1d85991452e020 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Fri, 4 Feb 2022 13:07:10 +0800 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Ajax/Ajax.cs | 5 ++--- .../Components/Ajax/AjaxService.cs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/BootstrapBlazor/Components/Ajax/Ajax.cs b/src/BootstrapBlazor/Components/Ajax/Ajax.cs index 08d750228..bfa46820f 100644 --- a/src/BootstrapBlazor/Components/Ajax/Ajax.cs +++ b/src/BootstrapBlazor/Components/Ajax/Ajax.cs @@ -3,7 +3,6 @@ // Website: https://www.blazor.zone or https://argozhang.github.io/ using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; namespace BootstrapBlazor.Components; @@ -28,13 +27,13 @@ public class Ajax : BootstrapComponentBase, IDisposable private async Task GetMessage(AjaxOption option) { - var obj = await JSRuntime.InvokeAsync(identifier: "$.bb_ajax", option.Url, option.Method, option.Data); + var obj = await JSRuntime.InvokeAsync(null, "bb_ajax", option.Url, option.Method, option.Data); return obj; } private async Task Goto(string url) { - await JSRuntime.InvokeVoidAsync(identifier: "$.bb_ajax_goto", url); + await JSRuntime.InvokeVoidAsync(null, "bb_ajax_goto", url); } /// diff --git a/src/BootstrapBlazor/Components/Ajax/AjaxService.cs b/src/BootstrapBlazor/Components/Ajax/AjaxService.cs index adb94cd00..3a8ee79f4 100644 --- a/src/BootstrapBlazor/Components/Ajax/AjaxService.cs +++ b/src/BootstrapBlazor/Components/Ajax/AjaxService.cs @@ -16,13 +16,6 @@ public class AjaxService /// private List<(IComponent Key, Func> Callback)> Cache { get; } = new(); - /// - /// 注册服务 - /// - /// - /// - internal void Register(IComponent key, Func> callback) => Cache.Add((key, callback)); - /// /// 获得 跳转其他页面的回调委托缓存集合 /// @@ -33,7 +26,7 @@ public class AjaxService /// /// /// - internal void RegisterGoto(IComponent key, Func callback) => GotoCache.Add((key, callback)); + internal void Register(IComponent key, Func> callback) => Cache.Add((key, callback)); /// /// 注销事件 @@ -47,6 +40,13 @@ public class AjaxService } } + /// + /// 注册服务 + /// + /// + /// + internal void RegisterGoto(IComponent key, Func callback) => GotoCache.Add((key, callback)); + /// /// 注销事件 /// -- Gitee From 626b448848e112e5573e9997394031336a96ff77 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Fri, 4 Feb 2022 13:07:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=20ajax=20?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Samples/Ajaxs.razor | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Samples/Ajaxs.razor b/src/BootstrapBlazor.Shared/Samples/Ajaxs.razor index f7456258f..b578aaa66 100644 --- a/src/BootstrapBlazor.Shared/Samples/Ajaxs.razor +++ b/src/BootstrapBlazor.Shared/Samples/Ajaxs.razor @@ -14,12 +14,11 @@
@ResultMessage
- - - + - - + + + -- Gitee From f3fcc79fd60e667327fa07d273d189e54a1bbffa Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Fri, 4 Feb 2022 13:07:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=20Ajax=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/AjaxTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/UnitTest/Components/AjaxTest.cs b/test/UnitTest/Components/AjaxTest.cs index e2e4cb14a..2ec89e7dd 100644 --- a/test/UnitTest/Components/AjaxTest.cs +++ b/test/UnitTest/Components/AjaxTest.cs @@ -22,5 +22,6 @@ public class AjaxTest : BootstrapBlazorTestBase _ = Context.RenderComponent(); _ = service.GetMessage(option); + _ = service.Goto("http://www.blazor.zone"); } } -- Gitee