mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-09-01 07:07:14 +00:00
refactor: delete empty components
This commit is contained in:
@@ -9,7 +9,7 @@ import BotForm from '@/app/home/bots/components/bot-form/BotForm';
|
|||||||
import BotCard from '@/app/home/bots/components/bot-card/BotCard';
|
import BotCard from '@/app/home/bots/components/bot-card/BotCard';
|
||||||
import CreateCardComponent from '@/app/infra/basic-component/create-card-component/CreateCardComponent';
|
import CreateCardComponent from '@/app/infra/basic-component/create-card-component/CreateCardComponent';
|
||||||
import { httpClient } from '@/app/infra/http/HttpClient';
|
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||||
import { Bot, Adapter } from '@/app/infra/api/api-types';
|
import { Bot, Adapter } from '@/app/infra/entities/api';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -20,27 +20,14 @@ import {
|
|||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
|
|
||||||
export default function BotConfigPage() {
|
export default function BotConfigPage() {
|
||||||
const router = useRouter();
|
|
||||||
const [pageShowRule, setPageShowRule] = useState<BotConfigPageShowRule>(
|
|
||||||
BotConfigPageShowRule.NO_BOT,
|
|
||||||
);
|
|
||||||
const [modalOpen, setModalOpen] = useState<boolean>(false);
|
const [modalOpen, setModalOpen] = useState<boolean>(false);
|
||||||
const [botList, setBotList] = useState<BotCardVO[]>([]);
|
const [botList, setBotList] = useState<BotCardVO[]>([]);
|
||||||
const [isEditForm, setIsEditForm] = useState(false);
|
const [isEditForm, setIsEditForm] = useState(false);
|
||||||
const [nowSelectedBotCard, setNowSelectedBotCard] = useState<BotCardVO>();
|
const [nowSelectedBotCard, setNowSelectedBotCard] = useState<BotCardVO>();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// TODO:补齐加载转圈逻辑
|
// TODO:补齐加载转圈逻辑
|
||||||
setIsLoading(true);
|
|
||||||
checkHasLLM().then((hasLLM) => {
|
|
||||||
if (hasLLM) {
|
|
||||||
getBotList();
|
|
||||||
} else {
|
|
||||||
setPageShowRule(BotConfigPageShowRule.NO_LLM);
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
async function checkHasLLM(): Promise<boolean> {
|
async function checkHasLLM(): Promise<boolean> {
|
||||||
@@ -49,7 +36,6 @@ export default function BotConfigPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getBotList() {
|
async function getBotList() {
|
||||||
setIsLoading(true);
|
|
||||||
|
|
||||||
const adapterListResp = await httpClient.getAdapters();
|
const adapterListResp = await httpClient.getAdapters();
|
||||||
const adapterList = adapterListResp.adapters.map((adapter: Adapter) => {
|
const adapterList = adapterListResp.adapters.map((adapter: Adapter) => {
|
||||||
@@ -72,11 +58,6 @@ export default function BotConfigPage() {
|
|||||||
usePipelineName: bot.use_pipeline_name || '',
|
usePipelineName: bot.use_pipeline_name || '',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (botList.length === 0) {
|
|
||||||
setPageShowRule(BotConfigPageShowRule.NO_BOT);
|
|
||||||
} else {
|
|
||||||
setPageShowRule(BotConfigPageShowRule.HAVE_BOT);
|
|
||||||
}
|
|
||||||
setBotList(botList);
|
setBotList(botList);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -89,7 +70,7 @@ export default function BotConfigPage() {
|
|||||||
// });
|
// });
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsLoading(false);
|
// setIsLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +117,6 @@ export default function BotConfigPage() {
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{/* 注意:其余的返回内容需要保持在Spin组件外部 */}
|
{/* 注意:其余的返回内容需要保持在Spin组件外部 */}
|
||||||
{pageShowRule === BotConfigPageShowRule.HAVE_BOT && (
|
|
||||||
<div className={`${styles.botListContainer}`}>
|
<div className={`${styles.botListContainer}`}>
|
||||||
|
|
||||||
<CreateCardComponent
|
<CreateCardComponent
|
||||||
@@ -158,13 +138,6 @@ export default function BotConfigPage() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum BotConfigPageShowRule {
|
|
||||||
NO_LLM,
|
|
||||||
NO_BOT,
|
|
||||||
HAVE_BOT,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -98,8 +98,6 @@ export default function LLMConfigPage() {
|
|||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
{cardList.length > 0 && (
|
|
||||||
<div className={`${styles.modelListContainer}`}>
|
<div className={`${styles.modelListContainer}`}>
|
||||||
|
|
||||||
<CreateCardComponent
|
<CreateCardComponent
|
||||||
@@ -121,20 +119,6 @@ export default function LLMConfigPage() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{cardList.length === 0 && (
|
|
||||||
<div className={`${styles.emptyContainer}`}>
|
|
||||||
<EmptyAndCreateComponent
|
|
||||||
title={'模型列表空空如也~'}
|
|
||||||
subTitle={'快去创建一个吧!'}
|
|
||||||
buttonText={'创建模型 +'}
|
|
||||||
onButtonClick={() => {
|
|
||||||
handleCreateModelClick();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,8 +110,6 @@ export default function PluginConfigPage() {
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
|
||||||
{pipelineList.length > 0 && (
|
|
||||||
<div className={styles.pipelineListContainer}>
|
<div className={styles.pipelineListContainer}>
|
||||||
<CreateCardComponent
|
<CreateCardComponent
|
||||||
width={'24rem'}
|
width={'24rem'}
|
||||||
@@ -140,7 +138,6 @@ export default function PluginConfigPage() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user