修复 跨越不能下载错误

This commit is contained in:
yf 2025-03-05 08:58:27 +08:00
parent 72d5375658
commit 3b2449710d
4 changed files with 130 additions and 134 deletions

View File

@ -32,9 +32,7 @@
<template #default="scope">
<div>
<el-link
:href="scope.row.url"
:underline="false"
download
@click="doDownload(scope.row.url)"
target="_blank"
type="primary"
>
@ -92,6 +90,9 @@ const formatBytes = (bytes: any, decimals = 2) =>{
}
return res + ' ' + sizes[i]
}
const doDownload = (url) =>{
window.open(url)
}
//
watch(
() => props.modelValue,

View File

@ -15,7 +15,7 @@
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-success="handleFileSuccess"
:show-file-list="true"
:show-file-list="false"
:accept="accept"
:disabled="disabled || fileList.length >= props.limit"
class="upload-file-uploader"
@ -36,69 +36,64 @@
{{ t(`common.fileUploadFormat`) }} <b style="color: #f56c6c">{{ fileType.join('/') }}</b>
</div>
</template>
<template #file="row">
<div class="flex items-center">
<div>
<!-- 'ready' | 'uploading' | 'success' | 'fail'-->
<div v-if="row.file.status === 'ready'">
<el-tag type="info">
<Icon icon="ep:clock"/>
</el-tag>
</div>
<div v-if="row.file.status === 'uploading'">
<el-tag type="warning" effect="dark">
<Icon icon="ep:loading"/>
</el-tag>
</div>
<div v-if="row.file.status === 'success'">
<el-tag type="success" effect="dark">
<Icon icon="ep:success-filled"/>
</el-tag>
</div>
<div v-if="row.file.status === 'fail'" style="color: #ff0000">
<el-tag type="danger" effect="dark">
<Icon icon="ep:warning-filled"/>
</el-tag>
{{ row.file.error }}
</div>
</div>
<el-tooltip
class="box-item"
effect="dark"
:content="row.file.name"
placement="top-start"
>
<div class="ml-2 line-clamp-1">{{ row.file.name }}</div>
</el-tooltip>
<div class="flex">
<div class="ml-1">
<el-link
:href="row.file.url"
:underline="false"
download
target="_blank"
type="primary"
>
<Icon icon="ep:download" :size="24"/>
</el-link>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="primary" @click="reName(row.file)">
<Icon icon="ep:edit" :size="18"/>
</el-button>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="danger" @click="handleRemove(row.file)">
<Icon icon="ep:delete" :size="18"/>
</el-button>
</div>
</div>
</div>
</template>
</el-upload>
<div class="flex items-center" v-for="(row) in fileList" :key="row.uid">
<div>
<!-- 'ready' | 'uploading' | 'success' | 'fail'-->
<div v-if="row.status === 'ready'">
<el-tag type="info">
<Icon icon="ep:clock"/>
</el-tag>
</div>
<div v-if="row.status === 'uploading'">
<el-tag type="warning" effect="dark">
<Icon icon="ep:loading"/>
</el-tag>
</div>
<div v-if="row.status === 'success'">
<el-tag type="success" effect="dark">
<Icon icon="ep:success-filled"/>
</el-tag>
</div>
<div v-if="row.status === 'fail'" style="color: #ff0000">
<el-tag type="danger" effect="dark">
<Icon icon="ep:warning-filled"/>
</el-tag>
{{ row.error }}
</div>
</div>
<el-tooltip
class="box-item"
effect="dark"
:content="row.name"
placement="top-start"
>
<div class="ml-2 line-clamp-1">{{ row.name }}</div>
</el-tooltip>
<div class="flex">
<div class="ml-1">
<el-link
@click="doDownload(row.url)"
target="_blank"
type="primary"
>
<Icon icon="ep:download" :size="24"/>
</el-link>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="primary" @click="reName(row)">
<Icon icon="ep:edit" :size="18"/>
</el-button>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="danger" @click="handleRemove(row)">
<Icon icon="ep:delete" :size="18"/>
</el-button>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
@ -240,7 +235,6 @@ const reName = (file: UploadFile) => {
useMessage().warning(t('common.fileUploadNotUploadTips'));
}
}
const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
console.log(uploadFile)
@ -294,6 +288,9 @@ const emitUpdateModelValue = () => {
result = result.join(',')
emit('update:modelValue', result)
}
const doDownload = (url) =>{
window.open(url)
}
</script>
<style lang="scss" scoped>
.upload-file-uploader {

View File

@ -32,9 +32,7 @@
<template #default="scope">
<div>
<el-link
:href="scope.row.url"
:underline="false"
download
@click="doDownload(scope.row.url)"
target="_blank"
type="primary"
>
@ -92,6 +90,9 @@ const formatBytes = (bytes: any, decimals = 2) =>{
}
return res + ' ' + sizes[i]
}
const doDownload = (url) =>{
window.open(url)
}
//
watch(
() => props.modelValue,

View File

@ -15,7 +15,7 @@
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-success="handleFileSuccess"
:show-file-list="true"
:show-file-list="false"
:accept="accept"
:disabled="disabled || fileList.length >= props.limit"
class="upload-file-uploader"
@ -36,69 +36,64 @@
{{ t(`common.fileUploadFormat`) }} <b style="color: #f56c6c">{{ fileType.join('/') }}</b>
</div>
</template>
<template #file="row">
<div class="flex items-center">
<div>
<!-- 'ready' | 'uploading' | 'success' | 'fail'-->
<div v-if="row.file.status === 'ready'">
<el-tag type="info">
<Icon icon="ep:clock"/>
</el-tag>
</div>
<div v-if="row.file.status === 'uploading'">
<el-tag type="warning" effect="dark">
<Icon icon="ep:loading"/>
</el-tag>
</div>
<div v-if="row.file.status === 'success'">
<el-tag type="success" effect="dark">
<Icon icon="ep:success-filled"/>
</el-tag>
</div>
<div v-if="row.file.status === 'fail'" style="color: #ff0000">
<el-tag type="danger" effect="dark">
<Icon icon="ep:warning-filled"/>
</el-tag>
{{ row.file.error }}
</div>
</div>
<el-tooltip
class="box-item"
effect="dark"
:content="row.file.name"
placement="top-start"
>
<div class="ml-2 line-clamp-1">{{ row.file.name }}</div>
</el-tooltip>
<div class="flex">
<div class="ml-1">
<el-link
:href="row.file.url"
:underline="false"
download
target="_blank"
type="primary"
>
<Icon icon="ep:download" :size="24"/>
</el-link>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="primary" @click="reName(row.file)">
<Icon icon="ep:edit" :size="18"/>
</el-button>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="danger" @click="handleRemove(row.file)">
<Icon icon="ep:delete" :size="18"/>
</el-button>
</div>
</div>
</div>
</template>
</el-upload>
<div class="flex items-center" v-for="(row) in fileList" :key="row.uid">
<div>
<!-- 'ready' | 'uploading' | 'success' | 'fail'-->
<div v-if="row.status === 'ready'">
<el-tag type="info">
<Icon icon="ep:clock"/>
</el-tag>
</div>
<div v-if="row.status === 'uploading'">
<el-tag type="warning" effect="dark">
<Icon icon="ep:loading"/>
</el-tag>
</div>
<div v-if="row.status === 'success'">
<el-tag type="success" effect="dark">
<Icon icon="ep:success-filled"/>
</el-tag>
</div>
<div v-if="row.status === 'fail'" style="color: #ff0000">
<el-tag type="danger" effect="dark">
<Icon icon="ep:warning-filled"/>
</el-tag>
{{ row.error }}
</div>
</div>
<el-tooltip
class="box-item"
effect="dark"
:content="row.name"
placement="top-start"
>
<div class="ml-2 line-clamp-1">{{ row.name }}</div>
</el-tooltip>
<div class="flex">
<div class="ml-1">
<el-link
@click="doDownload(row.url)"
target="_blank"
type="primary"
>
<Icon icon="ep:download" :size="24"/>
</el-link>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="primary" @click="reName(row)">
<Icon icon="ep:edit" :size="18"/>
</el-button>
</div>
<div class="ml-1" v-if="!disabled">
<el-button link type="danger" @click="handleRemove(row)">
<Icon icon="ep:delete" :size="18"/>
</el-button>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
@ -240,7 +235,6 @@ const reName = (file: UploadFile) => {
useMessage().warning(t('common.fileUploadNotUploadTips'));
}
}
const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
console.log(uploadFile)
@ -294,6 +288,9 @@ const emitUpdateModelValue = () => {
result = result.join(',')
emit('update:modelValue', result)
}
const doDownload = (url) =>{
window.open(url)
}
</script>
<style lang="scss" scoped>
.upload-file-uploader {