@koi-br/ocr-web-sdk 1.0.14 → 1.0.16

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": "@koi-br/ocr-web-sdk",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "一个支持多种Office文件格式预览的Vue3组件SDK,包括PDF、Word、Excel、图片、OFD、TIF等格式",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -46,6 +46,7 @@
46
46
  "docx-preview": "^0.1.12",
47
47
  "lucide-vue-next": "^0.344.0",
48
48
  "pdfjs-dist": "^3.11.174",
49
+ "tiff.js": "^1.0.0",
49
50
  "vue": "^3.0.0"
50
51
  },
51
52
  "devDependencies": {
@@ -4,7 +4,10 @@
4
4
  @wheel.prevent="handleWheel"
5
5
  >
6
6
  <!-- 工具栏 -->
7
- <div class="preview-toolbar preview-toolbar-right">
7
+ <div class="preview-toolbar preview-toolbar-between">
8
+ <div class="toolbar-group">
9
+ <slot name="left-top"></slot>
10
+ </div>
8
11
  <div class="toolbar-group">
9
12
  <span class="scale-text">
10
13
  {{ Math.round(scale * 100) }}%
@@ -4,6 +4,9 @@
4
4
  <div class="preview-toolbar preview-toolbar-between">
5
5
  <!-- 左侧: 翻页控制 -->
6
6
  <div class="toolbar-group">
7
+ <!-- 左上角自定义按钮插槽 -->
8
+ <slot name="left-top"></slot>
9
+
7
10
  <!-- 目录和印章列表切换按钮 -->
8
11
  <ATooltip
9
12
  v-if="props.showTocSidebar !== false"
@@ -2420,6 +2423,20 @@ onBeforeUnmount(() => {
2420
2423
 
2421
2424
  &.toc-sidebar-show {
2422
2425
  width: 180px;
2426
+
2427
+ .toc-tab-switcher {
2428
+ opacity: 1; // 展开时显示Tab切换器
2429
+ visibility: visible; // 展开时可见
2430
+ pointer-events: auto; // 展开时允许交互
2431
+ transition: opacity 0.2s ease 0.4s, visibility 0s linear 0.4s; // 延迟显示,确保宽度变化完成后再显示(0.3s宽度 + 0.1s缓冲)
2432
+ }
2433
+
2434
+ .toc-sidebar-content {
2435
+ opacity: 1; // 展开时显示内容区域
2436
+ visibility: visible; // 展开时可见
2437
+ pointer-events: auto; // 展开时允许交互
2438
+ transition: opacity 0.2s ease 0.4s, visibility 0s linear 0.4s; // 延迟显示,确保宽度变化完成后再显示(0.3s宽度 + 0.1s缓冲)
2439
+ }
2423
2440
  }
2424
2441
 
2425
2442
  .toc-tab-switcher {
@@ -2434,6 +2451,10 @@ onBeforeUnmount(() => {
2434
2451
  border: 0.5px solid rgb(0 0 0 / 8%);
2435
2452
  border: 0.5px solid var(--s-color-border-tertiary, rgb(0 0 0 / 8%));
2436
2453
  border-radius: 10px;
2454
+ opacity: 0; // 默认隐藏
2455
+ visibility: hidden; // 完全隐藏,防止在宽度变化时可见
2456
+ pointer-events: none; // 收起时禁止交互,防止内容可见
2457
+ transition: opacity 0.15s ease 0s, visibility 0s linear 0s; // 收起时立即隐藏
2437
2458
 
2438
2459
  .toc-tab-item {
2439
2460
  display: flex;
@@ -2463,6 +2484,10 @@ onBeforeUnmount(() => {
2463
2484
  flex: 1;
2464
2485
  padding: 8px 0;
2465
2486
  overflow: hidden auto;
2487
+ opacity: 0; // 默认隐藏
2488
+ visibility: hidden; // 完全隐藏,防止在宽度变化时可见
2489
+ pointer-events: none; // 收起时禁止交互,防止内容可见
2490
+ transition: opacity 0.15s ease 0s, visibility 0s linear 0s; // 收起时立即隐藏
2466
2491
 
2467
2492
  // 自定义滚动条样式
2468
2493
  &::-webkit-scrollbar {
@@ -8,7 +8,10 @@
8
8
  <p class="preview-loading-title">正在加载文档...</p>
9
9
  </div>
10
10
  <!-- 工具栏 -->
11
- <div class="preview-toolbar preview-toolbar-right" v-if="isDownload">
11
+ <div class="preview-toolbar preview-toolbar-between" v-if="isDownload || slots['left-top']">
12
+ <div class="toolbar-group">
13
+ <slot name="left-top"></slot>
14
+ </div>
12
15
  <div class="toolbar-group">
13
16
  <ATooltip
14
17
  mini
@@ -33,10 +36,12 @@
33
36
 
34
37
  <script setup>
35
38
  import { renderAsync } from 'docx-preview';
36
- import { ref, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
39
+ import { ref, watch, onMounted, nextTick, useSlots } from 'vue';
37
40
  import { Download } from 'lucide-vue-next';
38
41
  import { Button as AButton, Tooltip as ATooltip, Spin as ASpin } from '@arco-design/web-vue';
39
42
 
43
+ const slots = useSlots();
44
+
40
45
  // 定义 props
41
46
  const props = defineProps({
42
47
  // 文档 URL 地址
package/preview/index.vue CHANGED
@@ -30,7 +30,12 @@
30
30
  :is-download="props.isDownload"
31
31
  v-bind="props.pdfProps || {}"
32
32
  @download="handleDownload"
33
- />
33
+ >
34
+ <!-- 透传 left-top 插槽给 PdfPreview -->
35
+ <template #left-top>
36
+ <slot name="left-top"></slot>
37
+ </template>
38
+ </PdfPreview>
34
39
 
35
40
  <!-- 图片预览 -->
36
41
  <ImagePreview
@@ -42,7 +47,11 @@
42
47
  v-bind="props.imageProps || {}"
43
48
  @original="handleOriginal"
44
49
  @download="handleDownload"
45
- />
50
+ >
51
+ <template #left-top>
52
+ <slot name="left-top"></slot>
53
+ </template>
54
+ </ImagePreview>
46
55
 
47
56
  <!-- ttf预览 -->
48
57
  <TifPreview
@@ -52,7 +61,11 @@
52
61
  :is-download="props.isDownload"
53
62
  v-bind="props.tifProps || {}"
54
63
  @download="handleDownload"
55
- />
64
+ >
65
+ <template #left-top>
66
+ <slot name="left-top"></slot>
67
+ </template>
68
+ </TifPreview>
56
69
 
57
70
  <!-- docx预览 -->
58
71
  <DocxPreview
@@ -62,7 +75,11 @@
62
75
  :is-download="props.isDownload"
63
76
  v-bind="props.docxProps || {}"
64
77
  @download="handleDownload"
65
- />
78
+ >
79
+ <template #left-top>
80
+ <slot name="left-top"></slot>
81
+ </template>
82
+ </DocxPreview>
66
83
 
67
84
  <!-- OFD预览 -->
68
85
  <OfdPreview
@@ -72,7 +89,8 @@
72
89
  :is-download="props.isDownload"
73
90
  v-bind="props.ofdProps || {}"
74
91
  @download="handleDownload"
75
- />
92
+ >
93
+ </OfdPreview>
76
94
 
77
95
  <!-- xlsx预览 -->
78
96
  <XLSXPreview
@@ -82,7 +100,11 @@
82
100
  :is-download="props.isDownload"
83
101
  v-bind="props.xlsxProps || {}"
84
102
  @download="handleDownload"
85
- />
103
+ >
104
+ <template #left-top>
105
+ <slot name="left-top"></slot>
106
+ </template>
107
+ </XLSXPreview>
86
108
 
87
109
  <!-- 不支持的文件类型 -->
88
110
  <div v-else class="preview-empty-container">
@@ -1,23 +1,5 @@
1
1
  <template>
2
2
  <div class="preview-container">
3
- <!-- 工具栏 -->
4
- <div class="preview-toolbar preview-toolbar-right" v-if="isDownload">
5
- <div class="toolbar-group">
6
- <ATooltip
7
- mini
8
- position="bottom"
9
- content="下载"
10
- >
11
- <AButton
12
- size="small"
13
- type="outline"
14
- @click="emit('download')"
15
- >
16
- <Download :size="16" />
17
- </AButton>
18
- </ATooltip>
19
- </div>
20
- </div>
21
3
  <OfdView
22
4
  :show-open-file-button="false"
23
5
  :ofd-link="props.url"