[add] 可以選星期幾

This commit is contained in:
建喵 2024-05-20 17:27:30 +08:00
parent 1fffabfae8
commit 4279c449b5
4 changed files with 14 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 264 KiB

View File

@ -2,12 +2,14 @@ import { Pagination } from 'antd';
import axios from 'axios'; import axios from 'axios';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { NavigateFunction, useNavigate } from "react-router-dom"; import { NavigateFunction, useNavigate, useParams } from "react-router-dom";
import './App.css'; import './App.css';
import A from './Components/CustomA'; import A from './Components/CustomA';
export default function App() { export default function App() {
const navigate: NavigateFunction = useNavigate(); const navigate: NavigateFunction = useNavigate();
const { id } = useParams();
const dayOfWeek: string = id ?? "1";
const [current, setCurrent] = useState(1); const [current, setCurrent] = useState(1);
const [totalDataLength, setTotalDataLength] = useState(50) const [totalDataLength, setTotalDataLength] = useState(50)
const [data, setData] = useState<any[][]>([[]]) const [data, setData] = useState<any[][]>([[]])
@ -28,6 +30,7 @@ export default function App() {
} }
const reqData = JSON.stringify({ const reqData = JSON.stringify({
"dayOfWeek": dayOfWeek,
"page": current "page": current
}); });
@ -55,6 +58,10 @@ export default function App() {
} }
function getListPage(): void { function getListPage(): void {
const reqData = JSON.stringify({
"dayOfWeek": dayOfWeek
});
const config = { const config = {
method: 'post', method: 'post',
maxBodyLength: Infinity, maxBodyLength: Infinity,
@ -62,6 +69,7 @@ export default function App() {
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
data: reqData
}; };
axios.request(config) axios.request(config)

View File

@ -16,7 +16,7 @@ export default function Play() {
const [scoreList, setScoreList] = useState<any[]>([]) const [scoreList, setScoreList] = useState<any[]>([])
function onClickLobby(): void { function onClickLobby(): void {
navigate(`/`); navigate(`/home/${data.dayOfWeek}`);
} }
useEffect(() => { useEffect(() => {

View File

@ -14,6 +14,10 @@ const hashRouter: Router = createHashRouter([
path: "/", path: "/",
element: <App />, element: <App />,
}, },
{
path: "/home/:id",
element: <App />,
},
{ {
path: "/play/:id", path: "/play/:id",
element: <Play />, element: <Play />,