feat: 产品视频改后台上传,promotion-media 公开访问;gitignore 大文件;保留原文件名上传

Made-with: Cursor
This commit is contained in:
whm
2026-03-20 17:10:56 +08:00
parent 5067fb6f76
commit 654b683067
20 changed files with 225 additions and 47 deletions

View File

@@ -78,6 +78,7 @@ export const uploadSiteAsset = (siteId, file, opts = {}) => {
form.append('file', file)
if (opts.folder != null) form.append('folder', opts.folder)
form.append('downloadable', opts.downloadable ? 'true' : 'false')
if (opts.preserveFilename) form.append('preserve_filename', 'true')
return request.post(`/admin/sites/${siteId}/assets`, form, { headers: { 'Content-Type': 'multipart/form-data' } })
}
export const createSiteFolder = (siteId, path) => request.post(`/admin/sites/${siteId}/folders`, { path })

View File

@@ -56,11 +56,15 @@
</el-card>
<!-- 上传前选择是否可下载 -->
<el-dialog v-model="uploadDialogVisible" title="上传文件" width="400px" :close-on-click-modal="false">
<el-form label-width="100px">
<el-dialog v-model="uploadDialogVisible" title="上传文件" width="440px" :close-on-click-modal="false">
<el-form label-width="112px">
<el-form-item label="当前目录">
<span>{{ currentPath || '根目录' }}</span>
</el-form-item>
<el-form-item label="保留原文件名">
<el-switch v-model="uploadPreserveFilename" />
<span class="form-hint">开启后覆盖同路径同名文件首页产品视频须上传到 <code>promotion/视频发布/</code> 并开启此项</span>
</el-form-item>
<el-form-item label="允许下载">
<el-switch v-model="uploadDownloadable" />
</el-form-item>
@@ -100,7 +104,8 @@ const loading = ref(false)
const currentPath = ref('')
const uploading = ref(false)
const uploadDialogVisible = ref(false)
const uploadDownloadable = ref(true)
const uploadDownloadable = ref(false)
const uploadPreserveFilename = ref(false)
const pendingFile = ref(null)
const showNewFolder = ref(false)
const newFolderName = ref('')
@@ -152,7 +157,9 @@ watch([siteId, currentPath], fetchList)
const beforeUpload = (file) => {
pendingFile.value = file
uploadDownloadable.value = true
const p = (currentPath.value || '').replace(/^\//, '')
uploadPreserveFilename.value = p.startsWith('promotion/')
uploadDownloadable.value = !uploadPreserveFilename.value
uploadDialogVisible.value = true
return false
}
@@ -163,7 +170,8 @@ const doUpload = async () => {
try {
await uploadSiteAsset(siteId.value, pendingFile.value, {
folder: currentPath.value || undefined,
downloadable: uploadDownloadable.value
downloadable: uploadDownloadable.value,
preserveFilename: uploadPreserveFilename.value
})
ElMessage.success('上传成功')
uploadDialogVisible.value = false
@@ -216,6 +224,8 @@ onMounted(() => fetchSites().then(() => fetchList()))
<style scoped>
.file-manage .tip { color: #666; font-size: 14px; }
.form-hint { display: block; margin-top: 6px; font-size: 12px; color: #909399; line-height: 1.4; }
.form-hint code { font-size: 11px; }
.module-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.breadcrumb-wrap { margin-top: 12px; }
.subdirs { margin-top: 8px; font-size: 13px; color: #666; }