From 0d7576dc85199e2b5cfa566b3960fe65756d341a Mon Sep 17 00:00:00 2001 From: TianyangZhang Date: Thu, 26 Mar 2026 11:29:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E5=A4=84=E9=A1=B5=E9=9D=A2=E5=8A=9F=E8=83=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - JobCard: 分享按钮移至卡片右上角,链接去掉 # 前缀 - JobDetailView: 修复已投递状态判断(job 字段为整数非对象),页面加载时同步收藏状态 - ApplicationManageView: 下载附件改用 Content-Type 判断扩展名,修复无扩展名文件下载为乱码问题 - 新增 SplashView 落地页(企业招聘门户风格) - 新增 FavoritesView 我的收藏页面 Co-Authored-By: Claude Sonnet 4.6 --- offer_frontend/src/components/JobCard.vue | 29 +- offer_frontend/src/views/SplashView.vue | 538 ++++++++++++++++++ .../src/views/admin/ApplicationManageView.vue | 47 +- .../src/views/portal/JobDetailView.vue | 15 +- .../src/views/seeker/FavoritesView.vue | 39 ++ 5 files changed, 638 insertions(+), 30 deletions(-) create mode 100644 offer_frontend/src/views/SplashView.vue create mode 100644 offer_frontend/src/views/seeker/FavoritesView.vue diff --git a/offer_frontend/src/components/JobCard.vue b/offer_frontend/src/components/JobCard.vue index 79010fe..182cc0e 100644 --- a/offer_frontend/src/components/JobCard.vue +++ b/offer_frontend/src/components/JobCard.vue @@ -1,6 +1,13 @@ + + diff --git a/offer_frontend/src/views/admin/ApplicationManageView.vue b/offer_frontend/src/views/admin/ApplicationManageView.vue index c377a39..b88f116 100644 --- a/offer_frontend/src/views/admin/ApplicationManageView.vue +++ b/offer_frontend/src/views/admin/ApplicationManageView.vue @@ -135,19 +135,48 @@ function getGenderLabel(gender) { return genderMap[gender] || '-' } -function downloadAttachment() { +async function downloadAttachment() { if (!currentResume.value?.attachment_url) { ElMessage.warning('附件不可用') return } - // 直接通过 media URL 下载(由 Django 代理) - const link = document.createElement('a') - link.href = currentResume.value.attachment_url - link.download = `${currentResume.value.name}_resume.pdf` - document.body.appendChild(link) - link.click() - document.body.removeChild(link) - ElMessage.success('下载已启动') + try { + // 修正 /media/media/ 双重前缀问题 + let url = currentResume.value.attachment_url.replace(/\/media\/media\//, '/media/') + + // 用 fetch+blob 确保触发下载而不是浏览器预览 + const response = await fetch(url) + if (!response.ok) throw new Error('请求失败') + + // 优先用 Content-Type 判断扩展名,避免无扩展名文件名导致乱码 + const contentType = (response.headers.get('content-type') || '').split(';')[0].trim() + const mimeMap = { + 'application/pdf': 'pdf', + 'application/msword': 'doc', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx', + 'image/jpeg': 'jpg', + 'image/png': 'png', + } + let ext = mimeMap[contentType] + if (!ext) { + const urlExt = url.split('.').pop().split('?')[0] + ext = /^[a-zA-Z0-9]{1,5}$/.test(urlExt) ? urlExt : 'pdf' + } + const filename = `${currentResume.value.name}_resume.${ext}` + + const blob = await response.blob() + const blobUrl = URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = blobUrl + link.download = filename + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + URL.revokeObjectURL(blobUrl) + ElMessage.success('下载已启动') + } catch { + ElMessage.error('下载失败,请重试') + } } diff --git a/offer_frontend/src/views/portal/JobDetailView.vue b/offer_frontend/src/views/portal/JobDetailView.vue index 267e3f8..bd552a7 100644 --- a/offer_frontend/src/views/portal/JobDetailView.vue +++ b/offer_frontend/src/views/portal/JobDetailView.vue @@ -132,7 +132,7 @@