askbot-dragon 1.6.75 → 1.6.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askbot-dragon",
3
- "version": "1.6.75",
3
+ "version": "1.6.76",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -281,7 +281,8 @@ export default {
281
281
 
282
282
  const page = await this.pdf.getPage(pageNumber);
283
283
  let pdfWidth = page.getViewport({ scale: 1 }).width;
284
- const viewport = page.getViewport({ scale: this.calculateScale(pdfWidth) });
284
+ const displayScale = this.calculateScale(pdfWidth);
285
+ const viewport = page.getViewport({ scale: displayScale });
285
286
  this.viewport = viewport;
286
287
 
287
288
  const canvas = pageData.canvas;
@@ -301,7 +302,7 @@ export default {
301
302
  this.context = context;
302
303
 
303
304
  // 计算输出缩放比例(与 vuePdf 保持一致)
304
- const outputScale = this.calculateScale(pdfWidth);
305
+ const outputScale = this.getOutputScale();
305
306
 
306
307
  // 计算实际显示的尺寸
307
308
  let domWidth = Math.floor(viewport.width);
@@ -315,7 +316,7 @@ export default {
315
316
  canvas.style.height = `${domHeight}px`;
316
317
 
317
318
  // 创建 transform 矩阵(与 vuePdf 保持一致)
318
- const transform = outputScale !== 1
319
+ let transform = outputScale !== 1
319
320
  ? [outputScale, 0, 0, outputScale, 0, 0]
320
321
  : null;
321
322
 
@@ -332,6 +333,7 @@ export default {
332
333
  transform: transform
333
334
  });
334
335
  await renderTask.promise;
336
+ transform = null;
335
337
 
336
338
  // 渲染文本层(必须在高亮渲染之前,确保文本层在最上层)
337
339
  try {
@@ -416,9 +418,15 @@ export default {
416
418
  }
417
419
  },
418
420
  calculateScale(pdfWidth) {
419
- const containerWidth = document.getElementById('pdfViewPage').clientWidth - 50;
421
+ const pdfViewPage = document.getElementById('pdfViewPage');
422
+ if (!pdfViewPage || !pdfWidth) return this.scale;
423
+ const horizontalPadding = this.isPC ? 50 : 16;
424
+ const containerWidth = Math.max(pdfViewPage.clientWidth - horizontalPadding, 1);
420
425
  return (containerWidth / pdfWidth) * this.scale;
421
426
  },
427
+ getOutputScale() {
428
+ return Math.min(window.devicePixelRatio || 1, 2);
429
+ },
422
430
  async renderHighlights(context, number, viewport, outputScale = 1) {
423
431
  const pageHighlights = this.highlights.filter(item => (item.page === number ))
424
432
  let highlights = this.mergedGroups(pageHighlights);