From 66f2b80c8b2289a83a6c9f8a4884be4a044a896b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 5 Dec 2025 11:02:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js index d95263af..14f4ede9 100644 --- a/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js +++ b/src/components/BootstrapBlazor.HikVision/wwwroot/hikvision.js @@ -212,7 +212,6 @@ export async function startRealPlay(id, iStreamType, iChannelID) { }); }; - console.log(oWndInfo); if (oWndInfo !== null) { WebVideoCtrl.I_Stop({ success: function () { From 689228cfa942cf4d8f8be8e4a451e9ce0c4c956c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 5 Dec 2025 11:02:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=94=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/HikVisionWebPlugin.razor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs b/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs index 40d87b33..6a0e16f8 100644 --- a/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs +++ b/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs @@ -122,6 +122,7 @@ public async Task Logout() { await InvokeVoidAsync("logout", Id); } + IsRealPlaying = false; IsLogined = false; } From bea0cfc015d5f580e3c8c1091eb071065e755839 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 5 Dec 2025 11:10:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/HikVisionWebPlugin.razor.cs | 77 +++++++++++++++++-- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs b/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs index 6a0e16f8..abe3dd9c 100644 --- a/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs +++ b/src/components/BootstrapBlazor.HikVision/Components/HikVisionWebPlugin.razor.cs @@ -58,7 +58,31 @@ public partial class HikVisionWebPlugin /// 获得/设置 插件初始化完成后回调方法 /// [Parameter] - public Func OnInitedAsync { get; set; } + public Func? OnInitedAsync { get; set; } + + /// + /// 获得/设置 登录成功后回调方法 + /// + [Parameter] + public Func? OnLoginedAsync { get; set; } + + /// + /// 获得/设置 注销成功后回调方法 + /// + [Parameter] + public Func? OnLogoutedAsync { get; set; } + + /// + /// 获得/设置 开始预览后回调方法 + /// + [Parameter] + public Func? OnStartRealPlayedAsync { get; set; } + + /// + /// 获得/设置 停止预览后回调方法 + /// + [Parameter] + public Func? OnStopRealPlayedAsync { get; set; } private string? ClassString => CssBuilder.Default("bb-hik") .AddClassFromAttributes(AdditionalAttributes) @@ -109,9 +133,21 @@ public async Task Login(string ip, int port, string userName, string passw { ThrowIfNotInited(); IsLogined = await InvokeAsync("login", Id, ip, port, userName, password, (int)loginType) ?? false; + if (IsLogined) + { + await TriggerLogined(); + } return IsLogined; } + private async Task TriggerLogined() + { + if (OnLoginedAsync != null) + { + await OnLoginedAsync(); + } + } + /// /// 登出方法 /// @@ -124,6 +160,15 @@ public async Task Logout() } IsRealPlaying = false; IsLogined = false; + await TriggerLogouted(); + } + + private async Task TriggerLogouted() + { + if (OnLogoutedAsync != null) + { + await OnLogoutedAsync(); + } } /// @@ -135,6 +180,18 @@ public async Task StartRealPlay(int streamType, int channelId) if (IsLogined && !IsRealPlaying) { IsRealPlaying = await InvokeAsync("startRealPlay", Id, streamType, channelId) ?? false; + if (IsRealPlaying) + { + await TriggerStartRealPlay(); + } + } + } + + private async Task TriggerStartRealPlay() + { + if (OnStartRealPlayedAsync != null) + { + await OnStartRealPlayedAsync(); } } @@ -144,13 +201,19 @@ public async Task StartRealPlay(int streamType, int channelId) /// public async Task StopRealPlay() { - if (IsLogined && IsRealPlaying) + if (IsRealPlaying) { - var result = await InvokeAsync("stopRealPlay", Id) ?? false; - if (result) - { - IsRealPlaying = false; - } + await InvokeVoidAsync("stopRealPlay", Id); + IsRealPlaying = false; + await TriggerStopRealPlay(); + } + } + + private async Task TriggerStopRealPlay() + { + if (OnStopRealPlayedAsync != null) + { + await OnStopRealPlayedAsync(); } }