From 8d509f14739bcb255329b01c128811f83ba0ad4f Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Tue, 27 Apr 2021 17:11:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=9C=B0=E5=9D=80=E3=80=81we?= =?UTF-8?q?bsite=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8F=AF=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E8=87=B3develop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Component/SearchUser.jsx | 71 ++++++++++++++++++------------ src/forge/Main/CoderDepot.jsx | 4 +- src/forge/Team/Sub/Detail.jsx | 10 ++++- 3 files changed, 53 insertions(+), 32 deletions(-) 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} + }
} />