fix: 完善任务导航与结束会话错误处理
- 结束会话 API 异常时显示错误,不导航(可重试) - 结束会话硬跳转改为软导航 router.push - TaskForm 创建/更新/取消后跳转任务列表页 - 移除 TaskForm 页面内大标题
This commit is contained in:
@@ -172,16 +172,22 @@ const endTimer = async (content: string) => {
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
});
|
||||
} catch {
|
||||
// 用户取消结束会话,不做任何操作
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await endSession(taskInfo.value.sessionNum, content);
|
||||
if (res.code === 200) {
|
||||
ElMessage.success("任务结束");
|
||||
} else {
|
||||
ElMessage.error(res.message || "结束会话失败");
|
||||
}
|
||||
|
||||
clear();
|
||||
window.location.assign("/study");
|
||||
await router.push("/study");
|
||||
} catch {
|
||||
// 用户取消结束会话,或接口异常时由请求层统一提示
|
||||
ElMessage.error("结束会话失败,请重试");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -238,13 +244,10 @@ onUnmounted(() => {
|
||||
|
||||
<template>
|
||||
<section class="start-page">
|
||||
<header class="surface-card top-head">
|
||||
<div>
|
||||
<h1 class="page-title">{{ taskInfo.taskName || "学习会话" }}</h1>
|
||||
<p class="page-subtitle">状态:{{ statusText }}</p>
|
||||
</div>
|
||||
<div class="task-info-bar">
|
||||
<el-tag type="success" effect="plain">任务编号:{{ taskInfo.taskNum }}</el-tag>
|
||||
</header>
|
||||
<span class="status-text">状态:{{ statusText }}</span>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="taskInfo.systemMessage"
|
||||
@@ -331,14 +334,17 @@ onUnmounted(() => {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.top-head {
|
||||
padding: 18px 20px;
|
||||
.task-info-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.session-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 380px 1fr;
|
||||
|
||||
Reference in New Issue
Block a user