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