fix(data-process): 优化预览分页与PDF兼容
This commit is contained in:
@@ -129,7 +129,7 @@ assert.match(previewSource, /sourceEnd/, '第四步未使用来源结束偏移')
|
|||||||
assert.match(previewSource, /filterable/, '文件选择器必须可搜索')
|
assert.match(previewSource, /filterable/, '文件选择器必须可搜索')
|
||||||
assert.match(previewSource, /当前文件/, '预览缺少当前文件切换器')
|
assert.match(previewSource, /当前文件/, '预览缺少当前文件切换器')
|
||||||
assert.doesNotMatch(previewSource, /located-badge|sync-label|已定位到/, '源文件栏不应显示冗余定位提示')
|
assert.doesNotMatch(previewSource, /located-badge|sync-label|已定位到/, '源文件栏不应显示冗余定位提示')
|
||||||
assert.match(previewSource, /const PREVIEW_PAGE_SIZE = 6/, '切片列表必须限制每页展示数量')
|
assert.match(previewSource, /const PREVIEW_PAGE_SIZE = 10/, '切片列表每页应展示 10 条')
|
||||||
assert.match(previewSource, /const pagedItems = computed/, '切片列表缺少分页数据')
|
assert.match(previewSource, /const pagedItems = computed/, '切片列表缺少分页数据')
|
||||||
assert.match(previewSource, /v-for="item in pagedItems"/, '切片列表没有使用分页数据')
|
assert.match(previewSource, /v-for="item in pagedItems"/, '切片列表没有使用分页数据')
|
||||||
assert.match(previewSource, /<el-pagination[\s\S]*:page-size="PREVIEW_PAGE_SIZE"/, '切片列表缺少分页控件')
|
assert.match(previewSource, /<el-pagination[\s\S]*:page-size="PREVIEW_PAGE_SIZE"/, '切片列表缺少分页控件')
|
||||||
@@ -159,6 +159,8 @@ assert.match(pdfViewerSource, /getDataProcessSourceRawUrl/, 'PDF 查看组件没
|
|||||||
assert.match(pdfViewerSource, /getDataProcessPdfPages/, 'PDF 查看组件没有读取页码与全文偏移映射')
|
assert.match(pdfViewerSource, /getDataProcessPdfPages/, 'PDF 查看组件没有读取页码与全文偏移映射')
|
||||||
assert.match(pdfViewerSource, /pdfjs-dist/, 'PDF 查看组件没有使用可控的 PDF.js 渲染器')
|
assert.match(pdfViewerSource, /pdfjs-dist/, 'PDF 查看组件没有使用可控的 PDF.js 渲染器')
|
||||||
assert.match(pdfViewerSource, /TextLayer/, 'PDF 查看组件没有渲染可定位的 PDF 文字层')
|
assert.match(pdfViewerSource, /TextLayer/, 'PDF 查看组件没有渲染可定位的 PDF 文字层')
|
||||||
|
assert.match(pdfViewerSource, /page\.streamTextContent\(\)/, 'PDF 文字层没有使用兼容 WebKit 的流式读取方式')
|
||||||
|
assert.doesNotMatch(pdfViewerSource, /page\.getTextContent\(\)/, 'PDF 文字层仍依赖 WebKit 不完整支持的 ReadableStream 异步迭代')
|
||||||
assert.match(pdfViewerSource, /is-slice-highlighted/, 'PDF 查看组件没有实现选中切片高亮')
|
assert.match(pdfViewerSource, /is-slice-highlighted/, 'PDF 查看组件没有实现选中切片高亮')
|
||||||
assert.match(pdfViewerSource, /:data-page-number="currentPage"/, 'PDF 查看组件缺少当前物理页标识')
|
assert.match(pdfViewerSource, /:data-page-number="currentPage"/, 'PDF 查看组件缺少当前物理页标识')
|
||||||
assert.doesNotMatch(pdfViewerSource, /<iframe/, 'PDF 查看组件不应继续使用无法控制高亮的浏览器 iframe')
|
assert.doesNotMatch(pdfViewerSource, /<iframe/, 'PDF 查看组件不应继续使用无法控制高亮的浏览器 iframe')
|
||||||
|
|||||||
@@ -220,10 +220,12 @@ async function renderCurrentPage(force = false) {
|
|||||||
) return
|
) return
|
||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
const textContent = await page.getTextContent()
|
// WebKit 兼容:PDF.js 的 getTextContent() 依赖 ReadableStream 异步迭代,
|
||||||
|
// 部分 Safari/WKWebView 未实现该接口。TextLayer 可直接通过 getReader() 消费文本流。
|
||||||
|
const textContentSource = page.streamTextContent()
|
||||||
if (sequence !== renderSequence) return
|
if (sequence !== renderSequence) return
|
||||||
const activeTextLayer = new TextLayer({
|
const activeTextLayer = new TextLayer({
|
||||||
textContentSource: textContent,
|
textContentSource,
|
||||||
container: layerContainer,
|
container: layerContainer,
|
||||||
viewport,
|
viewport,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const emit = defineEmits<{
|
|||||||
const sourceViewerRef = ref<HTMLElement | null>(null)
|
const sourceViewerRef = ref<HTMLElement | null>(null)
|
||||||
const search = ref('')
|
const search = ref('')
|
||||||
const currentPage = ref(1)
|
const currentPage = ref(1)
|
||||||
const PREVIEW_PAGE_SIZE = 6
|
const PREVIEW_PAGE_SIZE = 10
|
||||||
const editingItemId = ref<string | null>(null)
|
const editingItemId = ref<string | null>(null)
|
||||||
const editorDraft = ref('')
|
const editorDraft = ref('')
|
||||||
const lines = computed(() => sourceLines(props.sourceText))
|
const lines = computed(() => sourceLines(props.sourceText))
|
||||||
|
|||||||
Reference in New Issue
Block a user