|
@@ -78,7 +78,7 @@
|
|
|
type="primary"
|
|
|
size="small"
|
|
|
@click="addApi(scope.row)"
|
|
|
- :disabled="isApiSelected(scope.row.key)">
|
|
|
+ :disabled="isApiSelected(scope.row)">
|
|
|
添加
|
|
|
</el-button>
|
|
|
</template>
|
|
@@ -367,7 +367,7 @@ const addSelectedApis = () => {
|
|
|
|
|
|
// 添加单个API
|
|
|
const addApi = (api: ApiInfo) => {
|
|
|
- if (isApiSelected(api.key)) {
|
|
|
+ if (isApiSelected(api)) {
|
|
|
ElMessage.warning('该API已添加');
|
|
|
return;
|
|
|
}
|
|
@@ -410,10 +410,14 @@ const removeAllSelected = async () => {
|
|
|
};
|
|
|
|
|
|
// 检查API是否已选中
|
|
|
-const isApiSelected = (key: string) => {
|
|
|
- // 查找是否有包含此key的API
|
|
|
- const api = selectedApis.value.find(api => api.key === key);
|
|
|
- return !!api;
|
|
|
+const isApiSelected = (api: ApiInfo) => {
|
|
|
+ // 获取API的apiKey或备选标识符
|
|
|
+ const apiIdentifier = api.apiKey || api.key || `${api.id}`;
|
|
|
+ // 遍历已选中的API数组,检查是否已存在相同的apiKey
|
|
|
+ return selectedApis.value.some(selectedApi => {
|
|
|
+ const selectedApiIdentifier = selectedApi.apiKey || selectedApi.key || `${selectedApi.id}`;
|
|
|
+ return apiIdentifier === selectedApiIdentifier;
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
// 搜索API
|