提交 1f5bd8ea 编写于 作者: 式部

fix

上级 f0f0be7f
import axios from 'axios';
const instance = axios.create({
baseURL: 'https://swimming.abdecd.xyz',
headers: {
'Content-Type': 'application/json'
}
});
const httpGet = async <T, > (url: string) => {
return await instance.get<T>(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<Competition[]> => {
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];
};
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<HTMLDivElement>
}));
export default Modal;
\ No newline at end of file
export default Modal;
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<HTMLDivElement>) => {
modalRef.current?.classList.add("mika-modal-closing");
......
......@@ -42,11 +42,10 @@ const DailySchedule = (props: DailyScheduleProps) => {
>
<Title title="Daily Schedule"/>
<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}/>
))}
......
{
"rewrites": [
{
"source": "/api/(.*)",
"destination": "https://api.worldaquatics.com/$1"
}
]
}
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/, '')
}
}
}
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册