Compare commits

...

2 Commits

Author SHA1 Message Date
55f48de4db hide download button 2023-02-17 00:00:48 +08:00
7738e061fc center UI 2023-02-16 23:55:05 +08:00
3 changed files with 70 additions and 43 deletions

View File

@@ -40,6 +40,7 @@ const Timetable = ({
replaceInputType = "checkbox", replaceInputType = "checkbox",
apiRecordEndPoint = "/api/record", apiRecordEndPoint = "/api/record",
openRecordMode = false, openRecordMode = false,
hideDownloadButton = true,
}) => { }) => {
const [editable, setEditable] = React.useState(true); const [editable, setEditable] = React.useState(true);
const ref = React.useRef(); const ref = React.useRef();
@@ -229,10 +230,7 @@ const Timetable = ({
main(); main();
}, []); }, []);
return ( const DownloadMarks = async () => {
<>
<button
onClick={async () => {
console.log("download marks", marks); console.log("download marks", marks);
const data = { const data = {
user, user,
@@ -250,19 +248,26 @@ const Timetable = ({
} }
console.log(data); console.log(data);
downloadObjectAsJson(data, user); downloadObjectAsJson(data, user);
}} };
>
DownloadSelection return (
</button> <>
<span>Login as {user}</span> <h2 style={{ textAlign: "center" }}>Login as {user}</h2>
<div <div
ref={ref} ref={ref}
contentEditable={editable} contentEditable={editable}
style={{ style={{
overflow: "scroll", overflow: "scroll",
display: "flex",
justifyContent: "center",
}} }}
onInput={handleInput} onInput={handleInput}
></div>{" "} ></div>{" "}
{!hideDownloadButton && (
<p style={{ display: "flex", justifyContent: "center" }}>
<button onClick={DownloadMarks}>Download Selection</button>
</p>
)}
<div style={{ display: "none" }} id="download-dom"></div> <div style={{ display: "none" }} id="download-dom"></div>
</> </>
); );

View File

@@ -1,3 +1,4 @@
import { NodeNextRequest } from "next/dist/server/base-http/node";
import React from "react"; import React from "react";
const UserInputWrap = ({ children, setUser }) => { const UserInputWrap = ({ children, setUser }) => {
@@ -11,13 +12,32 @@ const UserInputWrap = ({ children, setUser }) => {
return ( return (
<> <>
{!begin && ( {!begin && (
<div
style={{
display: "grid",
placeItems: "center",
alignItems: "center",
minHeight: "100vh",
}}
>
<div> <div>
<input <input
placeholder="在这输你的名字" style={{
margin: "0.5em",
padding: "0.5em",
borderRadius: "0.39em",
}}
placeholder="你的名字..."
value={inputUser} value={inputUser}
onChange={(event) => setInputUser(event.target.value)} onChange={(event) => setInputUser(event.target.value)}
size={10}
/> />
<button <button
style={{
margin: "0.5em",
padding: "0.5em",
backgroundColor: "#39ceff",
}}
onClick={() => { onClick={() => {
if (inputUser.trim() === "") { if (inputUser.trim() === "") {
alert("姓名不能为空"); alert("姓名不能为空");
@@ -31,6 +51,7 @@ const UserInputWrap = ({ children, setUser }) => {
Login Login
</button> </button>
</div> </div>
</div>
)} )}
{begin && children} {begin && children}
</> </>

View File

@@ -47,6 +47,7 @@ export default function Home() {
disableConflictCheck={true} disableConflictCheck={true}
disableNetwork={true} disableNetwork={true}
replaceInputType={"number"} replaceInputType={"number"}
hideDownloadButton={false}
/> />
)} )}
</main> </main>