Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<IsWebProject>true</IsWebProject>
Expand Down Expand Up @@ -42,7 +42,7 @@
<PackageReference Include="BootstrapBlazor.FluentSystemIcon" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.Gantt" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.HikVision" Version="10.0.9" />
<PackageReference Include="BootstrapBlazor.HikVision" Version="10.0.10" />
<PackageReference Include="BootstrapBlazor.Holiday" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.Html2Image" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.Html2Pdf" Version="10.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</BootstrapInputGroup>
</div>
<div class="col-12">
<div style="width: 100%; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));">
<div class="hik-controls">
<Button OnClick="OnLogin" IsDisabled="_loginStatus">
<span>登录</span>
</Button>
Expand Down Expand Up @@ -106,6 +106,12 @@
<Button OnClick="OnStopRecord" IsDisabled="_stopRecordStatus">
<span>停止录像</span>
</Button>
<Dropdown Value="@_iWndType" IsDisabled="false" Items="_iWndTypes"
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IsDisabled="false" attribute is redundant as false is the default value for the IsDisabled property. This explicit assignment should be removed for cleaner code.

Suggested change
<Dropdown Value="@_iWndType" IsDisabled="false" Items="_iWndTypes"
<Dropdown Value="@_iWndType" Items="_iWndTypes"

Copilot uses AI. Check for mistakes.
MenuAlignment="Alignment.Right" OnSelectedItemChanged="OnWndTypeChanged">
<ButtonTemplate>
<span>分屏 (@context.Text)</span>
</ButtonTemplate>
</Dropdown>
</div>
</div>
}
Expand Down
34 changes: 25 additions & 9 deletions src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public partial class HikVisions
private string _userName = "admin";
private bool _inited;

private bool _loginStatus => _hikVision.IsLogin;
private bool _logoutStatus => !_hikVision.IsLogin;
private bool _startRealPlayStatus => _hikVision is not { IsLogin: true, IsRealPlaying: false };
private bool _stopRealPlayStatus => _hikVision is not { IsLogin: true, IsRealPlaying: true };
private bool _openSoundStatus => _hikVision is not { IsLogin: true, IsRealPlaying: true, IsOpenSound: false };
private bool _closeSoundStatus => _hikVision is not { IsLogin: true, IsRealPlaying: true, IsOpenSound: true };
private bool _startRecordStatus => _hikVision is not { IsLogin: true, IsRealPlaying: true, IsStartRecord: false };
private bool _stopRecordStatus => _hikVision is not { IsLogin: true, IsRealPlaying: true, IsStartRecord: true };
private bool _loginStatus => _hikVision.IsMultipleWindowType ? false : _hikVision.IsLogin;
private bool _logoutStatus => _hikVision.IsMultipleWindowType ? false : !_hikVision.IsLogin;
private bool _startRealPlayStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: false };
private bool _stopRealPlayStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true };
private bool _openSoundStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsOpenSound: false };
private bool _closeSoundStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsOpenSound: true };
private bool _startRecordStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsStartRecord: false };
private bool _stopRecordStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsStartRecord: true };

Comment on lines +29 to 37
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These boolean status properties have confusing logic due to double negatives. The pattern _hikVision is not { IsLogin: true, IsRealPlaying: false } is negating a property check, which when combined with the IsMultipleWindowType check makes it difficult to understand when buttons should be disabled. Consider using positive logic patterns and adding comments to clarify the intended button state (enabled/disabled) for each scenario.

