From 0d67ec11e9d562b383c01aedd46b46b852883df3 Mon Sep 17 00:00:00 2001 From: yini-chen Date: Tue, 27 Aug 2024 19:37:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BA=91=E4=BA=A7=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- media/src/components/APIPage/API.tsx | 2 +- media/src/components/main.tsx | 2 +- src/explorer.ts | 53 +++++++++++++++++++++++----- src/types.ts | 20 ++++++----- 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/media/src/components/APIPage/API.tsx b/media/src/components/APIPage/API.tsx index 1c9e487..fe36ca7 100644 --- a/media/src/components/APIPage/API.tsx +++ b/media/src/components/APIPage/API.tsx @@ -229,7 +229,7 @@ export const API: React.FC = (props) => { }, []); return ( -
+
{/* */} = (props) => { ) : null; return ( -
+
, element: PontAPITreeItem = null) { - return products?.map((product) => { + static getProductItems(element = null) { + if (element.contextValue === "productGroup2") { + const productGroups = _.groupBy(element.children, (item) => { + if (item?.categoryName?.length) { + return item.categoryName; + } else { + return "其他"; + } + }); + return Object.keys(productGroups || {})?.map((group) => { + return { + specName: group, + contextValue: "productGroup", + label: `${group}`, + modName: group, + children: productGroups[group], + collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, + }; + }); + } + return element.children?.map((product) => { return { specName: product.code, modName: "", @@ -243,13 +262,20 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider { if (element.contextValue === "alicloudProducts") { const productExplorer = getProductRequestInstance(); - const productGroups = _.groupBy(productExplorer?.products, (product) => product.group); + const productGroups = _.groupBy(productExplorer?.products, (product) => { + if (product?.category2Name?.length) { + return product.category2Name; + } else { + return "其他"; + } + }); return Object.keys(productGroups || {})?.map((group) => { return { specName: group, - contextValue: "productGroup", + contextValue: "productGroup2", label: `${group}`, modName: group, + children: productGroups[group], collapsibleState: vscode.TreeItemCollapsibleState.Collapsed, }; }); @@ -311,10 +337,19 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider item.category2Name === element.modName), + // (product) => product.categoryName, + // ); + // return this.getAPIManagerChildren(element); + // } + else if (element.contextValue === "productGroup" || element.contextValue === "productGroup2") { const productExplorer = getProductRequestInstance(); - const productGroups = _.groupBy(productExplorer?.products, (product) => product.group); - return PontAPIExplorer.getProductItems(productGroups[element?.modName?.toString()], element); + // const productGroups = _.groupBy(productExplorer?.products, (product) => product.category2Name); + return PontAPIExplorer.getProductItems(element); } else { return PontAPIExplorer.getDirItems(spec); } @@ -349,7 +384,9 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider; - defaultVersion: string; -} \ No newline at end of file + code: string; + name: string; + description: string; + shortName: string; + group: string; + style: string; + versions: Array; + defaultVersion: string; + categoryName: string; + category2Name: string; +} From b0ecb43493db0342e5e6f479ec838598124a9c61 Mon Sep 17 00:00:00 2001 From: yini-chen Date: Tue, 27 Aug 2024 19:39:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BA=91=E4=BA=A7=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/explorer.ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/explorer.ts b/src/explorer.ts index 7e2ff8f..3ebb5c1 100644 --- a/src/explorer.ts +++ b/src/explorer.ts @@ -337,16 +337,7 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider item.category2Name === element.modName), - // (product) => product.categoryName, - // ); - // return this.getAPIManagerChildren(element); - // } - else if (element.contextValue === "productGroup" || element.contextValue === "productGroup2") { + } else if (element.contextValue === "productGroup" || element.contextValue === "productGroup2") { const productExplorer = getProductRequestInstance(); // const productGroups = _.groupBy(productExplorer?.products, (product) => product.category2Name); return PontAPIExplorer.getProductItems(element);