From 661cadfd8de0221bd30e5233129147f463ee8955 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 4 Dec 2025 16:22:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BootstrapBlazor.HikVision/Component1.razor | 3 --- .../BootstrapBlazor.HikVision/Component1.razor.css | 6 ------ 2 files changed, 9 deletions(-) delete mode 100644 src/components/BootstrapBlazor.HikVision/Component1.razor delete mode 100644 src/components/BootstrapBlazor.HikVision/Component1.razor.css diff --git a/src/components/BootstrapBlazor.HikVision/Component1.razor b/src/components/BootstrapBlazor.HikVision/Component1.razor deleted file mode 100644 index 70c378b8..00000000 --- a/src/components/BootstrapBlazor.HikVision/Component1.razor +++ /dev/null @@ -1,3 +0,0 @@ -
- This component is defined in the BootstrapBlazor.HikVision library. -
diff --git a/src/components/BootstrapBlazor.HikVision/Component1.razor.css b/src/components/BootstrapBlazor.HikVision/Component1.razor.css deleted file mode 100644 index c6afca40..00000000 --- a/src/components/BootstrapBlazor.HikVision/Component1.razor.css +++ /dev/null @@ -1,6 +0,0 @@ -.my-component { - border: 2px dashed red; - padding: 1em; - margin: 1em 0; - background-image: url('background.png'); -} From e7150cd97be7ee5fd6885cf767a4d78e761f20c2 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 4 Dec 2025 16:23:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/HikVision.razor.js | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.js b/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.js index 3d38ef1d..198f5c39 100644 --- a/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.js +++ b/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.js @@ -7,39 +7,11 @@ export async function init(id) { return; } - const previewId = `${id}_preview`; - await initVision(previewId); - - const controls = el.querySelector('.bb-hik-controls'); - if (controls) { - EventHandler.on(controls, 'click', '.bb-hik-login', async e => { - console.log('login'); - await login(previewId, '47.121.113.151', 9980, 'admin', 'vhbn8888', 1) - }); - EventHandler.on(controls, 'click', '.bb-hik-logout', e => { - console.log('logout'); - logout(previewId); - }); - EventHandler.on(controls, 'click', '.bb-hik-start', e => { - console.log('start'); - startRealPlay(previewId); - }); - EventHandler.on(controls, 'click', '.bb-hik-stop', e => { - console.log('stop'); - stopRealPlay(previewId); - }); - } + await initVision(id); } -export function dispose(id) { - const el = document.getElementById(id); - if (el !== null) { - const controls = el.querySelector('.bb-hik-controls'); - if (controls) { - EventHandler.off(controls, 'click'); - } - } +export { login, logout, startRealPlay, stopRealPlay } - const previewId = `${id}_preview`; - disposeVision(previewId); +export function dispose(id) { + disposeVision(id); } From 3367285fae6ad6e16fe6da4cc2280ca486ad12eb Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 4 Dec 2025 16:23:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/HikVision.razor | 17 +--- .../Components/HikVision.razor.cs | 84 ++++++++++++++++++- 2 files changed, 84 insertions(+), 17 deletions(-) diff --git a/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor b/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor index 8645aab8..e4b02995 100644 --- a/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor +++ b/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor @@ -1,20 +1,5 @@ @namespace BootstrapBlazor.Components @inherits BootstrapModuleComponentBase -
-
-
- - - - -
+
diff --git a/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.cs b/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.cs index 91d75cb0..bd19718f 100644 --- a/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.cs +++ b/src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.cs @@ -2,6 +2,8 @@ // 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 Microsoft.AspNetCore.Components; + namespace BootstrapBlazor.Components; /// @@ -10,9 +12,89 @@ namespace BootstrapBlazor.Components; [JSModuleAutoLoader("./_content/BootstrapBlazor.HikVision/Components/HikVision.razor.js")] public partial class HikVision { - private string PreviewId => $"{Id}_preview"; + /// + /// 获得/设置 网络摄像机 IP 地址 + /// + [Parameter] + public string? Ip { get; set; } + + /// + /// 获得/设置 网络摄像机 端口号 默认值 80 + /// + [Parameter] + public int Port { get; set; } = 80; + + /// + /// 获得/设置 网络摄像机 登录用户名 + /// + [Parameter] + public string? UserName { get; set; } + + /// + /// 获得/设置 网络摄像机 登录密码 + /// + [Parameter] + public string? Password { get; set; } + + /// + /// 获得/设置 网络摄像机 登录类型 默认值 + /// + [Parameter] + public LoginType LoginType { get; set; } + + /// + /// 获得/设置 视频图像窗口宽度 默认值 500px + /// + [Parameter] + public string? Width { get; set; } + + /// + /// 获得/设置 视频图像窗口高度 默认值 300px + /// + [Parameter] + public string? Height { get; set; } private string? ClassString => CssBuilder.Default("bb-hik") .AddClassFromAttributes(AdditionalAttributes) .Build(); + + private string? StyleString => CssBuilder.Default() + .AddClass($"width: {Width};", !string.IsNullOrEmpty(Width)) + .AddClass($"height: {Height};", !string.IsNullOrEmpty(Height)) + .AddStyleFromAttributes(AdditionalAttributes) + .Build(); + + /// + /// + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + Width ??= "500px"; + Height ??= "300px"; + } + + /// + /// 登录方法 + /// + /// + /// + /// + /// + /// + /// + public async Task Login(string ip, string port, string userName, string password, LoginType loginType = LoginType.Http) + { + await InvokeVoidAsync("login", Id, ip, port, userName, password, (int)loginType); + } + + /// + /// 登出方法 + /// + /// + public async Task Logout() + { + await InvokeVoidAsync("logout", Id); + } }