fix: backend framework options

This commit is contained in:
jialin
2025-12-16 11:11:24 +08:00
parent fa42474612
commit 5225fd328d
23 changed files with 99 additions and 85 deletions
+20 -10
View File
@@ -12,9 +12,13 @@ import { DashboardProps } from './config/types';
const Dashboard: React.FC = () => {
const intl = useIntl();
const [loading, setLoading] = useState(false);
const [loadingStatus, setLoadingStatus] = useState({
loading: false,
loadend: false
});
const [data, setData] = useState<DashboardProps>({} as DashboardProps);
const { fetchAll, clusterList, workerList } = useClusterList();
const { fetchAll, clusterList, workerList, clustersAtom, workersAtom } =
useClusterList();
const { noResourceResult } = useNoResourceResult({
loadend: true,
@@ -47,16 +51,22 @@ const Dashboard: React.FC = () => {
const initData = useMemoizedFn(async () => {
try {
setLoading(true);
setLoadingStatus({
loading: true,
loadend: false
});
const { hasClusters, hasWorkers } = await fetchAll();
if (!hasClusters || !hasWorkers) {
setLoading(false);
return;
}
await fetchDashboardData();
setLoading(false);
} catch (error) {
setLoading(false);
// ignore
} finally {
setLoadingStatus({
loading: false,
loadend: true
});
}
});
@@ -69,11 +79,11 @@ const Dashboard: React.FC = () => {
value={{ ...data, fetchData: fetchDashboardData, clusterList }}
>
<PageBox>
<Spin spinning={loading} style={{ minHeight: 300 }}>
{(!clusterList.length || !workerList.length) && !loading ? (
noResourceResult
) : loading ? null : (
<Spin spinning={loadingStatus.loading} style={{ minHeight: 300 }}>
{workersAtom.length > 0 && clustersAtom.length > 0 ? (
<DashboardInner />
) : loadingStatus.loading || !loadingStatus.loadend ? null : (
noResourceResult
)}
</Spin>
</PageBox>