|
|
@@ -54,6 +54,7 @@ function MirrorList() { |
|
|
const [cacheState, setCacheState] = useCacheState(); |
|
|
const [cacheState, setCacheState] = useCacheState(); |
|
|
const [activeTab, setActiveTab] = useState<string>(cacheState?.activeTab ?? CommonTabKeys.Public); |
|
|
const [activeTab, setActiveTab] = useState<string>(cacheState?.activeTab ?? CommonTabKeys.Public); |
|
|
const [searchText, setSearchText] = useState(cacheState?.searchText); |
|
|
const [searchText, setSearchText] = useState(cacheState?.searchText); |
|
|
|
|
|
const [inputText, setInputText] = useState(cacheState?.searchText); |
|
|
const [tableData, setTableData] = useState<MirrorData[]>([]); |
|
|
const [tableData, setTableData] = useState<MirrorData[]>([]); |
|
|
const [total, setTotal] = useState(0); |
|
|
const [total, setTotal] = useState(0); |
|
|
const [pagination, setPagination] = useState<TablePaginationConfig>( |
|
|
const [pagination, setPagination] = useState<TablePaginationConfig>( |
|
|
@@ -65,11 +66,12 @@ function MirrorList() { |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
getMirrorList(); |
|
|
getMirrorList(); |
|
|
}, [activeTab, pagination]); |
|
|
|
|
|
|
|
|
}, [activeTab, pagination, searchText]); |
|
|
|
|
|
|
|
|
// 切换 Tab,重置数据 |
|
|
// 切换 Tab,重置数据 |
|
|
const hanleTabChange: TabsProps['onChange'] = (value) => { |
|
|
const hanleTabChange: TabsProps['onChange'] = (value) => { |
|
|
setSearchText(''); |
|
|
setSearchText(''); |
|
|
|
|
|
setInputText(''); |
|
|
setPagination({ |
|
|
setPagination({ |
|
|
current: 1, |
|
|
current: 1, |
|
|
pageSize: 10, |
|
|
pageSize: 10, |
|
|
@@ -78,16 +80,16 @@ function MirrorList() { |
|
|
setTableData([]); |
|
|
setTableData([]); |
|
|
setActiveTab(value); |
|
|
setActiveTab(value); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 获取镜像列表 |
|
|
// 获取镜像列表 |
|
|
const getMirrorList = async (params?: Record<string, any>) => { |
|
|
|
|
|
const reqParams = { |
|
|
|
|
|
|
|
|
const getMirrorList = async () => { |
|
|
|
|
|
const params: Record<string, any> = { |
|
|
page: pagination.current! - 1, |
|
|
page: pagination.current! - 1, |
|
|
size: pagination.pageSize, |
|
|
size: pagination.pageSize, |
|
|
name: searchText, |
|
|
name: searchText, |
|
|
image_type: activeTab === CommonTabKeys.Public ? 1 : 0, |
|
|
image_type: activeTab === CommonTabKeys.Public ? 1 : 0, |
|
|
...params, |
|
|
|
|
|
}; |
|
|
}; |
|
|
const [res] = await to(getMirrorListReq(reqParams)); |
|
|
|
|
|
|
|
|
const [res] = await to(getMirrorListReq(params)); |
|
|
if (res && res.data) { |
|
|
if (res && res.data) { |
|
|
const { content = [], totalElements = 0 } = res.data; |
|
|
const { content = [], totalElements = 0 } = res.data; |
|
|
setTableData(content); |
|
|
setTableData(content); |
|
|
@@ -116,10 +118,7 @@ function MirrorList() { |
|
|
|
|
|
|
|
|
// 搜索 |
|
|
// 搜索 |
|
|
const onSearch: SearchProps['onSearch'] = (value) => { |
|
|
const onSearch: SearchProps['onSearch'] = (value) => { |
|
|
// 带参数是为了点清除时,searchText 更新不及时的问题 |
|
|
|
|
|
getMirrorList({ |
|
|
|
|
|
name: value, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
setSearchText(value); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
// 查看详情 |
|
|
// 查看详情 |
|
|
@@ -241,9 +240,9 @@ function MirrorList() { |
|
|
placeholder="按数据集名称筛选" |
|
|
placeholder="按数据集名称筛选" |
|
|
allowClear |
|
|
allowClear |
|
|
onSearch={onSearch} |
|
|
onSearch={onSearch} |
|
|
onChange={(e) => setSearchText(e.target.value)} |
|
|
|
|
|
|
|
|
onChange={(e) => setInputText(e.target.value)} |
|
|
style={{ width: 300 }} |
|
|
style={{ width: 300 }} |
|
|
value={searchText} |
|
|
|
|
|
|
|
|
value={inputText} |
|
|
/> |
|
|
/> |
|
|
{activeTab === CommonTabKeys.Private && ( |
|
|
{activeTab === CommonTabKeys.Private && ( |
|
|
<Button |
|
|
<Button |
|
|
|