WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3367285

Browse files
committed
refactor: 更新组件
1 parent e7150cd commit 3367285

File tree

2 files changed

+84
-17
lines changed

2 files changed

+84
-17
lines changed
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
@namespace BootstrapBlazor.Components
22
@inherits BootstrapModuleComponentBase
33

4-
<div @attributes="AdditionalAttributes" class="@ClassString" id="@Id">
5-
<div id="@PreviewId" class="bb-hik-preview" style="width: 500px; height: 300px;"></div>
6-
<div class="bb-hik-controls">
7-
<button class="btn btn-primary bb-hik-login">
8-
<span>登录</span>
9-
</button>
10-
<button class="btn btn-primary bb-hik-logout">
11-
<span>退出</span>
12-
</button>
13-
<button class="btn btn-primary bb-hik-start">
14-
<span>开始预览</span>
15-
</button>
16-
<button class="btn btn-primary bb-hik-stop">
17-
<span>停止预览</span>
18-
</button>
19-
</div>
4+
<div @attributes="AdditionalAttributes" class="@ClassString" id="@Id" style="@StyleString">
205
</div>

src/components/BootstrapBlazor.HikVision/Components/HikVision.razor.cs

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5+
using Microsoft.AspNetCore.Components;
6+
57
namespace BootstrapBlazor.Components;
68

79
/// <summary>
@@ -10,9 +12,89 @@ namespace BootstrapBlazor.Components;
1012
[JSModuleAutoLoader("./_content/BootstrapBlazor.HikVision/Components/HikVision.razor.js")]
1113
public partial class HikVision
1214
{
13-
private string PreviewId => $"{Id}_preview";
15+
/// <summary>
16+
/// 获得/设置 网络摄像机 IP 地址
17+
/// </summary>
18+
[Parameter]
19+
public string? Ip { get; set; }
20+
21+
/// <summary>
22+
/// 获得/设置 网络摄像机 端口号 默认值 80
23+
/// </summary>
24+
[Parameter]
25+
public int Port { get; set; } = 80;
26+
27+
/// <summary>
28+
/// 获得/设置 网络摄像机 登录用户名
29+
/// </summary>
30+
[Parameter]
31+
public string? UserName { get; set; }
32+
33+
/// <summary>
34+
/// 获得/设置 网络摄像机 登录密码
35+
/// </summary>
36+
[Parameter]
37+
public string? Password { get; set; }
38+
39+
/// <summary>
40+
/// 获得/设置 网络摄像机 登录类型 默认值 <see cref="LoginType.Http"/>
41+
/// </summary>
42+
[Parameter]
43+
public LoginType LoginType { get; set; }
44+
45+
/// <summary>
46+
/// 获得/设置 视频图像窗口宽度 默认值 500px
47+
/// </summary>
48+
[Parameter]
49+
public string? Width { get; set; }
50+
51+
/// <summary>
52+
/// 获得/设置 视频图像窗口高度 默认值 300px
53+
/// </summary>
54+
[Parameter]
55+
public string? Height { get; set; }
1456

1557
private string? ClassString => CssBuilder.Default("bb-hik")
1658
.AddClassFromAttributes(AdditionalAttributes)
1759
.Build();
60+
61+
private string? StyleString => CssBuilder.Default()
62+
.AddClass($"width: {Width};", !string.IsNullOrEmpty(Width))
63+
.AddClass($"height: {Height};", !string.IsNullOrEmpty(Height))
64+
.AddStyleFromAttributes(AdditionalAttributes)
65+
.Build();
66+
67+
/// <summary>
68+
/// <inheritdoc/>
69+
/// </summary>
70+
protected override void OnParametersSet()
71+
{
72+
base.OnParametersSet();
73+
74+
Width ??= "500px";
75+
Height ??= "300px";
76+
}
77+
78+
/// <summary>
79+
/// 登录方法
80+
/// </summary>
81+
/// <param name="ip"></param>
82+
/// <param name="port"></param>
83+
/// <param name="userName"></param>
84+
/// <param name="password"></param>
85+
/// <param name="loginType"></param>
86+
/// <returns></returns>
87+
public async Task Login(string ip, string port, string userName, string password, LoginType loginType = LoginType.Http)
88+
{
89+
await InvokeVoidAsync("login", Id, ip, port, userName, password, (int)loginType);
90+
}
91+
92+
/// <summary>
93+
/// 登出方法
94+
/// </summary>
95+
/// <returns></returns>
96+
public async Task Logout()
97+
{
98+
await InvokeVoidAsync("logout", Id);
99+
}
18100
}

0 commit comments

Comments
 (0)