新建:拥有者默认选中当前登录用户,默认路由

This commit is contained in:
caishi 2021-07-06 11:54:57 +08:00
parent 275b7d2015
commit 1bb339bfb1
3 changed files with 22 additions and 42 deletions

View File

@ -78,6 +78,10 @@ const Search = Loadable({
loading: Loading,
})
const ProjectIndex = Loadable({
loader: () => import("./forge/Main/Index"),
loading: Loading,
});
class App extends Component {
constructor(props) {
super(props);
@ -103,30 +107,9 @@ class App extends Component {
Addcoursestypes: false
})
};
ModalCancelsy = () => {
this.setState({
mydisplay: false,
})
window.location.href = "/";
};
ModalshowCancelsy = () => {
this.setState({
mydisplay: true,
})
};
disableVideoContextMenu = () => {
window.$("body").on("mousedown", "video", function (event) {
if (event.which === 3) {
window.$('video').bind('contextmenu', function () { return false; });
} else {
window.$('video').unbind('contextmenu');
}
});
}
componentDidMount() {
document.title = "loading...";
this.disableVideoContextMenu();
initAxiosInterceptors(this.props);
this.getAppdata();
@ -204,6 +187,8 @@ class App extends Component {
};
render() {
const { mygetHelmetapi } = this.state;
let personal = mygetHelmetapi && mygetHelmetapi.personal;
return (
<Provider store={store}>
<ConfigProvider locale={zhCN}>
@ -265,7 +250,10 @@ class App extends Component {
<Route exact path="/"
render={
(props) => (
<Projects {...this.props} {...props} {...this.state}></Projects>
personal && personal.length > 0 ?
<InfosIndex {...this.props} {...props} />
:
<ProjectIndex {...this.props} {...props} />
)
}
/>

View File

@ -26,10 +26,6 @@ const ProjectDetail = Loadable({
loading: Loading,
});
const Infos = Loadable({
loader: () => import("./users/Infos"),
loading: Loading,
});
class Index extends Component {
componentDidUpdate=()=>{
@ -73,16 +69,6 @@ class Index extends Component {
<ProjectIndex {...this.props} {...props} />
)}
></Route>
<Route
exact
path="/"
render={(props) => (
this.props.current_user && this.props.current_user.login ?
<Infos {...this.props} {...props} />
:
<ProjectIndex {...this.props} {...props} />
)}
></Route>
</Switch>
</div>
);

View File

@ -68,24 +68,30 @@ class Index extends Component {
getOwner=()=>{
const { OIdentifier } = this.props.match.params;
const { user_id } = this.props && this.props.current_user;
const url = `/owners.json`;
axios.get(url).then(result=>{
if(result && result.data){
let owner = result.data.owners;
this.setState({
OwnerList: owner,
})
if(OIdentifier){
owner = owner.filter(item=>item.name === OIdentifier);
this.props.form.setFieldsValue({
user_id:OIdentifier
})
owner && this.setState({
owners_id:owner[0].id,
owners_name:owner[0].name
}else if(user_id){
owner = owner.filter(item=>item.id === user_id);
this.props.form.setFieldsValue({
user_id:owner && owner[0].name
})
}
this.setOptionsList(owner, 'owners');
this.setState({
OwnerList: owner,
owner && this.setState({
owners_id:owner[0].id,
owners_name:owner[0].name
})
this.setOptionsList(owner, 'owners');
}
}).catch(error=>{})
}