diff --git a/web/console/helpers/urlUtil.ts b/web/console/helpers/urlUtil.ts index e78546ebf4..cb547a1814 100644 --- a/web/console/helpers/urlUtil.ts +++ b/web/console/helpers/urlUtil.ts @@ -68,6 +68,7 @@ export const reduceK8sQueryString = ({ restfulPath?: string; }) => { const queryString = Object.entries(k8sQueryObj) + .filter(([_, value]) => value !== undefined) .map(([key, value]) => { // 也许value是object,即labelSelector 或者 fieldSelector value = isObject(value) diff --git a/web/console/src/modules/cluster/WebAPI/K8sResourceAPI.ts b/web/console/src/modules/cluster/WebAPI/K8sResourceAPI.ts index 2149e5c76c..bc0d29acd5 100644 --- a/web/console/src/modules/cluster/WebAPI/K8sResourceAPI.ts +++ b/web/console/src/modules/cluster/WebAPI/K8sResourceAPI.ts @@ -201,42 +201,27 @@ export async function fetchResourceList( // 如果是主动清空 或者 resourceInfo 为空,都不需要发请求 if (!isClearData && !isEmpty(resourceInfo)) { - let k8sUrl = ''; + let k8sUrl = reduceK8sRestfulPath({ + resourceInfo, + namespace, + specificName: isNeedSpecific ? specificName : '', + clusterId, + meshId, + extraResource + }); // 如果有搜索字段的话 - if (search) { - k8sUrl = reduceK8sRestfulPath({ - resourceInfo, - namespace, - specificName: isNeedSpecific ? search : '', - clusterId, - meshId, - extraResource - }); - } else { - k8sUrl = reduceK8sRestfulPath({ - resourceInfo, - namespace, - specificName: isNeedSpecific ? specificName : '', - clusterId, - meshId, - extraResource - }); - } - // 这里是去拼接,是否需要在k8s url后面拼接一些queryString - if (isContinue && !search) { + if (isContinue) { const { pageSize } = paging; - k8sQueryObj = JSON.parse( - JSON.stringify( - Object.assign( - { - limit: pageSize, - continue: continueToken ? continueToken : undefined, - labelSelector - }, - k8sQueryObj - ) - ) + + k8sQueryObj = Object.assign( + { + limit: pageSize, + continue: continueToken ? continueToken : undefined, + labelSelector, + fieldSelector: search ? `metadata.name=${search}` : undefined + }, + k8sQueryObj ); } diff --git a/web/console/src/modules/cluster/components/resource/resourceTableOperation/ResourceActionPanel.tsx b/web/console/src/modules/cluster/components/resource/resourceTableOperation/ResourceActionPanel.tsx index 6e01cbbaaf..82b302ff6c 100644 --- a/web/console/src/modules/cluster/components/resource/resourceTableOperation/ResourceActionPanel.tsx +++ b/web/console/src/modules/cluster/components/resource/resourceTableOperation/ResourceActionPanel.tsx @@ -360,8 +360,6 @@ export class ResourceActionPanel extends React.Component