update at 2025-10-08 22:26:26
This commit is contained in:
@@ -27,7 +27,9 @@ function parseAspectRatio(ratio: string): { width: number; height: number } {
|
||||
*/
|
||||
function getTargetPageHeight(settings: NMPSettings): number {
|
||||
const ratio = parseAspectRatio(settings.sliceImageAspectRatio);
|
||||
return Math.round((settings.sliceImageWidth * ratio.height) / ratio.width);
|
||||
const height = Math.round((settings.sliceImageWidth * ratio.height) / ratio.width);
|
||||
console.log(`[paginator] 计算页面高度: 宽度=${settings.sliceImageWidth}, 比例=${settings.sliceImageAspectRatio} (${ratio.width}:${ratio.height}), 高度=${height}`);
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,20 +152,26 @@ function wrapPageContent(elements: Element[]): string {
|
||||
|
||||
/**
|
||||
* 渲染单个页面到容器
|
||||
* 预览时缩放显示,切图时使用实际尺寸
|
||||
*/
|
||||
export function renderPage(
|
||||
container: HTMLElement,
|
||||
pageContent: string,
|
||||
settings: NMPSettings
|
||||
): void {
|
||||
const pageHeight = getTargetPageHeight(settings);
|
||||
const pageWidth = settings.sliceImageWidth;
|
||||
// 实际内容尺寸(切图使用)
|
||||
const actualPageWidth = settings.sliceImageWidth;
|
||||
const actualPageHeight = getTargetPageHeight(settings);
|
||||
|
||||
console.log(`[renderPage] 渲染页面: 宽=${actualPageWidth}, 高=${actualPageHeight}`);
|
||||
|
||||
container.innerHTML = '';
|
||||
|
||||
// 直接设置为实际尺寸,用于切图
|
||||
// 预览时通过外层 CSS 的 max-width 限制显示宽度,浏览器自动缩放
|
||||
container.style.cssText = `
|
||||
width: ${pageWidth}px;
|
||||
min-height: ${pageHeight}px;
|
||||
max-height: ${pageHeight}px;
|
||||
width: ${actualPageWidth}px;
|
||||
height: ${actualPageHeight}px;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
padding: 40px;
|
||||
|
||||
Reference in New Issue
Block a user