@koi-br/ocr-web-sdk 1.0.25 → 1.0.26
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/dist/{index-B4GG8QkF.js → index-BHtQ-val.js} +86 -89
- package/dist/{index-BDV45uQO.mjs → index-CqSyQjJ2.mjs} +10537 -10202
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/{tiff.min-0h4Fdea0.js → tiff.min-D0RfnjXu.js} +1 -1
- package/dist/{tiff.min-CSPHYlVM.mjs → tiff.min-q16GulNm.mjs} +1 -1
- package/package.json +1 -1
- package/preview/ImagePreview.vue +1222 -280
- package/preview/index.vue +43 -3
package/preview/index.vue
CHANGED
|
@@ -42,13 +42,17 @@
|
|
|
42
42
|
<ImagePreview
|
|
43
43
|
v-else-if="fileType === 'image'"
|
|
44
44
|
ref="imagePreviewRef"
|
|
45
|
-
:url="
|
|
45
|
+
:url="imagePreviewUrl"
|
|
46
46
|
:original-id="originalId"
|
|
47
47
|
:is-download="props.isDownload"
|
|
48
48
|
v-bind="props.imageProps || {}"
|
|
49
49
|
@original="handleOriginal"
|
|
50
50
|
@download="handleDownload"
|
|
51
51
|
@load="handleFileLoaded"
|
|
52
|
+
@page-change="handleImagePageChange"
|
|
53
|
+
@annotation-add="handleAnnotationAdd"
|
|
54
|
+
@annotation-update="handleAnnotationUpdate"
|
|
55
|
+
@annotation-delete="handleAnnotationDelete"
|
|
52
56
|
>
|
|
53
57
|
<template #left-top>
|
|
54
58
|
<slot name="left-top"></slot>
|
|
@@ -127,7 +131,7 @@
|
|
|
127
131
|
</template>
|
|
128
132
|
|
|
129
133
|
<script setup>
|
|
130
|
-
import { ref, onBeforeUnmount } from 'vue';
|
|
134
|
+
import { ref, onBeforeUnmount, computed } from 'vue';
|
|
131
135
|
import { Message, Button as AButton } from '@arco-design/web-vue';
|
|
132
136
|
import ImagePreview from './ImagePreview.vue';
|
|
133
137
|
import PdfPreview from './PdfPreview.vue';
|
|
@@ -137,7 +141,7 @@ import DocxPreview from './docxPreview.vue';
|
|
|
137
141
|
import XLSXPreview from './xlsxPreview.vue';
|
|
138
142
|
|
|
139
143
|
// 定义 emits
|
|
140
|
-
const emit = defineEmits(['load']);
|
|
144
|
+
const emit = defineEmits(['load', 'annotation-add', 'annotation-update', 'annotation-delete']);
|
|
141
145
|
|
|
142
146
|
// 定义 props
|
|
143
147
|
const props = defineProps({
|
|
@@ -193,6 +197,21 @@ const xlsxPreviewRef = ref(null);
|
|
|
193
197
|
|
|
194
198
|
const originalId = ref('');
|
|
195
199
|
|
|
200
|
+
// 计算图片预览的URL(支持单个URL或URL数组)
|
|
201
|
+
const imagePreviewUrl = computed(() => {
|
|
202
|
+
// 如果imageProps中指定了url或urls,优先使用
|
|
203
|
+
if (props.imageProps) {
|
|
204
|
+
if (Array.isArray(props.imageProps.urls)) {
|
|
205
|
+
return props.imageProps.urls;
|
|
206
|
+
}
|
|
207
|
+
if (typeof props.imageProps.url === 'string' || Array.isArray(props.imageProps.url)) {
|
|
208
|
+
return props.imageProps.url;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// 否则使用fileUrl(向后兼容)
|
|
212
|
+
return fileUrl.value;
|
|
213
|
+
});
|
|
214
|
+
|
|
196
215
|
// 添加 AbortController 的引用
|
|
197
216
|
const abortController = ref(null);
|
|
198
217
|
|
|
@@ -394,6 +413,27 @@ const handleFileLoaded = (data) => {
|
|
|
394
413
|
emit('load', fileInfo);
|
|
395
414
|
};
|
|
396
415
|
|
|
416
|
+
// 处理图片页码变化事件
|
|
417
|
+
const handleImagePageChange = (page, totalPages) => {
|
|
418
|
+
// 可以在这里处理页码变化,例如更新文件名显示等
|
|
419
|
+
console.log(`图片页码变化: ${page}/${totalPages}`);
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
// 处理批注添加事件
|
|
423
|
+
const handleAnnotationAdd = (annotation) => {
|
|
424
|
+
emit('annotation-add', annotation);
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
// 处理批注更新事件
|
|
428
|
+
const handleAnnotationUpdate = (annotation) => {
|
|
429
|
+
emit('annotation-update', annotation);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
// 处理批注删除事件
|
|
433
|
+
const handleAnnotationDelete = (annotationId) => {
|
|
434
|
+
emit('annotation-delete', annotationId);
|
|
435
|
+
};
|
|
436
|
+
|
|
397
437
|
// 获取当前活动的预览组件引用
|
|
398
438
|
const getCurrentPreviewRef = () => {
|
|
399
439
|
switch (fileType.value) {
|