@koi-br/ocr-web-sdk 1.0.23 → 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.
@@ -1,7 +1,10 @@
1
1
  <template>
2
2
  <div class="preview-container">
3
3
  <!-- 工具栏 -->
4
- <div class="preview-toolbar preview-toolbar-between">
4
+ <div
5
+ class="preview-toolbar preview-toolbar-between"
6
+ :class="props.toolbarClass"
7
+ >
5
8
  <!-- 左侧: 翻页控制 -->
6
9
  <div class="toolbar-group">
7
10
  <!-- 左上角自定义按钮插槽 -->
@@ -362,6 +365,7 @@ interface Props {
362
365
  showTocSidebar?: boolean; // 是否显示目录侧边栏(包括工具栏中的切换按钮),默认为 true
363
366
  isDownload?: boolean; // 是否显示下载按钮,默认为 false
364
367
  enableMargin?: boolean; // 是否启用留白(自动缩放和适合页宽模式下),true=留白(左右各20px,共40px),false=不留白(只有左右5px padding),默认为 true
368
+ toolbarClass?: string; // 工具栏的自定义类名,用于自定义样式(包括深度选择器样式)
365
369
  }
366
370
 
367
371
  // 使用 withDefaults 显式设置默认值,确保未传递 prop 时使用默认值
@@ -2193,6 +2197,7 @@ onBeforeUnmount(() => {
2193
2197
 
2194
2198
  // 工具栏样式已统一到公共样式文件,使用 .preview-toolbar .preview-toolbar-between
2195
2199
  // PDF 特有的页码信息样式(在工具栏内)
2200
+
2196
2201
  .preview-toolbar {
2197
2202
  .page-info {
2198
2203
  display: flex;
@@ -2223,6 +2228,16 @@ onBeforeUnmount(() => {
2223
2228
  }
2224
2229
  }
2225
2230
 
2231
+ .custom-toolbar {
2232
+ :deep(.arco-btn-outline) {
2233
+ background: transparent !important;
2234
+ }
2235
+ padding: 1px 5px;
2236
+ background: #f7f7f7;
2237
+ border-color:#cbcbcb;
2238
+ }
2239
+
2240
+
2226
2241
  // PDF 内容区域
2227
2242
  .pdf-content {
2228
2243
  position: relative;
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="fileUrl"
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) {