vomebook commited on
Commit
737dc41
·
verified ·
1 Parent(s): 4de059f

Upload 2 files

Browse files
Files changed (2) hide show
  1. static/app.js +9 -2
  2. static/style.css +2 -0
static/app.js CHANGED
@@ -1610,7 +1610,7 @@ function proofreadHTML(item) {
1610
  const sourceDownload = sourceDownloadURL(item, defaultFile);
1611
  const sourceViewer = sourceFiles.length
1612
  ? (isImageSource(selectedUrl)
1613
- ? `<div class="proofread-image-viewer" data-image-viewer><div class="proofread-image-tools"><button type="button" class="text-btn-sm" data-image-zoom="out">缩小</button><button type="button" class="text-btn-sm" data-image-zoom="reset">原始大小</button><button type="button" class="text-btn-sm" data-image-zoom="in">放大</button></div><div class="proofread-image-stage"><img data-proofread-source-image src="${sourceURL}" alt="原文件" data-image-scale="1"><a class="text-btn-sm proofread-image-download" href="${sourceDownload}">下载原文件</a></div></div>`
1614
  : `<iframe sandbox data-proofread-source title="原文件" src="${sourceURL}${pdfPage}"></iframe>`)
1615
  : '<div class="proofread-no-source"><strong>没有原文件,无法校对</strong><span>当前只能查看正文。</span></div>';
1616
  const partTypeOptions = (current) => PART_TYPES.map((type) => `<option value="${type}" ${type === current ? "selected" : ""}>${type}</option>`).join("");
@@ -1639,10 +1639,16 @@ function openProofread(item, focusPart = null, restoring = false) {
1639
  const fitImage = () => {
1640
  const stage = sourceImage.closest(".proofread-image-stage");
1641
  if (!stage || !sourceImage.naturalWidth) return;
1642
- const baseWidth = Math.min(sourceImage.naturalWidth, Math.max(1, stage.clientWidth - 32));
 
 
 
 
 
1643
  sourceImage.dataset.imageBaseWidth = String(baseWidth);
1644
  sourceImage.style.maxWidth = "none";
1645
  sourceImage.style.width = `${baseWidth}px`;
 
1646
  };
1647
  sourceImage.addEventListener("load", fitImage, { once: true });
1648
  if (sourceImage.complete) fitImage();
@@ -2259,6 +2265,7 @@ function attachEvents() {
2259
  const baseWidth = Number(image.dataset.imageBaseWidth) || image.naturalWidth;
2260
  image.style.maxWidth = "none";
2261
  image.style.width = `${Math.max(1, baseWidth * next)}px`;
 
2262
  image.style.transform = "none";
2263
  return;
2264
  }
 
1610
  const sourceDownload = sourceDownloadURL(item, defaultFile);
1611
  const sourceViewer = sourceFiles.length
1612
  ? (isImageSource(selectedUrl)
1613
+ ? `<div class="proofread-image-viewer" data-image-viewer><div class="proofread-image-tools"><button type="button" class="text-btn-sm" data-image-zoom="out">缩小</button><button type="button" class="text-btn-sm" data-image-zoom="reset">原始大小</button><button type="button" class="text-btn-sm" data-image-zoom="in">放大</button></div><div class="proofread-image-stage"><img data-proofread-source-image src="${sourceURL}" alt="原文件" decoding="async" data-image-scale="1"><a class="text-btn-sm proofread-image-download" href="${sourceDownload}">下载原文件</a></div></div>`
1614
  : `<iframe sandbox data-proofread-source title="原文件" src="${sourceURL}${pdfPage}"></iframe>`)
1615
  : '<div class="proofread-no-source"><strong>没有原文件,无法校对</strong><span>当前只能查看正文。</span></div>';
1616
  const partTypeOptions = (current) => PART_TYPES.map((type) => `<option value="${type}" ${type === current ? "selected" : ""}>${type}</option>`).join("");
 
1639
  const fitImage = () => {
1640
  const stage = sourceImage.closest(".proofread-image-stage");
1641
  if (!stage || !sourceImage.naturalWidth) return;
1642
+ const availableWidth = Math.max(1, stage.clientWidth - 32);
1643
+ const availableHeight = Math.max(1, stage.clientHeight - 32);
1644
+ const fitScale = STATE.isMobile
1645
+ ? Math.min(availableWidth / sourceImage.naturalWidth, availableHeight / sourceImage.naturalHeight, 1)
1646
+ : Math.min(availableWidth / sourceImage.naturalWidth, 1);
1647
+ const baseWidth = Math.max(1, Math.round(sourceImage.naturalWidth * fitScale));
1648
  sourceImage.dataset.imageBaseWidth = String(baseWidth);
1649
  sourceImage.style.maxWidth = "none";
1650
  sourceImage.style.width = `${baseWidth}px`;
1651
+ sourceImage.style.height = "auto";
1652
  };
1653
  sourceImage.addEventListener("load", fitImage, { once: true });
1654
  if (sourceImage.complete) fitImage();
 
2265
  const baseWidth = Number(image.dataset.imageBaseWidth) || image.naturalWidth;
2266
  image.style.maxWidth = "none";
2267
  image.style.width = `${Math.max(1, baseWidth * next)}px`;
2268
+ image.style.height = "auto";
2269
  image.style.transform = "none";
2270
  return;
2271
  }
static/style.css CHANGED
@@ -619,6 +619,7 @@ ul, li {
619
  display: flex;
620
  min-height: 520px;
621
  flex: 1;
 
622
  align-items: flex-start;
623
  justify-content: flex-start;
624
  overflow: auto;
@@ -628,6 +629,7 @@ ul, li {
628
  .proofread-image-stage img {
629
  display: block;
630
  flex: 0 0 auto;
 
631
  max-width: 100%;
632
  height: auto;
633
  transform-origin: top left;
 
619
  display: flex;
620
  min-height: 520px;
621
  flex: 1;
622
+ display: block;
623
  align-items: flex-start;
624
  justify-content: flex-start;
625
  overflow: auto;
 
629
  .proofread-image-stage img {
630
  display: block;
631
  flex: 0 0 auto;
632
+ margin: 0;
633
  max-width: 100%;
634
  height: auto;
635
  transform-origin: top left;