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
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,31 @@ public partial class HikVisionWebPlugin
/// 获得/设置 插件初始化完成后回调方法
/// </summary>
[Parameter]
public Func<bool, Task> OnInitedAsync { get; set; }
public Func<bool, Task>? OnInitedAsync { get; set; }

/// <summary>
/// 获得/设置 登录成功后回调方法
/// </summary>
[Parameter]
public Func<Task>? OnLoginedAsync { get; set; }
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The callback name OnLoginedAsync uses incorrect grammar. "Logined" is not a valid past participle in English. Consider renaming to OnLoggedInAsync to be grammatically correct and consistent with standard English usage, or use OnLoginSuccessAsync as an alternative.

Suggested change
public Func<Task>? OnLoginedAsync { get; set; }
public Func<Task>? OnLoggedInAsync { get; set; }

Copilot uses AI. Check for mistakes.

/// <summary>
/// 获得/设置 注销成功后回调方法
/// </summary>
[Parameter]
public Func<Task>? OnLogoutedAsync { get; set; }
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The callback name OnLogoutedAsync uses incorrect grammar. "Logouted" is not a valid past participle in English. Consider renaming to OnLoggedOutAsync to be grammatically correct and consistent with standard English usage, or use OnLogoutSuccessAsync as an alternative.

Suggested change
public Func<Task>? OnLogoutedAsync { get; set; }
public Func<Task>? OnLoggedOutAsync { get; set; }

Copilot uses AI. Check for mistakes.

/// <summary>
/// 获得/设置 开始预览后回调方法
/// </summary>
[Parameter]
public Func<Task>? OnStartRealPlayedAsync { get; set; }

/// <summary>
/// 获得/设置 停止预览后回调方法
/// </summary>
[Parameter]
public Func<Task>? OnStopRealPlayedAsync { get; set; }

private string? ClassString => CssBuilder.Default("bb-hik")
.AddClassFromAttributes(AdditionalAttributes)
Expand Down Expand Up @@ -109,9 +133,21 @@ public async Task<bool> Login(string ip, int port, string userName, string passw
{
ThrowIfNotInited();
IsLogined = await InvokeAsync<bool?>("login", Id, ip, port, userName, password, (int)loginType) ?? false;
if (IsLogined)
{
await TriggerLogined();
}
return IsLogined;
}

private async Task TriggerLogined()
Comment on lines +138 to +143
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The method name TriggerLogined uses incorrect grammar. "Logined" is not a valid past participle. This should be renamed to TriggerLoggedIn to match the suggested parameter name correction.

Suggested change
await TriggerLogined();
}
return IsLogined;
}
private async Task TriggerLogined()
await TriggerLoggedIn();
}
return IsLogined;
}
private async Task TriggerLoggedIn()

Copilot uses AI. Check for mistakes.
{
if (OnLoginedAsync != null)
{
await OnLoginedAsync();
}
}

/// <summary>
/// 登出方法
/// </summary>
Expand All @@ -122,7 +158,17 @@ public async Task Logout()
{
await InvokeVoidAsync("logout", Id);
}
IsRealPlaying = false;
IsLogined = false;
await TriggerLogouted();
}

private async Task TriggerLogouted()
{
if (OnLogoutedAsync != null)
{
await OnLogoutedAsync();
Comment on lines +163 to +170
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The method name TriggerLogouted uses incorrect grammar. "Logouted" is not a valid past participle. This should be renamed to TriggerLoggedOut to match the suggested parameter name correction.

Suggested change
await TriggerLogouted();
}
private async Task TriggerLogouted()
{
if (OnLogoutedAsync != null)
{
await OnLogoutedAsync();
await TriggerLoggedOut();
}
private async Task TriggerLoggedOut()
{
if (OnLoggedOutAsync != null)
{
await OnLoggedOutAsync();

Copilot uses AI. Check for mistakes.
}
}

/// <summary>
Expand All @@ -134,6 +180,18 @@ public async Task StartRealPlay(int streamType, int channelId)
if (IsLogined && !IsRealPlaying)
{
IsRealPlaying = await InvokeAsync<bool?>("startRealPlay", Id, streamType, channelId) ?? false;
if (IsRealPlaying)
{
await TriggerStartRealPlay();
}
}
}

private async Task TriggerStartRealPlay()
{
if (OnStartRealPlayedAsync != null)
{
await OnStartRealPlayedAsync();
}
}

Expand All @@ -143,13 +201,19 @@ public async Task StartRealPlay(int streamType, int channelId)
/// <returns></returns>
public async Task StopRealPlay()
{
if (IsLogined && IsRealPlaying)
if (IsRealPlaying)
{
var result = await InvokeAsync<bool?>("stopRealPlay", Id) ?? false;
if (result)
{
IsRealPlaying = false;
}
await InvokeVoidAsync("stopRealPlay", Id);
IsRealPlaying = false;
await TriggerStopRealPlay();
Comment on lines +206 to +208
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The method now calls InvokeVoidAsync instead of checking the return value from the JavaScript function. However, the JavaScript stopRealPlay function still returns a Promise with a boolean result. This discrepancy means potential errors from the JavaScript side will be silently ignored. The callback OnStopRealPlayedAsync is now always triggered even if the JavaScript operation fails. Consider either: (1) reverting to InvokeAsync<bool?> and checking the result, or (2) updating the JavaScript function to properly handle and throw errors.

Suggested change
await InvokeVoidAsync("stopRealPlay", Id);
IsRealPlaying = false;
await TriggerStopRealPlay();
var result = await InvokeAsync<bool?>("stopRealPlay", Id);
if (result ?? false)
{
IsRealPlaying = false;
await TriggerStopRealPlay();
}
// Optionally handle failure here (e.g., log, throw, notify user)

Copilot uses AI. Check for mistakes.
}
}

private async Task TriggerStopRealPlay()
{
if (OnStopRealPlayedAsync != null)
{
await OnStopRealPlayedAsync();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export async function startRealPlay(id, iStreamType, iChannelID) {
});
};

console.log(oWndInfo);
if (oWndInfo !== null) {
WebVideoCtrl.I_Stop({
success: function () {
Expand Down
Loading