vome-core 0.0.47 → 0.0.48
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.
|
@@ -73,9 +73,10 @@
|
|
|
73
73
|
v-if="useDownloadAction"
|
|
74
74
|
type="button"
|
|
75
75
|
class="vm-file-preview-viewer__link"
|
|
76
|
+
:disabled="downloading"
|
|
76
77
|
@click="downloadFile"
|
|
77
78
|
>
|
|
78
|
-
下载
|
|
79
|
+
{{ downloading ? '下载中…' : '下载' }}
|
|
79
80
|
</button>
|
|
80
81
|
<button
|
|
81
82
|
v-else
|
|
@@ -238,6 +239,8 @@ const props = withDefaults(
|
|
|
238
239
|
radius?: number | string
|
|
239
240
|
preview?: boolean
|
|
240
241
|
fit?: 'cover' | 'contain'
|
|
242
|
+
/** 私有文件:点「下载」时先解析可访问短链 */
|
|
243
|
+
resolveDownloadUrl?: (url: string) => Promise<string | undefined>
|
|
241
244
|
}>(),
|
|
242
245
|
{
|
|
243
246
|
embedded: false,
|
|
@@ -255,6 +258,7 @@ const emit = defineEmits<{ 'update:open': [v: boolean] }>()
|
|
|
255
258
|
|
|
256
259
|
const internalOpen = ref(false)
|
|
257
260
|
const loading = ref(false)
|
|
261
|
+
const downloading = ref(false)
|
|
258
262
|
const error = ref('')
|
|
259
263
|
const textContent = ref('')
|
|
260
264
|
const excelHtml = ref('')
|
|
@@ -336,16 +340,28 @@ const useDownloadAction = computed(
|
|
|
336
340
|
() => kind.value === 'unsupported' || kind.value === 'office',
|
|
337
341
|
)
|
|
338
342
|
|
|
339
|
-
function downloadFile() {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
async function downloadFile() {
|
|
344
|
+
if (downloading.value) return
|
|
345
|
+
const raw = src.value
|
|
346
|
+
if (!raw) return
|
|
347
|
+
downloading.value = true
|
|
348
|
+
try {
|
|
349
|
+
let url = raw
|
|
350
|
+
if (props.resolveDownloadUrl) {
|
|
351
|
+
const signed = await props.resolveDownloadUrl(raw)
|
|
352
|
+
if (!signed) return
|
|
353
|
+
url = signed
|
|
354
|
+
}
|
|
355
|
+
const a = document.createElement('a')
|
|
356
|
+
a.href = url
|
|
357
|
+
a.download = displayName.value || 'download'
|
|
358
|
+
a.rel = 'noopener'
|
|
359
|
+
document.body.appendChild(a)
|
|
360
|
+
a.click()
|
|
361
|
+
a.remove()
|
|
362
|
+
} finally {
|
|
363
|
+
downloading.value = false
|
|
364
|
+
}
|
|
349
365
|
}
|
|
350
366
|
|
|
351
367
|
function openInNewWindow() {
|
|
@@ -58,32 +58,24 @@
|
|
|
58
58
|
|
|
59
59
|
<div v-if="previewSrc" class="vm-upload-item__actions">
|
|
60
60
|
<button
|
|
61
|
-
v-if="canInlinePreview"
|
|
62
61
|
type="button"
|
|
63
62
|
title="预览"
|
|
64
63
|
@click.stop="previewOpen = true"
|
|
65
64
|
>
|
|
66
65
|
<i class="ri-zoom-in-line" />
|
|
67
66
|
</button>
|
|
68
|
-
<button
|
|
69
|
-
v-else
|
|
70
|
-
type="button"
|
|
71
|
-
title="下载"
|
|
72
|
-
@click.stop="downloadFile"
|
|
73
|
-
>
|
|
74
|
-
<i class="ri-download-2-line" />
|
|
75
|
-
</button>
|
|
76
67
|
<button v-if="!disabled" type="button" title="删除" @click.stop="emit('remove')">
|
|
77
68
|
<i class="ri-delete-bin-line" />
|
|
78
69
|
</button>
|
|
79
70
|
</div>
|
|
80
71
|
|
|
81
72
|
<vm-preview-viewer
|
|
82
|
-
v-if="
|
|
73
|
+
v-if="previewSrc"
|
|
83
74
|
embedded
|
|
84
75
|
v-model:open="previewOpen"
|
|
85
76
|
:src="previewSrc"
|
|
86
77
|
:file-name="item.name || item.url"
|
|
78
|
+
:resolve-download-url="resolveDownloadUrl"
|
|
87
79
|
/>
|
|
88
80
|
</div>
|
|
89
81
|
</template>
|
|
@@ -91,7 +83,6 @@
|
|
|
91
83
|
<script setup lang="ts">
|
|
92
84
|
import { ref, computed, watch } from 'vue'
|
|
93
85
|
import { useVideoFrame } from '../../lib/video-frame'
|
|
94
|
-
import { getMediaPreviewKind } from '../../lib/file-preview'
|
|
95
86
|
import { extname, getUploadRule } from '../../lib/upload'
|
|
96
87
|
import VmPreviewViewer from './vm-preview-viewer.vue'
|
|
97
88
|
import type { UploadItem } from '../../../../typings/admin/comm/upload'
|
|
@@ -103,6 +94,8 @@ const props = withDefaults(
|
|
|
103
94
|
item: UploadItem
|
|
104
95
|
disabled?: boolean
|
|
105
96
|
showTag?: boolean
|
|
97
|
+
/** 私有文件:预览内点「下载」时先解析可访问短链 */
|
|
98
|
+
resolveDownloadUrl?: (url: string) => Promise<string | undefined>
|
|
106
99
|
}>(),
|
|
107
100
|
{
|
|
108
101
|
disabled: false,
|
|
@@ -117,38 +110,6 @@ const imgBroken = ref(false)
|
|
|
117
110
|
|
|
118
111
|
const previewSrc = computed(() => props.item.preload || props.item.url || '')
|
|
119
112
|
|
|
120
|
-
const INLINE_KINDS = new Set([
|
|
121
|
-
'image',
|
|
122
|
-
'video',
|
|
123
|
-
'audio',
|
|
124
|
-
'pdf',
|
|
125
|
-
'excel',
|
|
126
|
-
'text',
|
|
127
|
-
])
|
|
128
|
-
|
|
129
|
-
/** 可内嵌预览才开浮层;.vome 等直接下载,避免新窗口崩溃 */
|
|
130
|
-
const canInlinePreview = computed(() => {
|
|
131
|
-
const name = props.item.name || props.item.url || ''
|
|
132
|
-
const kind = getMediaPreviewKind(name)
|
|
133
|
-
return INLINE_KINDS.has(kind)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
function downloadFile() {
|
|
137
|
-
const url = previewSrc.value
|
|
138
|
-
if (!url) return
|
|
139
|
-
const base =
|
|
140
|
-
props.item.name ||
|
|
141
|
-
String(url).split('?')[0]?.split('/').pop() ||
|
|
142
|
-
'download'
|
|
143
|
-
const a = document.createElement('a')
|
|
144
|
-
a.href = url
|
|
145
|
-
a.download = base
|
|
146
|
-
a.rel = 'noopener'
|
|
147
|
-
document.body.appendChild(a)
|
|
148
|
-
a.click()
|
|
149
|
-
a.remove()
|
|
150
|
-
}
|
|
151
|
-
|
|
152
113
|
/** 仅上传中显示;失败后隐藏,避免挡住预览/删除 */
|
|
153
114
|
const showProgress = computed(() => {
|
|
154
115
|
if (props.item.error) return false
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
:item="item"
|
|
39
39
|
:disabled="disabled"
|
|
40
40
|
:show-tag="showTag"
|
|
41
|
+
:resolve-download-url="resolveDownloadUrl"
|
|
41
42
|
@remove="remove(index)"
|
|
42
43
|
/>
|
|
43
44
|
</div>
|
|
@@ -96,6 +97,8 @@ const props = withDefaults(
|
|
|
96
97
|
drag?: boolean
|
|
97
98
|
prefixPath?: string
|
|
98
99
|
beforeUpload?: (file: File) => boolean | Promise<boolean>
|
|
100
|
+
/** 私有文件:预览内点「下载」时先解析可访问短链 */
|
|
101
|
+
resolveDownloadUrl?: (url: string) => Promise<string | undefined>
|
|
99
102
|
}>(),
|
|
100
103
|
{
|
|
101
104
|
modelValue: '',
|
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.
|
|
27859
|
+
version: "0.0.48",
|
|
27860
27860
|
description: "Vome framework \u2014 shared + Bun/Elysia server + Vue admin",
|
|
27861
27861
|
license: "MIT",
|
|
27862
27862
|
type: "module",
|
package/dist/server/index.js
CHANGED
|
@@ -31168,7 +31168,7 @@ init_excel();
|
|
|
31168
31168
|
// package.json
|
|
31169
31169
|
var package_default = {
|
|
31170
31170
|
name: "vome-core",
|
|
31171
|
-
version: "0.0.
|
|
31171
|
+
version: "0.0.48",
|
|
31172
31172
|
description: "Vome framework \u2014 shared + Bun/Elysia server + Vue admin",
|
|
31173
31173
|
license: "MIT",
|
|
31174
31174
|
type: "module",
|