From 39bf6b742683bf27e9b112ce49a74a91e20e5522 Mon Sep 17 00:00:00 2001 From: developer Date: Sun, 12 Jul 2026 13:47:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Study=20=E9=A1=B5=E9=9D=A2=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=9C=BA=E6=99=AF=E9=93=BE=E6=8E=A5=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E6=8A=93=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 替换 fetchTitles 导入为 getUrlTitle - 新增 appUrlTitles 响应式映射缓存 - loadTaskApplications 中并行抓取应用场景 URL 标题 - 模板中应用场景链接显示抓取到的标题 - 移除旧的 loadUrlTitles 调用逻辑 --- src/components/Study.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/Study.vue b/src/components/Study.vue index e074d41..6ca419d 100644 --- a/src/components/Study.vue +++ b/src/components/Study.vue @@ -5,6 +5,7 @@ import router from "@/router"; import { ElMessage, ElMessageBox } from "element-plus"; import { getReviewTaskStatsByTask } from "@/api/review"; import { getActiveSession } from "@/api/studySessions"; + import { getPriorityWeights, getTaskApplications, @@ -13,7 +14,7 @@ import { type PriorityWeights, type TaskApplication, } from "@/api/tasks"; -import { fetchTitles } from "@/utils/fetchTitle"; +import { getUrlTitle } from "@/utils/fetchTitle"; interface TaskItem { title: string; @@ -39,6 +40,7 @@ const selectedTaskId = ref(null); const loading = ref(false); const taskApplications = ref([]); const applicationsLoading = ref(false); +const appUrlTitles = ref>({}); const applicationStatusOptions: { label: string; value: TaskApplication["status"] }[] = [ { label: "待应用", value: "TODO" }, @@ -97,6 +99,15 @@ async function loadTaskApplications(taskNum: string) { try { const res = await getTaskApplications(taskNum); taskApplications.value = res?.data || []; + const map: Record = {}; + await Promise.all( + taskApplications.value + .filter((a) => a.resourceUrl) + .map(async (a) => { + map[a.id] = await getUrlTitle(a.resourceUrl!); + }) + ); + appUrlTitles.value = map; } catch (error: any) { taskApplications.value = []; ElMessage.error(error?.message || "应用场景加载失败"); @@ -168,10 +179,8 @@ watch(selectedTaskId, (newId) => { if (task) { loadTaskStats(task.taskNum); loadTaskApplications(task.taskNum); - loadUrlTitles(); } else { taskApplications.value = []; - urlTitles.value = []; } }); @@ -409,7 +418,7 @@ onMounted(() => {

{{ item.description }}

- {{ item.resourceUrl }} + {{ appUrlTitles[item.id] || item.resourceUrl }}