Suggested change
private bool _loginStatus => _hikVision.IsMultipleWindowType ? false : _hikVision.IsLogin;
private bool _logoutStatus => _hikVision.IsMultipleWindowType ? false : !_hikVision.IsLogin;
private bool _startRealPlayStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: false };
private bool _stopRealPlayStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true };
private bool _openSoundStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsOpenSound: false };
private bool _closeSoundStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsOpenSound: true };
private bool _startRecordStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsStartRecord: false };
private bool _stopRecordStatus => _hikVision.IsMultipleWindowType ? false : _hikVision is not { IsLogin: true, IsRealPlaying: true, IsStartRecord: true };
// true when in single-window mode and the plugin reports a logged-in state
private bool _loginStatus => !_hikVision.IsMultipleWindowType && _hikVision.IsLogin;
// true when in single-window mode and the plugin reports a logged-out state
private bool _logoutStatus => !_hikVision.IsMultipleWindowType && !_hikVision.IsLogin;
// true when in single-window mode and NOT (logged in and currently not playing)
private bool _startRealPlayStatus =>
!_hikVision.IsMultipleWindowType &&
!(_hikVision.IsLogin && !_hikVision.IsRealPlaying);
// true when in single-window mode and NOT (logged in and currently playing)
private bool _stopRealPlayStatus =>
!_hikVision.IsMultipleWindowType &&
!(_hikVision.IsLogin && _hikVision.IsRealPlaying);
// true when in single-window mode and NOT (logged in, playing, and sound is closed)
private bool _openSoundStatus =>
!_hikVision.IsMultipleWindowType &&
!(_hikVision.IsLogin && _hikVision.IsRealPlaying && !_hikVision.IsOpenSound);
// true when in single-window mode and NOT (logged in, playing, and sound is open)
private bool _closeSoundStatus =>
!_hikVision.IsMultipleWindowType &&
!(_hikVision.IsLogin && _hikVision.IsRealPlaying && _hikVision.IsOpenSound);
// true when in single-window mode and NOT (logged in, playing, and recording is stopped)
private bool _startRecordStatus =>
!_hikVision.IsMultipleWindowType &&
!(_hikVision.IsLogin && _hikVision.IsRealPlaying && !_hikVision.IsStartRecord);
// true when in single-window mode and NOT (logged in, playing, and recording is started)
private bool _stopRecordStatus =>
!_hikVision.IsMultipleWindowType &&
!(_hikVision.IsLogin && _hikVision.IsRealPlaying && _hikVision.IsStartRecord);

Copilot uses AI. Check for mistakes.
private List<SelectedItem> _analogChannels = [];
private int _channelId = 1;
Expand All @@ -45,7 +45,16 @@ public partial class HikVisions
new SelectedItem("3", "第三码流"),
new SelectedItem("4", "转码码流")
];

private readonly List<SelectedItem> _iWndTypes =
[
new SelectedItem("1", "1*1"),
new SelectedItem("2", "2*2"),
new SelectedItem("3", "3*3"),
new SelectedItem("4", "4*4"),
new SelectedItem("1*2", "1*2"),
new SelectedItem("2*1", "2*1")
];
Comment on lines +48 to +56
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of this collection is inconsistent with C# naming conventions and lacks clarity. The abbreviation _iWndTypes (presumably "iWindow Types") is unclear. Consider renaming to _windowLayoutTypes or _windowGridTypes to better describe that these represent different grid layout options (1x1, 2x2, etc.) for the video display window.

Copilot uses AI. Check for mistakes.
private string _iWndType = "1";
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of this variable is inconsistent with the existing naming convention in the file. Other similar variables use camelCase with descriptive names like _streamType, _channelId, but this uses an abbreviation _iWndType. Consider renaming to _windowType or _windowLayoutType for better clarity and consistency with the codebase naming patterns.

Copilot uses AI. Check for mistakes.
private async Task OnLogin()
{
await _hikVision.Login(_ip, _port, _userName, _password, HikVisionLoginType.Http);
Expand Down Expand Up @@ -208,4 +217,11 @@ private Task OnStopRealPlayedAsync()
StateHasChanged();
return Task.CompletedTask;
}

private async Task OnWndTypeChanged(SelectedItem item)
{
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method lacks null safety checking. If item or item.Value is null, this will cause a runtime exception. Consider adding null checks or using null-coalescing operators to handle edge cases gracefully.

Suggested change
{
{
if (item is null || string.IsNullOrEmpty(item.Value))
{
return;
}

Copilot uses AI. Check for mistakes.
_iWndType = item.Value;
await _hikVision.ChangeWindowNum(_iWndType);
StateHasChanged();
}
}
10 changes: 10 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/HikVisions.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.hik-controls {
width: 100%;
display: grid;
gap: .5rem;
grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}

.hik-controls ::deep .btn {
white-space: nowrap;
}
Comment on lines +8 to +10
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inconsistent indentation in this CSS file. The .hik-controls selector starts with indentation, but the nested selector .hik-controls ::deep .btn has even more indentation. CSS at the root level should not have leading indentation for consistency with standard CSS formatting conventions.

Suggested change
.hik-controls ::deep .btn {
white-space: nowrap;
}
.hik-controls ::deep .btn {
white-space: nowrap;
}

Copilot uses AI. Check for mistakes.
Loading