diff --git a/222100414_222100415/src/common/api/api.ts b/222100414_222100415/src/common/api/api.ts index b9f214ddb153035b098bb800dc32a8c9fcb84f32..b32181890ab773cc29d5ea24fa791eb3390a58d0 100644 --- a/222100414_222100415/src/common/api/api.ts +++ b/222100414_222100415/src/common/api/api.ts @@ -1,16 +1,3 @@ -import axios from 'axios'; - -const instance = axios.create({ - baseURL: 'https://swimming.abdecd.xyz', - headers: { - 'Content-Type': 'application/json' - } -}); - -const httpGet = async (url: string) => { - return await instance.get(url); -}; - export interface Schedule { UtcDateTime: string; Date: string; @@ -19,8 +6,8 @@ export interface Schedule { } export const getSchedules = async () => { - const response = await httpGet('/api/fina/competitions/3337/schedule?discipline='); - return response.data; + const response = await fetch('/api/fina/competitions/3337/schedule'); + return response.json(); }; export interface Competition { @@ -29,13 +16,14 @@ export interface Competition { } export const getCompetitions = async (): Promise => { - const response = await fetch('/api/fina/competitions/3337/events'); + const response = await fetch('https://swimming.abdecd.xyz/api/fina/competitions/3337/events'); const data = await response.json() as { Sports: [{ DisciplineList: Competition[] }] }; return data.Sports?.[0]?.DisciplineList; }; +getCompetitions().then(console.log); export const getResults = async (hash: string) => { - const response = await fetch(`/api/fina/events/${hash}`); + const response = await fetch(`https://swimming.abdecd.xyz/api/fina/events/${hash}`); return await response.json(); }; @@ -57,3 +45,4 @@ export const getMedalTable = async () => { }; return data.Medals.SportMedals?.[0]; }; + diff --git a/222100414_222100415/src/component/mika-ui/Modal/Modal.tsx b/222100414_222100415/src/component/mika-ui/Modal/Modal.tsx index 878a71fca0696525e24cf319eecaba0c4a3d172e..4bb3c6f12f8e84b8a9042890c1d44019cbf1dc55 100644 --- a/222100414_222100415/src/component/mika-ui/Modal/Modal.tsx +++ b/222100414_222100415/src/component/mika-ui/Modal/Modal.tsx @@ -1,6 +1,6 @@ import React, {forwardRef, memo, useCallback, useEffect, useRef} from "react"; import './Modal.less'; -import {fadeOutModal} from "./ModalUtils.tsx"; +import {fadeOutModal} from "./ModalUtils"; export type ModalController = { @@ -160,4 +160,4 @@ const Modal = memo(forwardRef((props: ModalProps, ref: React.Ref })); -export default Modal; \ No newline at end of file +export default Modal; diff --git a/222100414_222100415/src/component/mika-ui/Modal/ModalUtils.tsx b/222100414_222100415/src/component/mika-ui/Modal/ModalUtils.tsx index b35614ea987d047865eb4bf0dd692240706c2d0f..9578da8742e5cbb7fcf21a75d89d149dc465e0e9 100644 --- a/222100414_222100415/src/component/mika-ui/Modal/ModalUtils.tsx +++ b/222100414_222100415/src/component/mika-ui/Modal/ModalUtils.tsx @@ -1,5 +1,5 @@ import React, {useCallback} from "react"; -import Modal, {ModalController, ModalProps} from "./Modal.tsx"; +import Modal, {ModalController, ModalProps} from "./Modal"; import {createRoot} from "react-dom/client"; export const fadeOutModal = (modalRef: React.RefObject) => { modalRef.current?.classList.add("mika-modal-closing"); diff --git a/222100414_222100415/src/page/DaliySchedule/DailySchedule.tsx b/222100414_222100415/src/page/DaliySchedule/DailySchedule.tsx index defcc92079c45cfb191eb1c2200183a705aaeea2..35307b48b2ba751449689090c423d0ccf4f000f6 100644 --- a/222100414_222100415/src/page/DaliySchedule/DailySchedule.tsx +++ b/222100414_222100415/src/page/DaliySchedule/DailySchedule.tsx @@ -42,11 +42,10 @@ const DailySchedule = (props: DailyScheduleProps) => { > <Panel> - <div> - <div className="text-black text-4xl bg-white p-4 rounded-tl-lg rounded-tr-lg select-none mb-4"> - {new Date().toLocaleDateString()} - </div> - + <div className="text-black text-4xl bg-white p-4 rounded-tl-lg rounded-tr-lg select-none mb-4"> + {new Date().toLocaleDateString()} + </div> + <div className="overflow-y-auto"> {data.map((item, index) => ( <DailyScheduleItem key={index} title={item.title} data={item.data}/> ))} diff --git a/222100414_222100415/vercel.json b/222100414_222100415/vercel.json new file mode 100644 index 0000000000000000000000000000000000000000..f254b8d281e2c4e470e13b2b816f3fe19dbdb314 --- /dev/null +++ b/222100414_222100415/vercel.json @@ -0,0 +1,8 @@ +{ + "rewrites": [ + { + "source": "/api/(.*)", + "destination": "https://api.worldaquatics.com/$1" + } + ] +} diff --git a/222100414_222100415/vite.config.ts b/222100414_222100415/vite.config.ts index 4b068ebfca2bcfd6b5f06c64ee7d642f8eebee36..52be1f715e0bab9b243a6d8e584877708710bf08 100644 --- a/222100414_222100415/vite.config.ts +++ b/222100414_222100415/vite.config.ts @@ -1,8 +1,18 @@ import {defineConfig} from 'vite'; import react from '@vitejs/plugin-react'; -import eslint from 'vite-plugin-eslint'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()] + plugins: [react()], + + server: { + proxy: { + '/api': { + target: 'https://api.worldaquatics.com', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, '') + } + } + } + });