@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/README.md +2 -0
- package/dist/index-C62sS5ip.js +215 -0
- package/dist/index-CTfcg7Et.mjs +44928 -0
- package/dist/index.cjs.js +2 -202
- package/dist/index.esm.js +11 -44802
- package/dist/preview/PdfPreview.vue.d.ts +10 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/tiff.min-Cj_Bc5eL.mjs +195485 -0
- package/dist/tiff.min-RanW0yRi.js +6 -0
- package/package.json +2 -1
- package/preview/ImagePreview.vue +4 -1
- package/preview/PdfPreview.vue +25 -0
- package/preview/docxPreview.vue +7 -2
- package/preview/index.vue +28 -6
- package/preview/ofdPreview.vue +0 -18
- package/preview/tifPreview.vue +452 -363
- package/preview/xlsxPreview.vue +171 -168
package/preview/xlsxPreview.vue
CHANGED
|
@@ -1,168 +1,171 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="preview-container">
|
|
3
|
-
<!-- 工具栏 -->
|
|
4
|
-
<div class="preview-toolbar preview-toolbar-
|
|
5
|
-
<div class="toolbar-group">
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import
|
|
75
|
-
import '@
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="preview-container">
|
|
3
|
+
<!-- 工具栏 -->
|
|
4
|
+
<div class="preview-toolbar preview-toolbar-between">
|
|
5
|
+
<div class="toolbar-group">
|
|
6
|
+
<slot name="left-top"></slot>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="toolbar-group">
|
|
9
|
+
<span class="scale-text">
|
|
10
|
+
{{ Math.round(scale * 100) }}%
|
|
11
|
+
</span>
|
|
12
|
+
<div class="toolbar-divider"></div>
|
|
13
|
+
<ATooltip mini position="bottom" content="重置">
|
|
14
|
+
<AButton
|
|
15
|
+
size="small"
|
|
16
|
+
type="outline"
|
|
17
|
+
@click="reset"
|
|
18
|
+
>
|
|
19
|
+
<RefreshCcw :size="16" />
|
|
20
|
+
</AButton>
|
|
21
|
+
</ATooltip>
|
|
22
|
+
<ATooltip mini position="bottom" content="缩小">
|
|
23
|
+
<AButton
|
|
24
|
+
size="small"
|
|
25
|
+
type="outline"
|
|
26
|
+
:disabled="scale <= 0.5"
|
|
27
|
+
@click="zoom(-0.1)"
|
|
28
|
+
>
|
|
29
|
+
<ZoomOut :size="16" />
|
|
30
|
+
</AButton>
|
|
31
|
+
</ATooltip>
|
|
32
|
+
<ATooltip mini position="bottom" content="放大">
|
|
33
|
+
<AButton
|
|
34
|
+
size="small"
|
|
35
|
+
type="outline"
|
|
36
|
+
:disabled="scale >= 2"
|
|
37
|
+
@click="zoom(0.1)"
|
|
38
|
+
>
|
|
39
|
+
<ZoomIn :size="16" />
|
|
40
|
+
</AButton>
|
|
41
|
+
</ATooltip>
|
|
42
|
+
<ATooltip
|
|
43
|
+
v-if="isDownload"
|
|
44
|
+
mini
|
|
45
|
+
position="bottom"
|
|
46
|
+
content="下载"
|
|
47
|
+
>
|
|
48
|
+
<AButton
|
|
49
|
+
size="small"
|
|
50
|
+
type="outline"
|
|
51
|
+
@click="emit('download')"
|
|
52
|
+
>
|
|
53
|
+
<Download :size="16" />
|
|
54
|
+
</AButton>
|
|
55
|
+
</ATooltip>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<div
|
|
59
|
+
class="excel-wrapper"
|
|
60
|
+
:style="{ transform: `scale(${scale})`, transformOrigin: 'top left' }"
|
|
61
|
+
>
|
|
62
|
+
<VueOfficeExcel
|
|
63
|
+
v-if="excel"
|
|
64
|
+
:src="excel"
|
|
65
|
+
style="width: 100%; height: 75vh"
|
|
66
|
+
@rendered="onRendered"
|
|
67
|
+
@error="onError"
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<script setup>
|
|
74
|
+
import { ref, watch } from 'vue';
|
|
75
|
+
import { Message, Button as AButton, Tooltip as ATooltip } from '@arco-design/web-vue';
|
|
76
|
+
import { ZoomIn, ZoomOut, RefreshCcw, Download } from 'lucide-vue-next';
|
|
77
|
+
import VueOfficeExcel from '@vue-office/excel/lib/v3/index';
|
|
78
|
+
import '@vue-office/excel/lib/v3/index.css';
|
|
79
|
+
|
|
80
|
+
const props = defineProps({
|
|
81
|
+
url: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: true
|
|
84
|
+
},
|
|
85
|
+
isDownload: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const emit = defineEmits(['download']);
|
|
92
|
+
|
|
93
|
+
const excel = ref('');
|
|
94
|
+
const loading = ref(false);
|
|
95
|
+
const scale = ref(1);
|
|
96
|
+
|
|
97
|
+
// 缩放方法
|
|
98
|
+
const zoom = delta => {
|
|
99
|
+
const newScale = scale.value + delta;
|
|
100
|
+
if (newScale >= 0.5 && newScale <= 2) {
|
|
101
|
+
scale.value = newScale;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// 重置方法
|
|
106
|
+
const reset = () => {
|
|
107
|
+
scale.value = 1;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// 放大
|
|
111
|
+
const zoomIn = () => {
|
|
112
|
+
zoom(0.1);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// 缩小
|
|
116
|
+
const zoomOut = () => {
|
|
117
|
+
zoom(-0.1);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// 重置缩放
|
|
121
|
+
const resetZoom = () => {
|
|
122
|
+
reset();
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// 文件加载成功
|
|
126
|
+
const onRendered = () => {
|
|
127
|
+
loading.value = false;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// 文件加载失败
|
|
131
|
+
const onError = error => {
|
|
132
|
+
loading.value = false;
|
|
133
|
+
Message.error('Excel文件加载失败');
|
|
134
|
+
console.error('Excel文件加载失败:', error);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// 监听URL变化
|
|
138
|
+
watch(
|
|
139
|
+
() => props.url,
|
|
140
|
+
newUrl => {
|
|
141
|
+
if (newUrl) {
|
|
142
|
+
loading.value = true;
|
|
143
|
+
excel.value = newUrl;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{ immediate: true }
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
// 清理函数
|
|
150
|
+
const cleanup = () => {
|
|
151
|
+
loading.value = false;
|
|
152
|
+
excel.value = '';
|
|
153
|
+
scale.value = 1;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// 暴露清理方法给父组件
|
|
157
|
+
defineExpose({
|
|
158
|
+
cleanup
|
|
159
|
+
});
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<style lang="less" scoped>
|
|
163
|
+
// 样式已统一到公共样式文件,这里只保留组件特定样式
|
|
164
|
+
.excel-wrapper {
|
|
165
|
+
flex: 1;
|
|
166
|
+
display: inline-block;
|
|
167
|
+
min-width: 100%;
|
|
168
|
+
overflow: auto;
|
|
169
|
+
transition: transform 0.2s ease;
|
|
170
|
+
}
|
|
171
|
+
</style>
|