diff --git a/src/AppConfig.js b/src/AppConfig.js index 9ca6363a..cf7fe8b6 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -25,7 +25,7 @@ if (isDev) { } debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : - window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || '' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' } window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/src/forge/Issues/Pages/list.jsx b/src/forge/Issues/Pages/list.jsx index d0b6dc0f..e9c197f0 100644 --- a/src/forge/Issues/Pages/list.jsx +++ b/src/forge/Issues/Pages/list.jsx @@ -45,7 +45,7 @@ function List(props){ const owner = props.match.params.owner; const projectsId = props.match.params.projectsId; const permission = props && props.projectDetail && props.projectDetail.permission; - const { projectDetail } = props; + const { projectDetail , current_user } = props; useEffect(()=>{ if(projectDetail){ @@ -54,6 +54,23 @@ function List(props){ } },[projectDetail]) + useEffect(()=>{ + const datas = cookie.load('states'); + let states = datas === "undefined" ? undefined : datas; + if(states){ + setAboutMe(states.participant_category); + setCategory(states.category); + setPage(states.page); + setLimit(states.limit || 10); + setUpdateIds({...states}); + setNames(states.names); + if(states.participant_category ==="all" && states.category === "opened" && states.page === 1 && states.limit===10) + Init({...states},states.page,states.names); + }else{ + Init(); + } + },[]) + useEffect(()=>{ let v = allValue && allValue > 0; if((updateIds && !v && (updateIds.author_id || updateIds.issue_priorities_id || updateIds.issue_tag_ids || updateIds.milestone_id || updateIds.sort_by || updateIds.status_id ||updateIds.assigner_id)) || value){ @@ -62,11 +79,26 @@ function List(props){ setClearFlag(false); } },[updateIds,value]) + // 自定义一个初始不更新的hook + const useUpdateEffect = (fn, inputs) => { + const didMountRef = useRef(false); + useEffect(() => { + if (didMountRef.current) fn(); + else didMountRef.current = true; + }, inputs); + }; + + // 定义处理函数 + function handleAllDisabled(){ + Init(updateIds,page,names); + } // 使用自定义hook - useEffect(()=>{ - Init(updateIds,1); - },[aboutMe,keyword,category,limit]) + useUpdateEffect(handleAllDisabled, [aboutMe,keyword,category,limit]); + + // useEffect(()=>{ + // Init(updateIds,page,names); + // },[aboutMe,keyword,category,limit]) function getDirection(id){ if(!id) return undefined; @@ -89,15 +121,20 @@ function List(props){ // 获取issue列表数据 function Init(params,p,names){ + const datas = cookie.load('states'); + let states = datas === "undefined" ? undefined : datas; + if(states){ + cookie.remove('states'); + } const url = `/v1/${owner}/${projectsId}/issues`; axios.get(url,{ params:{ + ...params, + page:p || 1, keyword, participant_category:aboutMe, category, limit, - ...params, - page:p || page, sort_direction:getDirection(params && params.sort_by), sort_by:getBy(params && params.sort_by), } @@ -111,6 +148,13 @@ function List(props){ setAllIds(ids); setIssueTotal(result.data.total_issues_count); setHas_created_issues(result.data.has_created_issues); + + const d = {...params,keyword,participant_category:aboutMe,category,limit,page:p || 1, + sort_direction:getDirection(params && params.sort_by), + sort_by:getBy(params && params.sort_by),names:names}; + + let inFifteenMinutes = new Date(new Date().getTime() + 24 * 3600 * 1000); + cookie.save('states', {...d},{ expires: inFifteenMinutes,path:`/` }); } }).then(error=>{}) } @@ -140,6 +184,7 @@ function List(props){ setUpdateIds(undefined); setAllValue([]); setValue(undefined); + setNames(undefined); Init(); // 清除下拉选项 menuRef.current && menuRef.current.clearChoose(); @@ -200,7 +245,7 @@ function List(props){ // 切换页码 function changepage(p){ setPage(p); - Init(updateIds,p); + Init(updateIds,p,names); if (document) { // 可以排除不需要置顶的页面 if (document.documentElement || document.body) { document.documentElement.scrollTop = document.body.scrollTop = 0; // 切换路由时手动置顶 @@ -241,15 +286,6 @@ function List(props){ setPage(1); setLimit(p); } - - function createBtnFunc(){ - if(props.checkIfLogin()===false){ - props.showLoginDialog(); - return false; - } - props.history.push(`/${owner}/${projectsId}/issues/new`); - } - function changeCategory(value){ setCategory(value); setPage(1); @@ -261,18 +297,21 @@ function List(props){ setVisible(false)} onSuccess={onSuccess}/>
- - - {aboutMe === "all" ? "全部":aboutMe === "aboutme"?"与我相关":aboutMe === "assignedme"?"我负责的":aboutMe === "authoredme"?"我创建的":"@我的"} - - - + { + (current_user && current_user.login) && + + + {aboutMe === "all" ? "全部":aboutMe === "aboutme"?"与我相关":aboutMe === "assignedme"?"我负责的":aboutMe === "authoredme"?"我创建的":"@我的"} + + + + } {setValue(e.target.value);}} onSearch={()=>setKeyword(value)} - style={{ width: 354 , height : 32 , marginLeft: 20 }} + style={{ width: 354 , height : 32 }} allowClear /> { diff --git a/src/forge/Issues/Pages/sign.jsx b/src/forge/Issues/Pages/sign.jsx index f8c5bbd9..d908e9b0 100644 --- a/src/forge/Issues/Pages/sign.jsx +++ b/src/forge/Issues/Pages/sign.jsx @@ -64,10 +64,17 @@ function Sign(props){ function arrayList(e){ const { eventKey , value , children , createName } = e.item.props; setPage(1); - setOrderName(createName); - setOrderType(value); - setArrayName(children); - setKey(eventKey); + if(value === order_type && createName === order_name){ + setOrderName(undefined); + setOrderType(undefined); + setArrayName("标记"); + setKey("0"); + }else{ + setOrderName(createName); + setOrderType(value); + setArrayName(children); + setKey(eventKey); + } } const menu = ( @@ -204,7 +211,7 @@ function Sign(props){
项目标记({total || 0}) - {arrayName} + {arrayName}
{