feat: add pip modules when selecting custom_nodes

This commit is contained in:
bennykok 2024-01-26 17:02:55 +08:00
parent 78721b3129
commit 2bace09f5e

View File

@ -157,6 +157,7 @@ type CustomNodeList = {
author: string;
title: string;
reference: string;
pip: string[];
files: string[];
install_type: string;
description: string;
@ -237,13 +238,23 @@ function CustomNodesSelector({
key={index}
value={framework.reference}
onSelect={async (currentValue) => {
let nodeList: Record<
string,
{
hash: string;
disabled: boolean;
pip?: string[]
}
>;
const x = customNodeList;
if (x[currentValue]) {
const newNodeList = { ...x };
delete newNodeList[currentValue];
nodeList = newNodeList;
} else {
const repoName = extractRepoName(currentValue);
console.log(repoName);
const id = toast.loading(`Fetching repo info...`);
// toast.info("hi");
const repo = await fetch(
`https://api.github.com/repos/${repoName}`
)
@ -261,9 +272,7 @@ function CustomNodesSelector({
});
if (!repo) return;
const branch = repo.default_branch;
const branchInfo = await fetch(
`https://api.github.com/repos/${repoName}/branches/${branch}`
)
@ -282,24 +291,11 @@ function CustomNodesSelector({
if (!branchInfo) return;
let nodeList: Record<
string,
{
hash: string;
disabled: boolean;
}
>;
const x = customNodeList;
if (x[currentValue]) {
const newNodeList = { ...x };
delete newNodeList[currentValue];
nodeList = newNodeList;
} else {
nodeList = {
[currentValue]: {
hash: branchInfo?.commit.sha,
disabled: false,
pip: framework.pip
},
...x,
};