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
22 changes: 21 additions & 1 deletion src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public partial class PdfReader
[Parameter]
public Func<bool, Task>? OnTwoPagesOneViewAsync { get; set; }

/// <summary>
/// 设置缩放倍率回调方法
/// </summary>
[Parameter]
public Func<float, Task>? OnScaleChangedAsync { get; set; }

/// <summary>
/// 获得/设置 更多按钮图标 默认为 null 使用内置图标
/// </summary>
Expand Down Expand Up @@ -225,7 +231,8 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
TriggerPagesInit = OnPagesInitAsync != null,
TriggerPagesLoaded = OnPagesLoadedAsync != null,
TriggerPageChanged = OnPageChangedAsync != null,
TriggerTowPagesOnViewChanged = OnTwoPagesOneViewAsync != null
TriggerTowPagesOnViewChanged = OnTwoPagesOneViewAsync != null,
TriggerScaleChanged = OnScaleChangedAsync != null
});

/// <summary>
Expand Down Expand Up @@ -302,6 +309,19 @@ public async Task PageChanged(uint pageIndex)
}
}

/// <summary>
/// 缩放倍率更改回调方法
/// </summary>
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Missing <param> documentation for the val parameter. Other similar callback methods in this file (e.g., PagesInit, PagesLoaded, PageChanged) include <param> documentation for their parameters.

Suggested change
/// </summary>
/// </summary>
/// <param name="val">缩放倍率值</param>

Copilot uses AI. Check for mistakes.
/// <returns></returns>
[JSInvokable]
public async Task ScaleChanged(float val)
{
if (OnScaleChangedAsync != null)
{
await OnScaleChangedAsync(val);
}
}

/// <summary>
/// 正在打印回调方法
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,13 @@ const addEventBus = (el, pdfViewer, eventBus, invoke, options) => {
}, true);


eventBus.on("scalechanging", evt => updateScaleValue(el, evt.scale));
eventBus.on("scalechanging", async evt => {
updateScaleValue(el, evt.scale);

if (options.triggerScaleChanged) {
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Inconsistent boolean check pattern. Other trigger checks in this function use strict equality comparison with === true (lines 306, 312, 346). Consider changing if (options.triggerScaleChanged) to if (options.triggerScaleChanged === true) for consistency.

Suggested change
if (options.triggerScaleChanged) {
if (options.triggerScaleChanged === true) {

Copilot uses AI. Check for mistakes.
await invoke.invokeMethodAsync("ScaleChanged", evt.scale);
}
})
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Missing semicolon at the end of the eventBus.on("scalechanging", ...) statement. All other event handler registrations in this function (lines 309, 325, 349, 365) end with semicolons for consistency.

Suggested change
})
});

Copilot uses AI. Check for mistakes.

eventBus.on("rotationchanging", evt => {
const thumbnailsContainer = el.querySelector(".bb-view-thumbnails");
Expand Down
Loading