vome-core 0.0.45 → 0.0.46
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.
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
v-else
|
|
70
70
|
type="button"
|
|
71
71
|
title="下载"
|
|
72
|
+
:disabled="downloading"
|
|
72
73
|
@click.stop="downloadFile"
|
|
73
74
|
>
|
|
74
75
|
<i class="ri-download-2-line" />
|
|
@@ -103,6 +104,8 @@ const props = withDefaults(
|
|
|
103
104
|
item: UploadItem
|
|
104
105
|
disabled?: boolean
|
|
105
106
|
showTag?: boolean
|
|
107
|
+
/** 私有桶等场景:先解析可访问 URL(如短时签名链)再下载 */
|
|
108
|
+
resolveDownloadUrl?: (url: string, item: UploadItem) => Promise<string | undefined>
|
|
106
109
|
}>(),
|
|
107
110
|
{
|
|
108
111
|
disabled: false,
|
|
@@ -114,6 +117,7 @@ const emit = defineEmits<{ remove: [] }>()
|
|
|
114
117
|
|
|
115
118
|
const previewOpen = ref(false)
|
|
116
119
|
const imgBroken = ref(false)
|
|
120
|
+
const downloading = ref(false)
|
|
117
121
|
|
|
118
122
|
const previewSrc = computed(() => props.item.preload || props.item.url || '')
|
|
119
123
|
|
|
@@ -133,20 +137,33 @@ const canInlinePreview = computed(() => {
|
|
|
133
137
|
return INLINE_KINDS.has(kind)
|
|
134
138
|
})
|
|
135
139
|
|
|
136
|
-
function downloadFile() {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
async function downloadFile() {
|
|
141
|
+
if (downloading.value) return
|
|
142
|
+
const raw = previewSrc.value
|
|
143
|
+
if (!raw) return
|
|
144
|
+
downloading.value = true
|
|
145
|
+
try {
|
|
146
|
+
let url = raw
|
|
147
|
+
if (props.resolveDownloadUrl) {
|
|
148
|
+
const signed = await props.resolveDownloadUrl(raw, props.item)
|
|
149
|
+
if (!signed) return
|
|
150
|
+
url = signed
|
|
151
|
+
}
|
|
152
|
+
const base =
|
|
153
|
+
props.item.name ||
|
|
154
|
+
String(url).split('?')[0]?.split('/').pop() ||
|
|
155
|
+
'download'
|
|
156
|
+
const a = document.createElement('a')
|
|
157
|
+
a.href = url
|
|
158
|
+
a.download = base
|
|
159
|
+
a.rel = 'noopener'
|
|
160
|
+
a.target = '_blank'
|
|
161
|
+
document.body.appendChild(a)
|
|
162
|
+
a.click()
|
|
163
|
+
a.remove()
|
|
164
|
+
} finally {
|
|
165
|
+
downloading.value = false
|
|
166
|
+
}
|
|
150
167
|
}
|
|
151
168
|
|
|
152
169
|
/** 仅上传中显示;失败后隐藏,避免挡住预览/删除 */
|
|
@@ -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
|
+
/** 私有桶等:下载前解析可访问 URL(短时签名链) */
|
|
101
|
+
resolveDownloadUrl?: (url: string, item: UploadItem) => 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.46",
|
|
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.46",
|
|
31172
31172
|
description: "Vome framework \u2014 shared + Bun/Elysia server + Vue admin",
|
|
31173
31173
|
license: "MIT",
|
|
31174
31174
|
type: "module",
|