vome-core 0.0.48 → 0.0.49

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.
@@ -70,21 +70,12 @@
70
70
  </div>
71
71
  <div class="vm-file-preview-viewer__actions">
72
72
  <button
73
- v-if="useDownloadAction"
74
- type="button"
75
- class="vm-file-preview-viewer__link"
76
- :disabled="downloading"
77
- @click="downloadFile"
78
- >
79
- {{ downloading ? '下载中…' : '下载' }}
80
- </button>
81
- <button
82
- v-else
83
73
  type="button"
84
74
  class="vm-file-preview-viewer__link"
75
+ :disabled="opening"
85
76
  @click="openInNewWindow"
86
77
  >
87
- 新窗口打开
78
+ {{ opening ? '打开中…' : '新窗口打开' }}
88
79
  </button>
89
80
  <button type="button" class="vm-file-preview-viewer__close" title="关闭" @click="closeViewer">
90
81
  <i class="ri-close-line" />
@@ -170,9 +161,14 @@
170
161
  <div v-else-if="kind === 'office'" class="vm-file-preview-viewer__fallback">
171
162
  <i class="ri-file-3-line" aria-hidden="true" />
172
163
  <p>Word / PPT 等 Office 文档暂不支持浏览器内预览。</p>
173
- <p>请点击上方「下载」后使用本地 Office / WPS 查看。</p>
174
- <button type="button" class="vm-file-preview-viewer__dl-btn" @click="downloadFile">
175
- 下载文件
164
+ <p>请点击下方按钮下载后使用本地 Office / WPS 查看。</p>
165
+ <button
166
+ type="button"
167
+ class="vm-file-preview-viewer__dl-btn"
168
+ :disabled="downloading"
169
+ @click="downloadFile"
170
+ >
171
+ {{ downloading ? '下载中…' : '下载文件' }}
176
172
  </button>
177
173
  </div>
178
174
 
@@ -180,8 +176,13 @@
180
176
  <i class="ri-file-3-line" aria-hidden="true" />
181
177
  <p>该文件类型暂不支持在线预览。</p>
182
178
  <p>请点击下方按钮下载查看(如 .vome 插件包)。</p>
183
- <button type="button" class="vm-file-preview-viewer__dl-btn" @click="downloadFile">
184
- 下载文件
179
+ <button
180
+ type="button"
181
+ class="vm-file-preview-viewer__dl-btn"
182
+ :disabled="downloading"
183
+ @click="downloadFile"
184
+ >
185
+ {{ downloading ? '下载中…' : '下载文件' }}
185
186
  </button>
186
187
  </div>
187
188
  </div>
@@ -259,6 +260,7 @@ const emit = defineEmits<{ 'update:open': [v: boolean] }>()
259
260
  const internalOpen = ref(false)
260
261
  const loading = ref(false)
261
262
  const downloading = ref(false)
263
+ const opening = ref(false)
262
264
  const error = ref('')
263
265
  const textContent = ref('')
264
266
  const excelHtml = ref('')
@@ -335,10 +337,7 @@ const displayName = computed(() =>
335
337
  fileDisplayName(props.fileName || src.value, '未命名文件'),
336
338
  )
337
339
 
338
- /** 无法内嵌预览的类型:只提供下载,避免「新窗口打开」崩掉(如 .vome) */
339
- const useDownloadAction = computed(
340
- () => kind.value === 'unsupported' || kind.value === 'office',
341
- )
340
+ /** 无法内嵌预览的类型在正文区提供「下载文件」;顶栏统一「新窗口打开」 */
342
341
 
343
342
  async function downloadFile() {
344
343
  if (downloading.value) return
@@ -364,10 +363,22 @@ async function downloadFile() {
364
363
  }
365
364
  }
366
365
 
367
- function openInNewWindow() {
368
- const url = src.value
369
- if (!url) return
370
- window.open(url, '_blank', 'noopener,noreferrer')
366
+ async function openInNewWindow() {
367
+ if (opening.value) return
368
+ const raw = src.value
369
+ if (!raw) return
370
+ opening.value = true
371
+ try {
372
+ let url = raw
373
+ if (props.resolveDownloadUrl) {
374
+ const signed = await props.resolveDownloadUrl(raw)
375
+ if (!signed) return
376
+ url = signed
377
+ }
378
+ window.open(url, '_blank', 'noopener,noreferrer')
379
+ } finally {
380
+ opening.value = false
381
+ }
371
382
  }
372
383
 
373
384
  const viewerOpen = computed({
package/dist/index.js CHANGED
@@ -27856,7 +27856,7 @@ init_excel();
27856
27856
  // package.json
27857
27857
  var package_default = {
27858
27858
  name: "vome-core",
27859
- version: "0.0.48",
27859
+ version: "0.0.49",
27860
27860
  description: "Vome framework \u2014 shared + Bun/Elysia server + Vue admin",
27861
27861
  license: "MIT",
27862
27862
  type: "module",
@@ -31168,7 +31168,7 @@ init_excel();
31168
31168
  // package.json
31169
31169
  var package_default = {
31170
31170
  name: "vome-core",
31171
- version: "0.0.48",
31171
+ version: "0.0.49",
31172
31172
  description: "Vome framework \u2014 shared + Bun/Elysia server + Vue admin",
31173
31173
  license: "MIT",
31174
31174
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vome-core",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "description": "Vome framework — shared + Bun/Elysia server + Vue admin",
5
5
  "license": "MIT",
6
6
  "type": "module",