加入了返回,改进了用户控制
This commit is contained in:
父節點
e2fb2ccc2b
當前提交
cfa6734461
15
src/App.css
15
src/App.css
@ -101,6 +101,21 @@ a.btn {
|
||||
height: 30px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.nav {
|
||||
display: flex;
|
||||
margin-left: 20px;
|
||||
}
|
||||
.nav-item {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.nav-link {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
}
|
||||
.nav-link:active {
|
||||
color: white;
|
||||
}
|
||||
|
||||
b {
|
||||
color: #9E0004;
|
||||
|
@ -7,6 +7,7 @@ import { apis } from '../../helper/apis';
|
||||
import { alert, confirmWithClose } from '../../helper/alert';
|
||||
import { UserContext } from '../../helper/Context';
|
||||
import Spinner from '../../components/Spinner/Spinner';
|
||||
import { Link } from '../../components/SingleRouter/SingleRouter';
|
||||
|
||||
export class ReviewContainer extends Component {
|
||||
static contextType = UserContext;
|
||||
@ -66,6 +67,11 @@ export class ReviewContainer extends Component {
|
||||
<div className="sdu">
|
||||
<img src={images.icon} className="sdu-logo" alt="logo" />
|
||||
<img src={images.name} className="sdu-name" alt="" />
|
||||
<div className="nav">
|
||||
<div className="nav-item">
|
||||
<Link to="/" className="nav-link">首页</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<UserControl pageAuthLevel={2} />
|
||||
</div>
|
||||
|
@ -10,7 +10,6 @@ import { alert } from '../../helper/alert';
|
||||
import History from '../../helper/history';
|
||||
import AvatarUnit from '../AvatarUnit/AvatarUnit';
|
||||
|
||||
const exitContent = ['登录', '退出', '退出审核'];
|
||||
// page level: 0: everyone, 1: login needed, 2: admin only
|
||||
export default function UserControl({ pageAuthLevel, buttonOnly }) {
|
||||
const { userData, setUserData } = useContext(UserContext);
|
||||
@ -69,21 +68,18 @@ export default function UserControl({ pageAuthLevel, buttonOnly }) {
|
||||
}
|
||||
</Fragment>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-hollow btn-straight"
|
||||
onClick={() => {
|
||||
localStorage.setItem('jwt', '');
|
||||
setUserData({ role: 0, name: '' });
|
||||
History.force('/login');
|
||||
}}
|
||||
>{userData.role > 0 ? '退出账号' : '登录'}</button>
|
||||
{
|
||||
userData.role === pageAuthLevel
|
||||
? (
|
||||
userData.role === 2 && pageAuthLevel !== 2 && (
|
||||
<button
|
||||
className="btn btn-hollow btn-straight"
|
||||
onClick={() => {
|
||||
localStorage.setItem('jwt', '');
|
||||
setUserData({ role: 0, name: '' });
|
||||
History.force('/login');
|
||||
}}
|
||||
>{exitContent[pageAuthLevel]}</button>
|
||||
)
|
||||
: userData.role === 2 && (
|
||||
<button
|
||||
className="btn btn-hollow btn-straight"
|
||||
className="btn btn-light btn-straight"
|
||||
onClick={() => {
|
||||
History.push('/admin/review');
|
||||
}}
|
||||
|
@ -6,3 +6,6 @@
|
||||
color: white;
|
||||
margin: 0 10px;
|
||||
}
|
||||
.user > :not(:first-child) {
|
||||
margin-left: 10px;
|
||||
}
|
@ -8,6 +8,7 @@ import { images } from '../resources.json';
|
||||
|
||||
import './upload.css';
|
||||
import UserControl from '../components/UserControl/UserControl';
|
||||
import { Link } from '../components/SingleRouter/SingleRouter';
|
||||
|
||||
export class UploadContainer extends Component {
|
||||
constructor(props) {
|
||||
@ -67,6 +68,11 @@ export class UploadContainer extends Component {
|
||||
<div className="sdu">
|
||||
<img src={images.icon} className="sdu-logo" alt="logo" />
|
||||
<img src={images.name} className="sdu-name" alt="" />
|
||||
<div className="nav">
|
||||
<div className="nav-item">
|
||||
<Link to="/" className="nav-link">首页</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<UserControl pageAuthLevel={1} />
|
||||
</div>
|
||||
|
載入中…
x
新增問題並參考
Block a user