控制开始时间
This commit is contained in:
@@ -29,6 +29,25 @@ export default function Time(props) {
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const setStarted = (started) => {
|
||||
fetch("/api/time/started", {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ token, started }),
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (res.error) {
|
||||
setSnackbarError(true);
|
||||
setSnackbarErrorMessage(res.error);
|
||||
} else {
|
||||
setSnackbarSuccess(true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const isAdmin = () => {
|
||||
if (props.username === "admin") {
|
||||
return true;
|
||||
@@ -226,6 +245,20 @@ export default function Time(props) {
|
||||
>
|
||||
修改上限
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() => setStarted(true)}
|
||||
>
|
||||
开始
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
onClick={() => setStarted(false)}
|
||||
>
|
||||
停止
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user