Merge pull request 'issue' (#298) from durian/forgeplus-react:gitlink_server into gitlink_server

This commit is contained in:
xxq250 2021-11-30 15:26:36 +08:00
commit 4971dc0a3d
3 changed files with 35 additions and 14 deletions

View File

@ -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 || 'student'
window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin'
}
window._debugType = debugType;
export function initAxiosInterceptors(props) {

View File

@ -47,7 +47,26 @@ class order_form extends Component {
}
componentDidMount = () => {
this.getSelectList();
//如果是复制issue则需要将原内容中的@谁录入 @列表中 (在tpm-md-editor.js中其实有处理但是当用户点击【复制】按钮之后迅速创建issue会有延迟导致@失效)
if (this.state.form_type === "copy"){
let allUser = undefined;
axios.get(`/${owner}/${projectsId}/members.json`).then(response=>{
if (response.data.total_count !== 0) {
allUser = response.data.users
}
})
if (allUser && allUser.length !== 0 && description && description.indexOf("@") !== -1) {
const list = new Set();
allUser.map(item => {
if (description.indexOf(`[@${item.username}](/${item.login})`) !== -1) {
list.add(item.login);
}
})
this.setState({ atWhoLoginList: Array.from(list)});
}
}
};
get_detail = () => {
this.setState({
isSpin:true

View File

@ -90,7 +90,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
const containerId = `mdEditor_${mdID}`;
const editorBodyId = `mdEditors_${mdID}`;
const tipId = `e_tips_mdEditor_${mdID}`;
const [init, setInit] = useState(true);
useEffect(()=>{
//请求members接口获取全部可@列表
@ -107,6 +106,20 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
})
},[])
useEffect(()=>{
//如果是复制issue则需要将原内容中的@谁录入 @列表中
if (isCanAtme === "copy" && initValue && initValue.indexOf("@") !== -1) {
allUsers.map(item=>{
if (initValue.indexOf(`[@${item.username}](/${item.login})`) !== -1) {
const list = new Set(atWhoLoginList.current);
list.add(item.login);
atWhoLoginList.current = Array.from(list);
setAtWhoLoginListState(Array.from(list));
}
})
}
}, [initValue])
function onLayout() {
let ro;
if (editorEl.current) {
@ -198,7 +211,7 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
}
useEffect(()=>{
changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginListState);
changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginList.current);
},[atWhoLoginListState])
const atWhoList = (
@ -296,17 +309,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
const cmEl = editorInstance && editorInstance.cm
useEffect(() => {
//如果是复制issue则需要将原内容中的@谁录入 @列表中
if (init && cmEl && initValue && isCanAtme === "copy" && initValue.indexOf("@") !== -1) {
allUsers.map(item => {
initValue.indexOf(`[@${item.username}](/${item.login})`) !== -1 && selectAtWho(item.username);
})
setInit(false);
console.log('复制issue atWhoLoginList.current', atWhoLoginList.current, 'atWhoLoginListState', atWhoLoginListState);
}
}, [initValue])
useEffect(()=>{
if(atWhoVisibleRef.current){
// 添加上下键、enter键监听事件