refactor frontend (not done)

This commit is contained in:
bridge
2026-01-11 22:29:53 +08:00
parent 08e28f52c7
commit 879a3c0d1f
24 changed files with 759 additions and 519 deletions

View File

@@ -0,0 +1,49 @@
import { httpClient } from '../http';
import type {
SaveFileDTO,
InitStatusDTO,
GameStartConfigDTO,
CurrentConfigDTO
} from '../../types/api';
export const systemApi = {
pauseGame() {
return httpClient.post('/api/control/pause', {});
},
resumeGame() {
return httpClient.post('/api/control/resume', {});
},
fetchSaves() {
return httpClient.get<{ saves: SaveFileDTO[] }>('/api/saves');
},
saveGame(filename?: string) {
return httpClient.post<{ status: string; filename: string }>('/api/game/save', { filename });
},
loadGame(filename: string) {
return httpClient.post<{ status: string; message: string }>('/api/game/load', { filename });
},
fetchInitStatus() {
return httpClient.get<InitStatusDTO>('/api/init-status');
},
startNewGame() {
return httpClient.post<{ status: string; message: string }>('/api/game/new', {});
},
reinitGame() {
return httpClient.post<{ status: string; message: string }>('/api/control/reinit', {});
},
fetchCurrentConfig() {
return httpClient.get<CurrentConfigDTO>('/api/config/current');
},
startGame(config: GameStartConfigDTO) {
return httpClient.post<{ status: string; message: string }>('/api/game/start', config);
}
};