vue3-components-plus 3.0.30 → 3.0.33

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.
@@ -3,14 +3,6 @@
3
3
  <div class="control-panel">
4
4
  <h3>PDF 文档预览演示</h3>
5
5
 
6
- <!-- 本地PDF文件 -->
7
- <div class="local-section">
8
- <h4>本地PDF文件</h4>
9
- <span class="file-name">驿云通 (11).pdf</span>
10
- <button @click="loadLocalPdf">加载本地文件</button>
11
- <button @click="printPdf" :disabled="!currentUrl">打印</button>
12
- </div>
13
-
14
6
  <!-- 文件上传方式 -->
15
7
  <div class="upload-section">
16
8
  <h4>方式一:文件上传</h4>
@@ -62,31 +54,23 @@
62
54
 
63
55
  <script setup lang="ts">
64
56
  import { ref, nextTick } from 'vue'
65
- import localPdfUrl from '@/assets/驿云通 (11).pdf'
66
57
 
67
58
  const counts = ref(true)
68
59
  const file = ref()
69
60
  const pdfRef = ref()
70
- const pdfUrl = ref('')
71
- const currentUrl = ref('')
61
+ const pdfUrl = ref(
62
+ 'https://501351981.github.io/vue-office/examples/dist/static/test-files/test.pdf',
63
+ )
64
+ const currentUrl = ref(pdfUrl.value)
72
65
  const searchKeyword = ref('')
73
66
 
74
- function loadLocalPdf() {
75
- pdfUrl.value = ''
76
- file.value = null
77
- currentUrl.value = localPdfUrl
78
- }
79
-
80
- function printPdf() {
81
- if (!currentUrl.value) return
82
- window.print()
83
- }
84
-
85
67
  function importPdf(f: any) {
68
+ // 清除URL,使用文件上传
86
69
  pdfUrl.value = ''
87
70
  file.value = f
88
71
 
89
72
  if (f && f.name.endsWith('.pdf')) {
73
+ // 创建文件URL
90
74
  const fileUrl = URL.createObjectURL(f)
91
75
  currentUrl.value = fileUrl
92
76
  } else if (f) {
@@ -97,6 +81,7 @@ function importPdf(f: any) {
97
81
 
98
82
  function loadFromUrl() {
99
83
  if (pdfUrl.value.trim()) {
84
+ // 清除文件,使用URL
100
85
  clearFile()
101
86
  currentUrl.value = pdfUrl.value.trim()
102
87
  }
@@ -121,6 +106,7 @@ function clickPdf() {
121
106
  }
122
107
  }
123
108
 
109
+ // 重新加载组件
124
110
  function reloadComponent() {
125
111
  counts.value = false
126
112
  nextTick(() => {
@@ -154,7 +140,6 @@ function reloadComponent() {
154
140
  }
155
141
  }
156
142
 
157
- .local-section,
158
143
  .upload-section,
159
144
  .url-section,
160
145
  .search-section {
@@ -219,16 +204,4 @@ function reloadComponent() {
219
204
  margin-bottom: 10px;
220
205
  }
221
206
  }
222
-
223
- @media print {
224
- .control-panel {
225
- display: none !important;
226
- }
227
-
228
- .pdf-container {
229
- height: auto !important;
230
- border: none !important;
231
- overflow: visible !important;
232
- }
233
- }
234
207
  </style>