解决tag加载的问题

This commit is contained in:
何童崇 2022-10-18 16:07:06 +08:00
parent a248611764
commit a73ea7338a
9 changed files with 2671 additions and 3674 deletions

6166
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ export const getBranch = async (id,owner)=>{
} }
// //
export const getTag = async (id,owner)=>{ export const getTag = async (id,owner)=>{
return (await axios.get(`/${owner}/${id}/tags.json`)).data; return (await axios.get(`/${owner}/${id}/tags.json`,{params:{only_name:true}})).data.tags;
} }
// hooks-web // hooks-web
export const getHooks = async (id,params)=>{ export const getHooks = async (id,params)=>{

View File

@ -14,10 +14,10 @@ export default (( props, { projectDetail }) => {
useEffect(() => { useEffect(() => {
if (projectsId) { if (projectsId) {
const url = `/${owner}/${projectsId}/tags.json`; const url = `/${owner}/${projectsId}/tags.json`;
axios.get(url).then((result) => { axios.get(url,{params:{page:1,limit:1000}}).then((result) => {
if (result) { if (result.data) {
setSpin(false); setSpin(false);
setData(result.data); setData(result.data.tags);
} }
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);

View File

@ -253,11 +253,11 @@ class Index extends Component {
newItem = ()=>{ newItem = ()=>{
return( return(
<ul> <ul>
<li> <li onClick={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目</CheckProfile> {/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目</CheckProfile> */}
</li> </li>
<li> <li onClick={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile> {/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile> */}
</li> </li>
</ul> </ul>
) )

View File

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import SubMenu from '../sub/SubMenu'; import SubMenu from '../sub/SubMenu';
import { Table , Tooltip , Spin } from 'antd'; import { Table, Tooltip, Spin,Pagination } from 'antd';
import axios from 'axios'; import axios from 'axios';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { truncateCommitId } from '../../common/util'; import { truncateCommitId } from '../../common/util';
@ -14,20 +14,29 @@ function Tags(props) {
const [source, setSource] = useState(undefined); const [source, setSource] = useState(undefined);
const [isSpin, setIsSpin] = useState(true); const [isSpin, setIsSpin] = useState(true);
const [page, setPage] = useState(1);
const [total,setTotal] =useState(0);
const [limit,setLimit] =useState(10);
const { projectsId, owner } = props.match.params; const { projectsId, owner } = props.match.params;
useEffect(() => { useEffect(() => {
if (projectsId) { if (projectsId) {
setIsSpin(true);
const url = `/${owner}/${projectsId}/tags.json`; const url = `/${owner}/${projectsId}/tags.json`;
axios.get(url).then((result) => { axios.get(url, {
params: {
limit,
page: page
}
}).then((result) => {
if (result) { if (result) {
setSource(result.data); setSource(result.data.tags);
setTotal(result.data.total_count);
setIsSpin(false); setIsSpin(false);
} }
}).catch(error => { }) }).catch(error => { })
} }
}, [owner, projectsId]); }, [owner, projectsId,page]);
const columns = [ const columns = [
{ {
@ -116,6 +125,8 @@ function Tags(props) {
} }
} }
] ]
return ( return (
<div> <div>
<SubMenu tab={"tags"} projectsId={projectsId} owner={owner} /> <SubMenu tab={"tags"} projectsId={projectsId} owner={owner} />
@ -124,9 +135,23 @@ function Tags(props) {
{ {
source && source.length > 0 && source && source.length > 0 &&
<Table <Table
rowKey={(record) => record.id}
className="tagTable" className="tagTable"
dataSource={source} columns={columns} pagination={false}></Table> dataSource={source} columns={columns} pagination={false}></Table>
} }
{total > limit ? (
<div className="mt30 mb50 edu-txt-center">
<Pagination
simple
current={page}
total={total}
pageSize={limit}
onChange={(e)=>{setPage(e)}}
></Pagination>
</div>
) : (
""
)}
{ {
source && source.length === 0 && <Nonedata _html={'暂无数据~'} /> source && source.length === 0 && <Nonedata _html={'暂无数据~'} />
} }

View File

@ -61,12 +61,12 @@ export default Form.create()(
const url = `/${owner}/${projectsId}/tags.json`; const url = `/${owner}/${projectsId}/tags.json`;
axios axios
.get(url,{params:{ .get(url,{params:{
limit:1000 page:1,limit:1000
}}) }})
.then(result => { .then(result => {
if (result) { if (result.data) {
setTagList(result.data); setTagList(result.data.tags);
setOptions(renderTagList(result.data)); setOptions(renderTagList(result.data.tags));
} }
}) })
.catch(error => { .catch(error => {

View File

@ -61,11 +61,11 @@ function List(props){
) )
const menu_new=( const menu_new=(
<ul> <ul>
<li> <li onClick={()=>{this.props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建项目
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建项目</CheckProfile> {/* <CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/deposit/new/${OIdentifier}`)}}>新建项目</CheckProfile> */}
</li> </li>
<li> <li onClick={()=>{this.props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>导入项目
<CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>导入项目</CheckProfile> {/* <CheckProfile {...props} sureFunc={()=>{props.history.push(`/projects/mirror/new/${OIdentifier}`)}}>导入项目</CheckProfile> */}
</li> </li>
</ul> </ul>
) )

View File

@ -115,12 +115,18 @@ class InfosUser extends Component {
newItem =()=> ( newItem =()=> (
<ul> <ul>
<li> <li onClick={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目
{/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}}>新建项目</CheckProfile> */}
</li>
<li onClick={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目
{/* <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile> */}
</li>
{/* <li>
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}} >新建项目</CheckProfile> <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/deposit/new')}} >新建项目</CheckProfile>
</li> </li>
<li> <li>
<CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile> <CheckProfile {...this.props} sureFunc={()=>{this.props.history.push('/projects/mirror/new')}}>导入项目</CheckProfile>
</li> </li> */}
</ul> </ul>
); );