定制简历浏览器记录缓存加IndexDB存储工具封装,修复同一个页面的不同协议切换问题
This commit is contained in:
+55
-4
@@ -152,7 +152,7 @@
|
||||
</div>
|
||||
<!-- 模式3:简历预览 -->
|
||||
<div v-else-if="rightPanelMode === 'resume'" class="agent-main__right-resume">
|
||||
<JobResumeTemplate :resume-data="applyResumeData" />
|
||||
<JobResumeTemplate ref="applyResumeTemplateRef" :resume-data="applyResumeData" />
|
||||
</div>
|
||||
<!-- 模式4:岗位预览 -->
|
||||
<AgentJobPreviewPanel
|
||||
@@ -179,7 +179,6 @@
|
||||
v-else-if="rightPanelMode === 'settings'"
|
||||
@close="handleCloseSettingsPanel"
|
||||
/>
|
||||
<!-- 模式7:AI助手设置 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -209,6 +208,8 @@ import { fetchAgentTaskList } from '@/api/jobs'
|
||||
import type { JobListItem } from '@/api/jobs'
|
||||
import { fetchResumeList } from '@/api/resume'
|
||||
import { getIntentionCategoryNames, getIntentionRegionNames, getIntentionIndustryNames } from '@/utils/intention'
|
||||
import { cacheResumePdfToLocal, getCachedResumeRecord, getCachedResumeFile } from '@/utils/resumeExport'
|
||||
import store from '@/stores'
|
||||
import AiThinkingIndicator from '@/components/tools/AiThinkingIndicator.vue'
|
||||
import JobGoalDialog from '@/components/JobGoalDialog.vue'
|
||||
|
||||
@@ -796,6 +797,9 @@ const generateProgress = ref(0)
|
||||
/** 当前投递流程的简历数据 */
|
||||
const applyResumeData = ref<ResumeTemplateData>({} as ResumeTemplateData)
|
||||
|
||||
/** 右侧面板简历模板组件引用(用于生成PDF上传) */
|
||||
const applyResumeTemplateRef = ref<InstanceType<typeof JobResumeTemplate> | null>(null)
|
||||
|
||||
/** 当前投递流程的简历名称 */
|
||||
const applyResumeName = ref('')
|
||||
|
||||
@@ -1098,13 +1102,60 @@ function handleCancelApply(msg: AgentChatMessage) {
|
||||
}
|
||||
|
||||
/** 第2步:确认简历 */
|
||||
function handleConfirmResumeStep(msg: AgentChatMessage) {
|
||||
async function handleConfirmResumeStep(msg: AgentChatMessage) {
|
||||
try {
|
||||
const extraData = JSON.parse(msg.extra)
|
||||
// 勾选第2步,进入第3步
|
||||
extraData.step = 3
|
||||
msg.extra = JSON.stringify(extraData)
|
||||
} catch { /* 忽略 */ }
|
||||
|
||||
// 确认简历后,自动生成PDF并缓存到浏览器localStorage
|
||||
await nextTick()
|
||||
const element = applyResumeTemplateRef.value?.resumeRef
|
||||
if (element) {
|
||||
const userId = String(store.state.userInfo?.id || '')
|
||||
const jobId = String(extraData.jobInfo?.id || '')
|
||||
if (userId && jobId) {
|
||||
const cacheRecord = await cacheResumePdfToLocal(element, userId, jobId)
|
||||
if (cacheRecord) {
|
||||
// 将缓存记录的 storageKey 存入 extraData,方便后续读取
|
||||
extraData.resumeCacheKey = cacheRecord.storageKey
|
||||
msg.extra = JSON.stringify(extraData)
|
||||
|
||||
//测试一下通过userId和jobId拿到storageKey,再用storageKey拿到简历文件并下载到浏览器测试一下(测试成功,先注释)
|
||||
const testRecord = getCachedResumeRecord(userId, jobId)
|
||||
// if (testRecord) {
|
||||
// const testFile = await getCachedResumeFile(testRecord.storageKey, '测试缓存简历')
|
||||
// if (testFile) {
|
||||
// const url = URL.createObjectURL(testFile)
|
||||
// const a = document.createElement('a')
|
||||
// a.href = url
|
||||
// a.download = testFile.name
|
||||
// document.body.appendChild(a)
|
||||
// a.click()
|
||||
// document.body.removeChild(a)
|
||||
// URL.revokeObjectURL(url)
|
||||
// console.log('[Agent] 测试:从IndexedDB取出简历并下载成功', testRecord)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // 【暂时注释】上传到服务器方案(服务器资源压力大,暂用localStorage缓存替代)
|
||||
// const element = applyResumeTemplateRef.value?.resumeRef
|
||||
// if (element) {
|
||||
// const fileName = applyResumeName.value || '岗位专属简历'
|
||||
// const pdfFile = await generateResumePdfFile(element, fileName)
|
||||
// const uploadRes = await uploadFileToOss(pdfFile, 'ResumeFile')
|
||||
// if (uploadRes.code === '0' && uploadRes.data) {
|
||||
// extraData.resumeFileUrl = uploadRes.data.downloadUrl
|
||||
// msg.extra = JSON.stringify(extraData)
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
console.error('[Agent] 简历PDF缓存失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
/** 第3步:跳过投递 */
|
||||
|
||||
Reference in New Issue
Block a user