diff --git a/spug_web/src/pages/deploy/request/HostSelector.js b/spug_web/src/pages/deploy/request/HostSelector.js index 882d659..0dd4fbe 100644 --- a/spug_web/src/pages/deploy/request/HostSelector.js +++ b/spug_web/src/pages/deploy/request/HostSelector.js @@ -1,14 +1,19 @@ import React, { useState, useEffect } from 'react'; import { observer } from 'mobx-react'; -import { Modal, Table, Button, Alert } from 'antd'; +import {Modal, Table, Button, Alert, Spin, Space} from 'antd'; import hostStore from 'pages/host/store'; import lds from 'lodash'; export default observer(function (props) { const [selectedRowKeys, setSelectedRowKeys] = useState(props.host_ids || []); + const [isLoading, setIsLoading] = useState(true); useEffect(() => { - hostStore.initial() + // 增加异步逻辑,以修复页面在初次载入时主机列表弹框看不到主机信息的问题 + hostStore.initial().then(() => { + // 异步执行完后,去除 loading 状态 + setIsLoading(false) + }) }, []) function handleClickRow(record) { @@ -32,6 +37,26 @@ export default observer(function (props) { } } + // 若主机列表数据未加载完成,则返回 loading 状态 + if (isLoading) { + return ( + + + + + + ) + } + return (