组织地址、website的问题,可合并至develop

This commit is contained in:
caishi 2021-04-27 17:11:37 +08:00
parent 4ba63fd8fa
commit 8d509f1473
3 changed files with 53 additions and 32 deletions

View File

@ -1,45 +1,43 @@
import React , { useState } from 'react'; import React , { useState , useEffect } from 'react';
import { AutoComplete } from 'antd'; import { AutoComplete } from 'antd';
import { getImageUrl } from "educoder"; import { getImageUrl } from "educoder";
import axios from 'axios'; import axios from 'axios';
const Option = AutoComplete.Option; const Option = AutoComplete.Option;
export default ({ getUser })=>{ export default ({ getUser , placeholder, width })=>{
const [ source , setSource ] = useState(undefined);
const [ searchKey , setSearchKey ] = useState(undefined); const [ searchKey , setSearchKey ] = useState(undefined);
const [ userDataSource , setUserDataSource ] = useState(undefined);
useEffect(()=>{
getUserList();
},[searchKey])
function getUserList(e){ function getUserList(e){
const url = `/users/list.json`; const url = `/users/list.json`;
axios.get(url, { axios.get(url, {
params: { params: {
search: e, search: searchKey,
}, },
}) }).then((result) => {
.then((result) => {
if (result) { if (result) {
setUserDataSource(result.data.users); sourceOptions(result.data.users);
} }
}) })
.catch((error) => { .catch((error) => {
console.log(error); console.log(error);
}); });
}; };
function changeInputUser(value){
setSearchKey(value);
getUserList(value);
}
function selectInputUser(id, option){ function sourceOptions(userDataSource){
setSearchKey(option.props.value); const s = userDataSource && userDataSource.map((item, key) => {
getUserList(option.props.value);
getUser && getUser(id);
}
const source =
userDataSource && userDataSource.map((item, key) => {
return ( return (
<Option key={key} value={`${item.login}`}> <Option
key={key}
value={`${item.user_id}`}
login={`${item.login}`}
name={item.username}
>
<img <img
className="user_img radius" className="user_img radius"
width="28" width="28"
@ -54,14 +52,31 @@ export default ({ getUser })=>{
</Option> </Option>
); );
}); });
setSource(s);
}
function changeInputUser(e){
setSearchKey(e);
};
//
function selectInputUser(e, option){
setSearchKey(option.props.name);
getUser(option.props.login);
};
return( return(
<AutoComplete <div className="addPanel">
dataSource={source} <AutoComplete
value={searchKey} getPopupContainer={trigger => trigger.parentNode}
style={{ width: 300 }} dataSource={source}
onChange={changeInputUser} value={searchKey}
onSelect={selectInputUser} style={{ width: width || 300 }}
placeholder="搜索需要添加的用户..." onChange={changeInputUser}
/> onSelect={selectInputUser}
placeholder={placeholder || "搜索需要添加的用户..."}
allowClear
/>
</div>
) )
} }

View File

@ -305,12 +305,12 @@ function CoderDepot(props){
<a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务</a> <a onClick={()=>urlLink(`/projects/${owner}/${projectsId}/issues/new`)} >+ 任务</a>
</div> </div>
{ type === "dir" && projectDetail.type !== 2 && { type === "dir" && projectDetail.type !== 2 &&
<Dropdown overlay={fileMenu} className="mr20"> <Dropdown overlay={fileMenu} className="mr20" trigger={['click']}>
<Button type="default">文件 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-grey-9"></i></Button> <Button type="default">文件 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-grey-9"></i></Button>
</Dropdown> </Dropdown>
} }
<Dropdown overlay={downloadMenu} placement="bottomRight"> <Dropdown overlay={downloadMenu} placement="bottomRight" trigger={['click']}>
<Button type={'primary'}>下载 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-white"></i></Button> <Button type={'primary'}>下载 <i className="iconfont icon-sanjiaoxing-down ml3 font-14 color-white"></i></Button>
</Dropdown> </Dropdown>
</AlignCenter> </AlignCenter>

View File

@ -96,8 +96,14 @@ function Detail(props){
} }
bottomInfos={ bottomInfos={
!buttonflag && <div> !buttonflag && <div>
<span className="color-grey-6"><i className="iconfont icon-weizhi mr3 font-16 color-grey-6"></i>{detail.location}</span> {
<a href={detail.website} target="_blank" className="ml20 color-grey-6"><i className="iconfont icon-lianjie mr3 font-14"></i>{detail.website}</a> detail.location &&
<span className="color-grey-6"><i className="iconfont icon-weizhi mr3 font-16 color-grey-6"></i>{detail.location}</span>
}
{
detail.website &&
<a href={detail.website} target="_blank" className="ml20 color-grey-6"><i className="iconfont icon-lianjie mr3 font-14"></i>{detail.website}</a>
}
</div> </div>
} }
/> />