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 }}