diff --git a/src/forge/Component/SearchUser.jsx b/src/forge/Component/SearchUser.jsx index 0203d24f..b9841123 100644 --- a/src/forge/Component/SearchUser.jsx +++ b/src/forge/Component/SearchUser.jsx @@ -1,45 +1,43 @@ -import React , { useState } from 'react'; +import React , { useState , useEffect } from 'react'; import { AutoComplete } from 'antd'; import { getImageUrl } from "educoder"; import axios from 'axios'; const Option = AutoComplete.Option; -export default ({ getUser })=>{ +export default ({ getUser , placeholder, width })=>{ + const [ source , setSource ] = useState(undefined); const [ searchKey , setSearchKey ] = useState(undefined); - const [ userDataSource , setUserDataSource ] = useState(undefined); + + useEffect(()=>{ + getUserList(); + },[searchKey]) function getUserList(e){ const url = `/users/list.json`; axios.get(url, { params: { - search: e, + search: searchKey, }, - }) - .then((result) => { + }).then((result) => { if (result) { - setUserDataSource(result.data.users); + sourceOptions(result.data.users); } }) .catch((error) => { console.log(error); }); }; - - function changeInputUser(value){ - setSearchKey(value); - getUserList(value); - } - function selectInputUser(id, option){ - setSearchKey(option.props.value); - getUserList(option.props.value); - getUser && getUser(id); - } - const source = - userDataSource && userDataSource.map((item, key) => { + function sourceOptions(userDataSource){ + const s = userDataSource && userDataSource.map((item, key) => { return ( - ); }); + setSource(s); + } + + function changeInputUser(e){ + setSearchKey(e); + }; + + // 选择用户 + function selectInputUser(e, option){ + setSearchKey(option.props.name); + getUser(option.props.login); + }; + return( - +
+ trigger.parentNode} + dataSource={source} + value={searchKey} + style={{ width: width || 300 }} + onChange={changeInputUser} + onSelect={selectInputUser} + placeholder={placeholder || "搜索需要添加的用户..."} + allowClear + /> +
) } \ No newline at end of file diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index 86a33246..15073e83 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -305,12 +305,12 @@ function CoderDepot(props){ urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务 { type === "dir" && projectDetail.type !== 2 && - + } - + diff --git a/src/forge/Team/Sub/Detail.jsx b/src/forge/Team/Sub/Detail.jsx index f2df0dbd..6e048a05 100644 --- a/src/forge/Team/Sub/Detail.jsx +++ b/src/forge/Team/Sub/Detail.jsx @@ -96,8 +96,14 @@ function Detail(props){ } bottomInfos={ !buttonflag &&
- {detail.location} - {detail.website} + { + detail.location && + {detail.location} + } + { + detail.website && + {detail.website} + }
} />