diff --git a/src/forge/Issues/Component/comments/list.jsx b/src/forge/Issues/Component/comments/list.jsx index 416deadf..d78eb46d 100644 --- a/src/forge/Issues/Component/comments/list.jsx +++ b/src/forge/Issues/Component/comments/list.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Button, Popconfirm, Radio, Input, message, Tooltip, Spin } from 'antd'; +import { Button, Popconfirm, Radio, Input, message, Tooltip, Spin, Pagination } from 'antd'; import axios from 'axios'; import { getImageUrl, timeAgo } from 'educoder'; import RenderHtml from '../../../../components/render-html'; @@ -27,6 +27,10 @@ function IssueCommentList(props){ const [spin, setSpin] = useState(false); // issue 评论总数 const [journalsCount, setJournalsCount] = useState(undefined); + // 分页 + const limit = 50; + const [page, setPage] = useState(1); + const [totalCount, setTotalCount] = useState(undefined); // 操作记录 icon const journalsIcon ={ 'issue': 'icon-chuangjianqianbao', @@ -46,10 +50,12 @@ function IssueCommentList(props){ useEffect(()=>{ setSpin(true); axios.get(`/v1/${owner}/${projectsId}/issues/${index}/journals`,{params:{ - category + category, + page, + limit }}).then(res=>{ if(res && res.data){ - const {journals, total_comment_journals_count} = res.data; + const {journals, total_comment_journals_count, total_count} = res.data; if(category === 'all'){ const array = []; let start = undefined; @@ -74,12 +80,13 @@ function IssueCommentList(props){ } }) } + setTotalCount(total_count); setJournalsCount(total_comment_journals_count); setJournals(journals); setSpin(false) } }) - }, [reload, category]) + }, [reload, category, page]) function commentCtx(v){ return ; @@ -104,7 +111,7 @@ function IssueCommentList(props){
{/* 全部 / 评论 / 操作日志 */}
- {setSpin(true);setCategory(e.target.value)}} value={category}> + {setSpin(true);setPage(1);setCategory(e.target.value)}} value={category}> 评论{journalsCount} 操作日志 全部 @@ -130,15 +137,15 @@ function IssueCommentList(props){ {journals && (journals.length > 0 && journals.map(item=>{return item.is_journal_detail ? (!item.closeAndSpan || item.id === item.start || open === item.start) ?
{/* 操作日志 */}
-
+
-
+
{item.user.name}  {(item.user.name.length + item.operate_content.length) > 62 ? {item.user.name}
}> : }
- {timeAgo(item.created_at)} + {timeAgo(item.created_at)}
{(item.closeAndSpan && item.id === item.start) && {setOpen(open === item.id ? undefined : item.id)}}>{open === item.id ? `点击收起操作日志` : `已折叠${item.numCount}条, 点击查看`}}
@@ -153,7 +160,7 @@ function IssueCommentList(props){
{item.user.name} - {timeAgo(item.created_at)} + {timeAgo(item.created_at)}
{login &&
{/* 平台管理员/仓库管理员/发布评论者/issue创建者 */} @@ -167,8 +174,8 @@ function IssueCommentList(props){ } {/* 仅评论者可修改 */} - {login === item.user.login && } - {setParentId(item.id); setReplyId(item.id); setShowEdit(3)}}> + {login === item.user.login && } + {setParentId(item.id); setReplyId(item.id); setShowEdit(3)}}>
}
{commentCtx(item.notes)}
@@ -189,7 +196,7 @@ function IssueCommentList(props){ {i.user.name} {i.reply_user && 回复} {i.reply_user && i.reply_user.name} - {timeAgo(i.created_at)} + {timeAgo(i.created_at)}
{login &&
{/* 平台管理员/仓库管理员/发布评论者/回复评论者/issue创建者 */} @@ -203,9 +210,9 @@ function IssueCommentList(props){ } {/* 仅回复评论者可修改 */} - {login === i.user.login && } + {login === i.user.login && } {setParentId(item.id);setReplyId(i.id); setShowEdit(5)}}> - +
}
@@ -222,6 +229,9 @@ function IssueCommentList(props){
}))}
+ {totalCount>limit &&
+ setPage(page)}/> +
} {/* 无数据 */} {journals && !journals.length && } diff --git a/src/forge/Issues/Component/comments/list.scss b/src/forge/Issues/Component/comments/list.scss index 69fd1cbf..d614d409 100644 --- a/src/forge/Issues/Component/comments/list.scss +++ b/src/forge/Issues/Component/comments/list.scss @@ -189,4 +189,7 @@ width: 100%; height: 30px; border: none; +} +.paginationIssueComment{ + text-align: center; } \ No newline at end of file diff --git a/src/forge/New/Index.js b/src/forge/New/Index.js index c307a8be..947634bd 100644 --- a/src/forge/New/Index.js +++ b/src/forge/New/Index.js @@ -220,7 +220,7 @@ class Index extends Component { user_id:owners_id, blockchain: tokenConTri, blockchain_token_all: 10000, - blockchain_init_token: blockchain_init && blockchain_init/100 + blockchain_init_token: parseInt(blockchain_init) }).then((result) => { if (result && result.data.id) { projectsType && projectsType !== "mirror" && this.props.showNotification(`项目创建成功!`); @@ -651,7 +651,9 @@ class Index extends Component { required: tokenConTri, message: '初始token值为一个不超过10000的正整数' }, { validator: (rule,val,callback) =>{ - if(val>10000){ + if(!/^[1-9]+[0-9]*]*$/.test(val)){ + callback('初始token值为正整数'); + }if(val>10000){ callback('初始token值最大值10000'); }else{ callback(); diff --git a/src/forge/users/Material/Phone.jsx b/src/forge/users/Material/Phone.jsx index bc355542..3e9d04fb 100644 --- a/src/forge/users/Material/Phone.jsx +++ b/src/forge/users/Material/Phone.jsx @@ -20,7 +20,7 @@ export default Form.create()( function checkPsd(rule, value, callback){ const map = passMap; if(value){ - current_user && value.length > 8 && Axios.post(`/v1/${current_user.login}/check_password.json`,{ + current_user && value.length > 7 && Axios.post(`/v1/${current_user.login}/check_password.json`,{ password: value }).then(res=>{ if(res && !res.data.status){ diff --git a/src/forge/users/contribution/index.jsx b/src/forge/users/contribution/index.jsx index 3fd80e11..0bafa286 100644 --- a/src/forge/users/contribution/index.jsx +++ b/src/forge/users/contribution/index.jsx @@ -12,8 +12,7 @@ import { FlexAJ } from '../../Component/layout'; // 个人中心-贡献确权 function Contribution(props){ - // 接口暂不支持分页 - const limit = 15; + const limit = 10; const [page, setPage] = useState(1); const [total, setTotal] = useState(undefined); // 转账列表 @@ -29,19 +28,42 @@ function Contribution(props){ const [error2, setError2] = useState(undefined); // 操作仓库id const [proId, setProId] = useState(undefined); - const { checkIfLogin , showLoginDialog , current_user:{user_id, login}, current_user } = props; - console.log('current_user', current_user); + const {current_user:{user_id, login, open_blockchain}, current_user} = props; const {user} = props; + const username = props.match.params.username; + + useEffect(()=>{ + if((username && current_user && (current_user.login !== username)) || !open_blockchain){ + props.history.push(`/${username}`); + } + },[current_user,username]) useEffect(()=>{ // token转账列表 - axios.get(`/users/blockchain/balance.json`,{params: {user_id}}).then(res=>{ + axios.get(`/users/blockchain/balance.json`,{params: { + user_id, + limit, + page + }}).then(res=>{ if(res && res.data){ - setList(res.data.projects); + const {projects} = res.data; + const newProjects = []; + let deleteProjectCount = 0; + projects.map(item=>{ + if(item.id){ + newProjects.unshift(item); + }else{ + deleteProjectCount++; + } + }) + deleteProjectCount && newProjects.push({ + 'balance': deleteProjectCount + }) + setList(newProjects); setTotal(res.data.total_count); } }) - }, [reload]) + }, [reload, page]) useEffect(()=>{ if(user){ @@ -53,14 +75,15 @@ function Contribution(props){ // 目标转账用户 function getUser(id, login){ - const userLoginObject = Object.assign(userLogin); + // 使用JSON进行对象深拷贝 + const userLoginObject = JSON.parse(JSON.stringify(userLogin)); userLoginObject[id] = login; setUserLogin(userLoginObject); } // token转账值 function setToken(id, token){ - const tokenCountObject = Object.assign(tokenCount); + const tokenCountObject = JSON.parse(JSON.stringify(tokenCount)); tokenCountObject[id] = token; setTokenCount(tokenCountObject); } @@ -80,7 +103,6 @@ function Contribution(props){ }else if(!/^[1-9]+[0-9]*]*$/.test(tokenCountById) || tokenCountById>max){ setError2('转账token数额必须为不超过token总数的正整数'); }else{ - console.log('userLogin', userLoginById, 'tokenCount', tokenCountById); axios.post(`/users/blockchain/transfer`, { owner_login: login, project_identifier: identifier, @@ -90,8 +112,9 @@ function Contribution(props){ payer_id: user_id, project_id: id }).then(res=>{ - console.log('res', res); if(res && res.data && res.data.status === 2){ + getUser(id, undefined); + setToken(id, undefined); setReload(Math.random()); message.success('转账成功'); } @@ -115,19 +138,19 @@ function Contribution(props){
操作
} {list && !list.length && } - {list && list.map(item=>{return
+ {list && list.map(item=>{return item.id ?
{item.name}
{item.balance}
- {getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户"/> + {getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户" value={userLogin[item.id]}/> {proId === item.id && error1 &&
{error1}
}
- {setToken(item.id, e.target.value)}} placeholder='请输入token数额'/> + {setToken(item.id, e.target.value)}} placeholder='请输入token数额'/> {proId === item.id && error2 &&
{error2}
}
-
})} +
:
{item.balance}个项目被删除
})} :
蒋宇航GilLink/确实开源给你转账了1000个tiken @@ -138,9 +161,9 @@ function Contribution(props){ 6小时前
} - {/* {total > limit &&
+ {total > limit &&
setPage(page)}/> -
} */} +
} ) } diff --git a/src/forge/users/contribution/index.scss b/src/forge/users/contribution/index.scss index ba3ee58a..d9eb51e8 100644 --- a/src/forge/users/contribution/index.scss +++ b/src/forge/users/contribution/index.scss @@ -40,14 +40,17 @@ padding: 15px 0; border-bottom: 1px solid #eee; } + .deleteRepo{ + color: slategrey; + } .tableColumn3, .tableColumn4{ - width: 200px; + width: 150px; } .tableColumn1{ - width: 130px; + width: 200px; } .tableColumn5{ - width: 120px; + width: 100px; text-align: center; } .tableColumn2{