Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 设置在不允许注册时候隐藏注册按钮 #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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> }
</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> }
</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> }
</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> }
</div>
</div>
</Paper>
Expand Down
17 changes: 10 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,18 @@ 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>
}
</div>
)}
</div>
Expand Down
17 changes: 10 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,16 @@ 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>
}
</div>
)}
{Auth.Check() && (
Expand Down