|
|
@@ -269,7 +269,7 @@
|
|
|
<template v-else>
|
|
|
<div v-if="requiredParams.length" class="otp-param-required-box">
|
|
|
<div
|
|
|
- v-for="(param, paramIndex) in requiredParams"
|
|
|
+ v-for="param in requiredParams"
|
|
|
:key="param.name"
|
|
|
class="otp-param-required-item"
|
|
|
>
|
|
|
@@ -286,13 +286,13 @@
|
|
|
:placeholder="param.placeholder || param.desc"
|
|
|
/>
|
|
|
<div
|
|
|
- v-if="paramIndex === 0 && displayRecommendQuestions.length"
|
|
|
+ v-if="getDisplayRecommendQuestions(param).length"
|
|
|
class="otp-recommend"
|
|
|
>
|
|
|
<div class="otp-recommend-main">
|
|
|
<span class="otp-recommend-label">推荐问题:</span>
|
|
|
<button
|
|
|
- v-for="(question, qIndex) in displayRecommendQuestions"
|
|
|
+ v-for="(question, qIndex) in getDisplayRecommendQuestions(param)"
|
|
|
:key="`${recommendPageIndex}-${qIndex}`"
|
|
|
type="button"
|
|
|
class="otp-recommend-chip"
|
|
|
@@ -592,11 +592,10 @@ const requestParams = ref([]);
|
|
|
const responseStructure = ref([]);
|
|
|
const paramTab = ref("request");
|
|
|
const jsonMode = ref(false);
|
|
|
-/** 推荐问题:后续接接口填充,暂无数据则不展示 */
|
|
|
-const recommendQuestionPool = ref([]);
|
|
|
+/** 推荐问题来自 /mcp/tool/{id} 的 reqParams.recommendQuestionList,每次展示 2 条 */
|
|
|
const recommendPageIndex = ref(0);
|
|
|
-const displayRecommendQuestions = computed(() => {
|
|
|
- const pool = recommendQuestionPool.value;
|
|
|
+const getDisplayRecommendQuestions = (param) => {
|
|
|
+ const pool = Array.isArray(param?.recommendQuestions) ? param.recommendQuestions : [];
|
|
|
if (!pool.length) return [];
|
|
|
const pageSize = 2;
|
|
|
const start = (recommendPageIndex.value * pageSize) % pool.length;
|
|
|
@@ -605,7 +604,7 @@ const displayRecommendQuestions = computed(() => {
|
|
|
list.push(pool[(start + i) % pool.length]);
|
|
|
}
|
|
|
return list;
|
|
|
-});
|
|
|
+};
|
|
|
const refreshRecommendQuestions = () => {
|
|
|
recommendPageIndex.value += 1;
|
|
|
};
|
|
|
@@ -688,7 +687,6 @@ const resetTestState = () => {
|
|
|
requestParams.value = [];
|
|
|
responseStructure.value = [];
|
|
|
requestJsonText.value = "{}";
|
|
|
- recommendQuestionPool.value = [];
|
|
|
recommendPageIndex.value = 0;
|
|
|
searchResult.value = null;
|
|
|
resultMeta.value = { code: null, time: null, ok: false, label: "-" };
|
|
|
@@ -761,6 +759,10 @@ const mapReqFormParams = (reqParams) => {
|
|
|
desc: param.description || param.desc || "",
|
|
|
placeholder: param.description || param.desc || "",
|
|
|
value: "",
|
|
|
+ recommendQuestions:
|
|
|
+ Number(param.recommendStatus) === 1 && Array.isArray(param.recommendQuestionList)
|
|
|
+ ? param.recommendQuestionList.filter((item) => String(item || "").trim())
|
|
|
+ : [],
|
|
|
}));
|
|
|
};
|
|
|
|