mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-01-02 23:38:22 +08:00
(feature)(webapp) modify model to view (#719)
This commit is contained in:
@@ -371,7 +371,7 @@ function getLeafNodes(treeNodes: any[]): any[] {
|
||||
return leafNodes;
|
||||
}
|
||||
|
||||
function buildTree(nodes: any[]): any[] {
|
||||
export function buildTree(nodes: any[]): any[] {
|
||||
const map: Record<number, any> = {};
|
||||
const roots: any[] = [];
|
||||
|
||||
@@ -400,6 +400,16 @@ export function getLeafList(flatNodes: any[]): any[] {
|
||||
return leafNodes;
|
||||
}
|
||||
|
||||
export function traverseTree(treeData: any[], callback: (node: any) => void) {
|
||||
treeData.forEach((node) => {
|
||||
callback(node);
|
||||
if (node.children?.length > 0) {
|
||||
traverseTree(node.children, callback);
|
||||
}
|
||||
});
|
||||
return treeData;
|
||||
}
|
||||
|
||||
export function traverseRoutes(routes, env: string, result: any[] = []) {
|
||||
if (!Array.isArray(routes)) {
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user