Skip to content

Commit 75c588c

Browse files
authored
fix: Update cloud product categories (#136)
* fix: 云产品分类更新 * fix: 云产品分类更新
1 parent a279675 commit 75c588c

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

media/src/components/APIPage/API.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export const API: React.FC<APIProps> = (props) => {
229229
}, []);
230230

231231
return (
232-
<div className="bg-[var(--vscode-textBlockQuote-background)] pb-4" ref={pageEl}>
232+
<div className="h-full bg-[var(--vscode-textBlockQuote-background)] pb-4" ref={pageEl}>
233233
{/* */}
234234
<APIPageContext.Provider
235235
initialState={{

media/src/components/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const App: React.FC<AppProps> = (props) => {
8080
) : null;
8181

8282
return (
83-
<div className="w-full">
83+
<div className="h-[100vh] w-full">
8484
<APIPage
8585
selectedApi={selectedApi}
8686
product={popcode}

src/explorer.ts

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,27 @@ export class PontAPITreeItem extends vscode.TreeItem {
2222
}
2323

2424
export class PontAPIExplorer {
25-
static getProductItems(products: Array<Product>, element: PontAPITreeItem = null) {
26-
return products?.map((product) => {
25+
static getProductItems(element = null) {
26+
if (element.contextValue === "productGroup2") {
27+
const productGroups = _.groupBy(element.children, (item) => {
28+
if (item?.categoryName?.length) {
29+
return item.categoryName;
30+
} else {
31+
return "其他";
32+
}
33+
});
34+
return Object.keys(productGroups || {})?.map((group) => {
35+
return {
36+
specName: group,
37+
contextValue: "productGroup",
38+
label: `${group}`,
39+
modName: group,
40+
children: productGroups[group],
41+
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
42+
};
43+
});
44+
}
45+
return element.children?.map((product) => {
2746
return {
2847
specName: product.code,
2948
modName: "",
@@ -243,13 +262,20 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
243262
getAPIManagerChildren(element?: PontAPITreeItem): vscode.ProviderResult<PontAPITreeItem[]> {
244263
if (element.contextValue === "alicloudProducts") {
245264
const productExplorer = getProductRequestInstance();
246-
const productGroups = _.groupBy(productExplorer?.products, (product) => product.group);
265+
const productGroups = _.groupBy(productExplorer?.products, (product) => {
266+
if (product?.category2Name?.length) {
267+
return product.category2Name;
268+
} else {
269+
return "其他";
270+
}
271+
});
247272
return Object.keys(productGroups || {})?.map((group) => {
248273
return {
249274
specName: group,
250-
contextValue: "productGroup",
275+
contextValue: "productGroup2",
251276
label: `${group}`,
252277
modName: group,
278+
children: productGroups[group],
253279
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
254280
};
255281
});
@@ -311,10 +337,10 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
311337
});
312338
} else if (element.contextValue === "Dir" && spec) {
313339
return PontAPIExplorer.getDirItems(spec, element);
314-
} else if (element.contextValue === "productGroup") {
340+
} else if (element.contextValue === "productGroup" || element.contextValue === "productGroup2") {
315341
const productExplorer = getProductRequestInstance();
316-
const productGroups = _.groupBy(productExplorer?.products, (product) => product.group);
317-
return PontAPIExplorer.getProductItems(productGroups[element?.modName?.toString()], element);
342+
// const productGroups = _.groupBy(productExplorer?.products, (product) => product.category2Name);
343+
return PontAPIExplorer.getProductItems(element);
318344
} else {
319345
return PontAPIExplorer.getDirItems(spec);
320346
}
@@ -349,7 +375,9 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
349375
getSpecInfoFromName(item.name || "").version === version,
350376
)?.length
351377
) {
352-
vscode.window.showInformationMessage("该产品及其版本号已订阅,您可以使用 cmd + ctrl + l 来搜索该产品下的API。");
378+
vscode.window.showInformationMessage(
379+
"该产品及其版本号已订阅,您可以使用「mac: ctrl+cmd+l」,「win: ctrl+alt+l」来搜索该产品下的API。",
380+
);
353381
} else {
354382
pontxConfig.origins = [
355383
...(pontxConfig.origins || []),

src/types.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
export declare class Product {
2-
code: string;
3-
name: string;
4-
description: string;
5-
shortName: string;
6-
group: string;
7-
style: string;
8-
versions: Array<string>;
9-
defaultVersion: string;
10-
}
2+
code: string;
3+
name: string;
4+
description: string;
5+
shortName: string;
6+
group: string;
7+
style: string;
8+
versions: Array<string>;
9+
defaultVersion: string;
10+
categoryName: string;
11+
category2Name: string;
12+
}

0 commit comments

Comments
 (0)