提交所有代码

This commit is contained in:
郭庆泰
2026-08-31 19:01:00 +08:00
parent f4d8bc1463
commit a14d95288c
53 changed files with 1356 additions and 286 deletions
+14 -2
View File
@@ -27,14 +27,14 @@
<path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13z"/>
</svg></el-icon>
<div class="file-meta">
<a class="file-name" :href="modelValue" target="_blank" @click.stop>{{ fileName }}</a>
<a class="file-name" :href="openHref" target="_blank" @click.stop>{{ fileName }}</a>
<span class="file-type">{{ ext.toUpperCase() }} · {{ fileSizeText }}</span>
</div>
<el-link :underline="false" v-if="!readonly" type="danger" class="remove-btn" @click.stop="onRemove">移除</el-link>
<!-- 右侧预览框 (图片用 el-image, 其他用 icon + 点击新窗口打开) -->
<div v-if="showPreview" class="preview-box">
<el-image v-if="isImage" :src="modelValue" :preview-src-list="[modelValue]" :initial-index="0" fit="cover" class="preview-img" />
<a v-else :href="modelValue" target="_blank" class="preview-file" @click.stop>
<a v-else :href="openHref" target="_blank" class="preview-file" @click.stop>
<el-icon :size="28"><Document /></el-icon>
<span class="preview-text">{{ getFileType(modelValue) }}</span>
</a>
@@ -100,6 +100,18 @@ const isImage = computed(() => {
if (!props.modelValue) return false
return ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext.value)
})
// PDF: 点击不下载, 走 /common/oss/proxy 后端代理重写 Content-Disposition 为 inline, 新窗口内嵌预览
const isPdf = computed(() => ext.value.toLowerCase() === 'pdf')
// OSS 代理预览 (与 Preview.vue / PublicityDetail 同技术): bucket 默认 attachment, 直接打开会强制下载
function proxyUrl(url) {
if (!url) return url
if (url.includes('hwtossbamlorgcn.oss-cn-beijing.aliyuncs.com')) {
return import.meta.env.VITE_APP_BASE_API + '/common/oss/proxy?url=' + encodeURIComponent(url) + '#toolbar=0&zoom=page-width'
}
return url
}
// 文件名/预览框点击目标: PDF → 代理预览(新窗口), 其余 → 原 URL (图片 el-image 预览, 其他下载)
const openHref = computed(() => isPdf.value ? proxyUrl(props.modelValue) : props.modelValue)
// 文件类型标签 (PDF / DOC / XLS / ZIP 等)
const typeLabelMap = {
pdf: 'PDF', doc: 'DOC', docx: 'DOCX',