AI助手引导步骤返回上一步和正式使用AI助手时的再次设置功能,和投递过程的其他地方按钮点击保护

This commit is contained in:
2026-05-28 11:09:38 +08:00
parent a9638fc7ec
commit f52a7c56f7
21 changed files with 2296 additions and 47 deletions
+204 -10
View File
@@ -50,15 +50,13 @@
v-if="showTaskListDropdown"
:pending-list="applyJobList"
@removed="handleTaskRemoved"
@view-all="showTaskListDropdown = false"
@view-all="handleOpenPendingListPanel"
@view-all-completed="handleOpenApplyProgressPanel"
/>
<!-- 齿轮按钮 -->
<!-- <button class="agent-main__tool-btn" title="配置">-->
<!-- <svg viewBox="0 0 24 24" fill="none">-->
<!-- <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="1.5" />-->
<!-- <path d="M12 1v2m0 18v2m-9-11h2m18 0h2m-3.3-7.7-1.4 1.4M4.7 19.3l1.4-1.4m0-11.8L4.7 4.7m14.6 14.6-1.4-1.4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />-->
<!-- </svg>-->
<!-- </button>-->
<!-- 设置按钮 -->
<button class="agent-main__tool-btn" title="配置" @click="handleOpenSettingsPanel">
设置
</button>
</div>
</div>
@@ -83,6 +81,7 @@
:summary="getRecommendSummaryFromExtra(msg.extra)"
:jobs="getRecommendJobsFromExtra(msg.extra)"
@view-all="handleOpenRecommendPanel(msg.id)"
@click-job="handleChatJobClick"
/>
</div>
@@ -138,6 +137,7 @@
@view-more="handleViewMoreJobs"
@toggle="handleToggleJobApply"
@add-all="handleAddAllJobs"
@click-job="handleMatchJobClick"
/>
<!-- 模式2简历生成进度 -->
<div v-else-if="rightPanelMode === 'generating'" class="agent-resume-generating">
@@ -154,6 +154,32 @@
<div v-else-if="rightPanelMode === 'resume'" class="agent-main__right-resume">
<JobResumeTemplate :resume-data="applyResumeData" />
</div>
<!-- 模式4岗位预览 -->
<AgentJobPreviewPanel
v-else-if="rightPanelMode === 'jobPreview'"
:job-id="previewJobId"
:application-status="previewJobApplicationStatus"
@back="handleJobPreviewBack"
@add="handleJobPreviewAdd"
@remove="handleJobPreviewRemove"
/>
<!-- 模式5全部的待投递列表 -->
<AgentPendingJobListPanel
v-else-if="rightPanelMode === 'pendingList'"
@close="handleClosePendingListPanel"
@removed="handlePendingListRemoved"
/>
<!-- 模式6全部的已投递进度 -->
<AgentApplyProgressPanel
v-else-if="rightPanelMode === 'applyProgress'"
@close="handleCloseApplyProgressPanel"
/>
<!-- 模式7设置面板 -->
<AgentSettingPanel
v-else-if="rightPanelMode === 'settings'"
@close="handleCloseSettingsPanel"
/>
<!-- 模式7AI助手设置 -->
</div>
</div>
</div>
@@ -172,6 +198,10 @@ import AgentMatchJobAdd from '@/components/AgentMatchJobAdd.vue'
import AgentApplyProgress from '@/components/AgentApplyProgress.vue'
import AgentTaskListDropdown from '@/components/AgentTaskListDropdown.vue'
import JobResumeTemplate from '@/components/JobResumeTemplate.vue'
import AgentJobPreviewPanel from '@/components/AgentJobPreviewPanel.vue'
import AgentPendingJobListPanel from '@/components/AgentPendingJobListPanel.vue'
import AgentApplyProgressPanel from '@/components/AgentApplyProgressPanel.vue'
import AgentSettingPanel from '@/components/AgentSettingPanel.vue'
import type { ResumeTemplateData } from '@/components/JobResumeTemplate.vue'
import { fetchAgentConfig, saveAgentConfig, fetchAgentRecommend, fetchAgentChatMessages, addAgentChatMessage, applyJob, cancelApplyJob, fetchApplyByJobIds, sendAgentChat, optimizeAgentResume } from '@/api/agent'
import type { AgentConfig, AgentRecommendJob, AgentChatMessage, AgentChatHistoryItem } from '@/api/agent'
@@ -370,6 +400,11 @@ async function loadApplyList() {
/** 切换待投递列表下拉弹窗显隐 */
function toggleTaskListDropdown() {
/* 投递流程进行中时禁止打开待投递列表 */
if (isApplying.value) {
ElMessage.warning('请完成或取消投递流程后再打开编辑待投递列表')
return
}
showTaskListDropdown.value = !showTaskListDropdown.value
if (showTaskListDropdown.value) {
loadApplyList()
@@ -564,6 +599,11 @@ function handleViewMoreJobs() {
/** 打开右侧匹配岗位面板 — 先查询投递记录更新岗位状态再显示 */
async function handleOpenRecommendPanel(msgId: number) {
/* 投递流程进行中(模式2简历生成 / 模式3简历预览)时禁止打开推荐面板 */
if (rightPanelMode.value === 'generating' || rightPanelMode.value === 'resume') {
ElMessage.warning('请完成或退出投递流程后再添加岗位')
return
}
activeRecommendMsgId.value = msgId
showRightPanel.value = true
panelLoading.value = true
@@ -618,10 +658,137 @@ function handleCloseRecommendPanel() {
rightPanelMode.value = 'recommend'
}
// ==================== 岗位预览(模式4 ====================
/** 当前预览的岗位 ID */
const previewJobId = ref('')
/** 当前预览岗位的投递状态 */
const previewJobApplicationStatus = ref<number | null>(null)
/** 进入岗位预览前记录的面板模式(用于返回) */
const prevPanelMode = ref<'recommend' | 'generating' | 'resume' | 'jobPreview' | 'pendingList' | 'applyProgress' | 'settings'>('recommend')
/** 打开岗位预览面板 */
function handleOpenJobPreview(jobId: string | number, applicationStatus?: number | null) {
previewJobId.value = String(jobId)
previewJobApplicationStatus.value = applicationStatus ?? null
prevPanelMode.value = rightPanelMode.value
rightPanelMode.value = 'jobPreview'
showRightPanel.value = true
}
/** 岗位预览返回 — 回到之前的面板模式 */
function handleJobPreviewBack() {
/* 如果之前是 recommend 模式且有选中的消息,回到推荐面板 */
if (prevPanelMode.value === 'recommend' && activeRecommendMsgId.value !== null) {
rightPanelMode.value = 'recommend'
} else {
/* 否则关闭面板 */
showRightPanel.value = false
rightPanelMode.value = 'recommend'
}
}
/** 岗位预览中点击添加 — 添加到待投递 */
async function handleJobPreviewAdd(jobId: string) {
try {
await applyJob({ jobId, status: -1 })
/* 更新对话消息中的岗位状态 */
updateJobStatusInMessages(Number(jobId), -1)
previewJobApplicationStatus.value = -1
await loadApplyList()
ElMessage.success('岗位已添加到待投递')
} catch {
ElMessage.error('操作失败,请重试')
}
}
/** 岗位预览中点击移出 — 从待投递移除 */
async function handleJobPreviewRemove(jobId: string) {
try {
await cancelApplyJob(jobId)
/* 更新对话消息中的岗位状态 */
updateJobStatusInMessages(Number(jobId), null)
previewJobApplicationStatus.value = null
await loadApplyList()
ElMessage.success('岗位已从待投递移除')
} catch {
ElMessage.error('操作失败,请重试')
}
}
/** AgentMatchJobAdd 中点击岗位 — 打开岗位预览 */
function handleMatchJobClick(job: AgentRecommendJob) {
handleOpenJobPreview(job.id, job.applicationStatus)
}
/** AgentChatJobList 中点击岗位 — 打开岗位预览 */
function handleChatJobClick(job: AgentRecommendJob) {
/* 投递流程进行中时禁止打开岗位详情 */
if (isApplying.value) {
ElMessage.warning('请完成或取消投递流程后再查看岗位详情')
return
}
handleOpenJobPreview(job.id, job.applicationStatus)
}
// ==================== 待投递列表面板(模式5 ====================
/** 打开待投递列表面板 */
function handleOpenPendingListPanel() {
showTaskListDropdown.value = false
rightPanelMode.value = 'pendingList'
showRightPanel.value = true
}
/** 关闭待投递列表面板 */
function handleClosePendingListPanel() {
showRightPanel.value = false
rightPanelMode.value = 'recommend'
}
/** 待投递列表面板中移除岗位后同步父组件数据 */
function handlePendingListRemoved(jobId: string) {
const idx = applyJobList.value.findIndex(j => j.id === jobId)
if (idx !== -1) {
applyJobList.value.splice(idx, 1)
}
}
// ==================== 申请进度面板(模式6 ====================
/** 打开申请进度面板 */
function handleOpenApplyProgressPanel() {
showTaskListDropdown.value = false
rightPanelMode.value = 'applyProgress'
showRightPanel.value = true
}
/** 关闭申请进度面板 */
function handleCloseApplyProgressPanel() {
showRightPanel.value = false
rightPanelMode.value = 'recommend'
}
// ==================== 设置面板(模式7 ====================
/** 打开设置面板 */
function handleOpenSettingsPanel() {
rightPanelMode.value = 'settings'
showRightPanel.value = true
}
/** 关闭设置面板 */
function handleCloseSettingsPanel() {
showRightPanel.value = false
rightPanelMode.value = 'recommend'
}
// ==================== 投递进度流程 ====================
/** 右侧面板显示模式recommend-岗位推荐 / generating-简历生成中 / resume-简历预览 */
const rightPanelMode = ref<'recommend' | 'generating' | 'resume'>('recommend')
/** 右侧面板显示模式 */
const rightPanelMode = ref<'recommend' | 'generating' | 'resume' | 'jobPreview' | 'pendingList' | 'applyProgress' | 'settings'>('recommend')
/** 简历生成进度百分比(0-100) */
const generateProgress = ref(0)
@@ -770,6 +937,7 @@ async function handleStartApply() {
// 打开右侧面板,显示生成进度
rightPanelMode.value = 'generating'
showRightPanel.value = true
applyCancelled.value = false
startProgressSimulation()
try {
@@ -778,12 +946,18 @@ async function handleStartApply() {
jobId: targetJob.id,
})
// 如果在等待期间已取消,直接退出
if (applyCancelled.value) return
// 接口返回后涨满进度条
finishProgress()
// 等待 1 秒让用户看到 100%
await new Promise(resolve => setTimeout(resolve, 1000))
// 再次检查取消状态
if (applyCancelled.value) return
// 解析简历数据 — 映射接口返回格式到 ResumeTemplateData
const apiData = res?.data || res
if (apiData) {
@@ -801,6 +975,8 @@ async function handleStartApply() {
rightPanelMode.value = 'resume'
}
} catch (e) {
// 取消导致的异常不提示
if (applyCancelled.value) return
console.error('[Agent] 优化简历失败', e)
ElMessage.error('简历优化失败,请重试')
finishProgress()
@@ -895,8 +1071,20 @@ function handleTogglePause() {
isPaused.value = !isPaused.value
}
/** 标记当前投递流程是否已被取消(防止异步回调覆盖状态) */
const applyCancelled = ref(false)
/** 取消投递流程 */
function handleCancelApply(msg: AgentChatMessage) {
// 标记已取消,阻止进行中的异步回调继续操作
applyCancelled.value = true
// 清除进度条定时器
if (progressTimer) {
clearInterval(progressTimer)
progressTimer = null
}
// 重置暂停状态
isPaused.value = false
// 从消息列表中移除该条 apply_progress
const idx = chatMessages.value.findIndex(m => m.id === msg.id)
if (idx !== -1) {
@@ -1029,6 +1217,7 @@ async function autoStartNextApply() {
// 第1步:优化简历
rightPanelMode.value = 'generating'
showRightPanel.value = true
applyCancelled.value = false
startProgressSimulation()
try {
@@ -1037,9 +1226,13 @@ async function autoStartNextApply() {
jobId: targetJob.id,
})
if (applyCancelled.value) return
finishProgress()
await new Promise(resolve => setTimeout(resolve, 1000))
if (applyCancelled.value) return
const apiData = res?.data || res
if (apiData) {
const resumeResult = mapOptimizeResumeToTemplate(apiData)
@@ -1053,6 +1246,7 @@ async function autoStartNextApply() {
rightPanelMode.value = 'resume'
}
} catch (e) {
if (applyCancelled.value) return
console.error('[Agent] 优化简历失败', e)
ElMessage.error('简历优化失败,请重试')
finishProgress()