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;
|
||||
|
||||
@@ -22,12 +22,6 @@ const priority = ref({
|
||||
});
|
||||
|
||||
const priorityOptions = [0, 1, 2, 3, 4, 5];
|
||||
const pageTitle = computed(() => (route.name === "update-task" ? "更新学习任务" : "创建学习任务"));
|
||||
const pageSubtitle = computed(() =>
|
||||
route.name === "update-task"
|
||||
? "修改任务信息后保存,后续学习会话将使用最新内容"
|
||||
: "填写任务基本信息与优先级维度,帮助系统更好排序"
|
||||
);
|
||||
|
||||
const createTask = () => {
|
||||
request
|
||||
@@ -40,7 +34,7 @@ const createTask = () => {
|
||||
.then((result) => {
|
||||
if (result.code === 200) {
|
||||
ElMessage.success("创建任务成功");
|
||||
router.back();
|
||||
router.push({ name: "study" });
|
||||
} else {
|
||||
ElMessage.error("任务创建失败:" + result.message);
|
||||
}
|
||||
@@ -81,7 +75,7 @@ const updateTask = () => {
|
||||
.then((result) => {
|
||||
if (result.code === 200) {
|
||||
ElMessage.success("更新任务成功");
|
||||
router.back();
|
||||
router.push({ name: "study" });
|
||||
} else {
|
||||
ElMessage.error("任务更新失败:" + result.message);
|
||||
}
|
||||
@@ -90,7 +84,7 @@ const updateTask = () => {
|
||||
|
||||
const cancelTask = () => {
|
||||
ElMessage.info("已取消操作");
|
||||
router.back();
|
||||
router.push({ name: "study" });
|
||||
};
|
||||
|
||||
const submitTask = () => {
|
||||
@@ -126,11 +120,6 @@ const isMobile = computed(() => screenWidth.value <= 900);
|
||||
|
||||
<template>
|
||||
<section class="task-form-page">
|
||||
<header class="surface-card form-header">
|
||||
<h1 class="page-title">{{ pageTitle }}</h1>
|
||||
<p class="page-subtitle">{{ pageSubtitle }}</p>
|
||||
</header>
|
||||
|
||||
<el-form label-position="top" class="surface-card form-shell">
|
||||
<div class="group">
|
||||
<h3>基础信息</h3>
|
||||
@@ -195,10 +184,6 @@ const isMobile = computed(() => screenWidth.value <= 900);
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
padding: 20px 22px;
|
||||
}
|
||||
|
||||
.form-shell {
|
||||
padding: 22px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user