Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

dist/
dist/

.vscode
4 changes: 2 additions & 2 deletions src/component/Login/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ function LoginForm() {
const [faCode, setFACode] = useState("");

const loginCaptcha = useSelector((state) => state.siteConfig.loginCaptcha);
const registerEnabled = useSelector((state) => state.siteConfig.registerEnabled);
const title = useSelector((state) => state.siteConfig.title);
const authn = useSelector((state) => state.siteConfig.authn);

const dispatch = useDispatch();
const ToggleSnackbar = useCallback(
(vertical, horizontal, msg, color) =>
Expand Down Expand Up @@ -353,7 +353,7 @@ function LoginForm() {
<Link href={"/forget"}>忘记密码</Link>
</div>
<div>
<Link href={"/signup"}>注册账号</Link>
{ registerEnabled ? <Link href={"/signup"}>注册账号</Link> : null }
</div>
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/component/Login/Reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function Reset() {
[name]: e.target.value,
});
};
const registerEnabled = useSelector((state) => state.siteConfig.registerEnabled);

const {
captchaLoading,
Expand Down Expand Up @@ -162,7 +163,7 @@ function Reset() {
<Link href={"/login"}>返回登录</Link>
</div>
<div>
<Link href={"/signup"}>注册账号</Link>
{ registerEnabled ? <Link href={"/signup"}>注册账号</Link> : null }
</div>
</div>
</Paper>
Expand Down
5 changes: 3 additions & 2 deletions src/component/Login/ResetForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useState } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { makeStyles } from "@material-ui/core";
import { toggleSnackbar } from "../../actions/index";
import { useHistory } from "react-router-dom";
Expand Down Expand Up @@ -78,6 +78,7 @@ function ResetForm() {
[dispatch]
);
const history = useHistory();
const registerEnabled = useSelector((state) => state.siteConfig.registerEnabled);

const submit = (e) => {
e.preventDefault();
Expand Down Expand Up @@ -155,7 +156,7 @@ function ResetForm() {
<Link href={"/#/login"}>返回登录</Link>
</div>
<div>
<Link href={"/#/signup"}>注册账号</Link>
{ registerEnabled ? <Link href={"/#/signup"}>注册账号</Link> : null }
</div>
</div>
</Paper>
Expand Down
8 changes: 5 additions & 3 deletions src/component/Login/ResetPwdForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ const styles = (theme) => ({
},
},
});
const mapStateToProps = () => {
return {};
const mapStateToProps = (state) => {
return {
registerEnabled: state.siteConfig.registerEnabled
};
};

const mapDispatchToProps = (dispatch) => {
Expand Down Expand Up @@ -197,7 +199,7 @@ class ResetPwdFormCompoment extends Component {
<Link href={"/Login"}>返回登录</Link>
</div>
<div>
<Link href={"/SignUp"}>注册账号</Link>
{ this.props.registerEnabled ? <Link href={"/signup"}>注册账号</Link> : null }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接写成 { this.props.registerEnabled &&<Link href={"/signup"}>注册账号</Link>} 即可,上同

</div>
</div>
</Paper>
Expand Down
18 changes: 11 additions & 7 deletions src/component/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const mapStateToProps = (state) => {
subTitle: state.viewUpdate.subTitle,
loadUploader: state.viewUpdate.loadUploader,
isLogin: state.viewUpdate.isLogin,
registerEnabled: state.siteConfig.registerEnabled,
};
};

Expand Down Expand Up @@ -519,16 +520,19 @@ class NavbarCompoment extends Component {
</ListItemIcon>
<ListItemText primary="登录" />
</ListItem>
<ListItem
{ this.props.registerEnabled ?
<ListItem
button
key="注册"
onClick={() => this.props.history.push("/signup")}
>
<ListItemIcon>
<AccountPlus className={classes.iconFix} />
</ListItemIcon>
<ListItemText primary="注册" />
</ListItem>
>
<ListItemIcon>
<AccountPlus className={classes.iconFix} />
</ListItemIcon>
<ListItemText primary="注册" />
</ListItem>
: null
}
</div>
)}
</div>
Expand Down
18 changes: 11 additions & 7 deletions src/component/Navbar/UserAvatarPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import pathHelper from "../../utils/page";
const mapStateToProps = (state) => {
return {
anchorEl: state.viewUpdate.userPopoverAnchorEl,
registerEnabled: state.siteConfig.registerEnabled,
};
};

Expand Down Expand Up @@ -139,14 +140,17 @@ class UserAvatarPopoverCompoment extends Component {
</ListItemIcon>
登录
</MenuItem>
<MenuItem
{ this.props.registerEnabled ?
<MenuItem
onClick={() => this.props.history.push("/signup")}
>
<ListItemIcon>
<AccountPlus />
</ListItemIcon>
注册
</MenuItem>
>
<ListItemIcon>
<AccountPlus />
</ListItemIcon>
注册
</MenuItem>
: null
}
</div>
)}
{Auth.Check() && (
Expand Down