feat: TaskForm 应用场景链接标题抓取
- 导入 getUrlTitle 替代直连 lpt-ai - 新增 appUrlTitles 缓存映射 - loadApplications 中并行抓取应用场景 URL 标题 - 模板中应用场景链接显示标题而非裸 URL
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
updateTaskApplication,
|
||||
type TaskApplication,
|
||||
} from "@/api/tasks";
|
||||
import { getUrlTitle } from "@/utils/fetchTitle";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -38,6 +39,7 @@ const applicationStatusOptions: { label: string; value: TaskApplication["status"
|
||||
];
|
||||
|
||||
const applications = ref<TaskApplication[]>([]);
|
||||
const appUrlTitles = ref<Record<number, string>>({});
|
||||
const applicationLoading = ref(false);
|
||||
const applicationSaving = ref(false);
|
||||
const editingApplicationId = ref<number | null>(null);
|
||||
@@ -68,6 +70,15 @@ const loadApplications = async (targetTaskNum: string) => {
|
||||
try {
|
||||
const res = await getTaskApplications(targetTaskNum);
|
||||
applications.value = res?.data || [];
|
||||
const map: Record<number, string> = {};
|
||||
await Promise.all(
|
||||
applications.value
|
||||
.filter((a) => a.resourceUrl)
|
||||
.map(async (a) => {
|
||||
map[a.id] = await getUrlTitle(a.resourceUrl!);
|
||||
})
|
||||
);
|
||||
appUrlTitles.value = map;
|
||||
} catch (error: any) {
|
||||
applications.value = [];
|
||||
ElMessage.error(error?.message || "应用场景加载失败");
|
||||
@@ -290,7 +301,7 @@ const isMobile = computed(() => screenWidth.value <= 900);
|
||||
</div>
|
||||
<p v-if="item.description">{{ item.description }}</p>
|
||||
<el-link v-if="item.resourceUrl" :href="item.resourceUrl" target="_blank" type="primary">
|
||||
{{ item.resourceUrl }}
|
||||
{{ appUrlTitles[item.id] || item.resourceUrl }}
|
||||
</el-link>
|
||||
<div class="application-actions">
|
||||
<el-button text type="primary" size="small" @click="editApplication(item)">编辑</el-button>
|
||||
|
||||
Reference in New Issue
Block a user