From 8184660bb292d533d177df3c87636c765bf1d3df Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 10 Dec 2025 10:08:12 +0800 Subject: [PATCH 1/2] chore(HikVision): remove IHikVision interface --- .../Extensions/ServiceCollectionExtensions.cs | 25 ------- .../Services/DefaultHicVision.cs | 71 ------------------- .../Services/IHikVision.cs | 42 ----------- 3 files changed, 138 deletions(-) delete mode 100644 src/components/BootstrapBlazor.HikVision/Extensions/ServiceCollectionExtensions.cs delete mode 100644 src/components/BootstrapBlazor.HikVision/Services/DefaultHicVision.cs delete mode 100644 src/components/BootstrapBlazor.HikVision/Services/IHikVision.cs diff --git a/src/components/BootstrapBlazor.HikVision/Extensions/ServiceCollectionExtensions.cs b/src/components/BootstrapBlazor.HikVision/Extensions/ServiceCollectionExtensions.cs deleted file mode 100644 index d78df93f..00000000 --- a/src/components/BootstrapBlazor.HikVision/Extensions/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -using BootstrapBlazor.Components; -using Microsoft.Extensions.DependencyInjection.Extensions; - -namespace Microsoft.Extensions.DependencyInjection; - -/// -/// BootstrapBlazor 服务扩展类 -/// -public static class ServiceCollectionExtensions -{ - /// - /// 增加海康威视网络摄像机 Web 服务 - /// - /// - /// - public static IServiceCollection AddBootstrapBlazorHikVision(this IServiceCollection services) - { - services.TryAddScoped(); - return services; - } -} diff --git a/src/components/BootstrapBlazor.HikVision/Services/DefaultHicVision.cs b/src/components/BootstrapBlazor.HikVision/Services/DefaultHicVision.cs deleted file mode 100644 index 88b52494..00000000 --- a/src/components/BootstrapBlazor.HikVision/Services/DefaultHicVision.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -namespace BootstrapBlazor.Components; - -sealed class DefaultHicVision(IJSRuntime jsRuntime) : IHikVision -{ - private JSModule _module = default!; - private bool _initialized; - private bool _logined; - - public async Task Login(string ip, int port, string userName, string password, HikVisionLoginType loginType = HikVisionLoginType.Http) - { - await LoadAsync(); - - if (!_logined) - { - _logined = await _module.InvokeAsync("login", ip, port, userName, password, (int)loginType); - } - - return _logined; - } - - public async Task Logout(string ip, int port) - { - if (_logined) - { - _logined = await _module.InvokeAsync("logout"); - } - - return _logined; - } - - public async Task StartRealPlay() - { - if (_logined) - { - await _module.InvokeVoidAsync("startRealPlay"); - } - } - - public async Task StopRealPlay() - { - if (_logined) - { - await _module.InvokeVoidAsync("stopRealPlay"); - } - } - - private async Task LoadAsync() - { - if (!_initialized) - { - var module = await jsRuntime.InvokeAsync("import", "./_content/BootstrapBlazor.HikVision/hikvision.js"); - _module = new JSModule(module); - - _initialized = true; - } - } - - public async ValueTask DisposeAsync() - { - if (_module != null) - { - await _module.InvokeVoidAsync("dispose"); - await _module.DisposeAsync(); - } - GC.SuppressFinalize(this); - } -} diff --git a/src/components/BootstrapBlazor.HikVision/Services/IHikVision.cs b/src/components/BootstrapBlazor.HikVision/Services/IHikVision.cs deleted file mode 100644 index 10119036..00000000 --- a/src/components/BootstrapBlazor.HikVision/Services/IHikVision.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -namespace BootstrapBlazor.Components; - -/// -/// 海康威视网络摄像机接口 -/// -public interface IHikVision : IAsyncDisposable -{ - /// - /// 登录方法 - /// - /// 登录方式 实例 - /// 设备 Ip 地址 - /// 设备端口 - /// 用户名 - /// 密码 - /// - Task Login(string ip, int port, string userName, string password, HikVisionLoginType loginType = HikVisionLoginType.Http); - - /// - /// 登出方法 - /// - /// 设备 Ip 地址 - /// 设备端口 - /// - Task Logout(string ip, int port); - - /// - /// 开始实时预览画面方法 - /// - /// - Task StartRealPlay(); - - /// - /// 停止实时预览画面方法 - /// - /// - Task StopRealPlay(); -} From 126dea0b946527447dde1bda775072d069798235 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 10 Dec 2025 10:09:12 +0800 Subject: [PATCH 2/2] chore: bump version 10.0.4 --- .../BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj b/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj index 6d49b425..3d45d7a5 100644 --- a/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj +++ b/src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj @@ -1,7 +1,7 @@ - 10.0.3 + 10.0.4