add architecture

This commit is contained in:
Владимир Фёдоров 2025-06-30 22:48:46 +07:00
parent 901a35f3ab
commit 440e0c2314
3 changed files with 37 additions and 33 deletions

View File

@ -3,24 +3,8 @@ import { onMounted, ref } from 'vue';
import { getApiUrl } from './net';
import router from '@/router';
import VueQrcode from '@chenfengyuan/vue-qrcode';
type Application = {
id: number
name: string
}
type Team = {
id: number
name: string
password: string
url: string
spendTime: number
applications: Application[]
}
type Teams = {
teams: Team[]
}
import type { Teams } from './models';
import { getTeams } from './client';
type Game = {
state: string
@ -36,19 +20,6 @@ const game = ref<Game>()
const teams = ref<Teams>({ teams: [] })
function getTeams() {
fetch(
getApiUrl("/teams")
)
.then(response => response.json())
.then(data => {
teams.value = data
})
.catch(error => {
console.error('Ошибка:', error)
});
}
function gaveApplication(teamId: number, id: number) {
fetch(
getApiUrl("/teams/" + teamId + "/applications"),
@ -178,10 +149,10 @@ function downloadFile(bytes: Uint8Array, fileName: string, mimeType: string) {
let intervalId = 0
onMounted(() => {
getTeams()
getTeams(teams)
intervalId = setInterval(() => {
getTeams()
getTeams(teams)
getGame()
}, 2000);

16
src/components/client.ts Normal file
View File

@ -0,0 +1,16 @@
import type { Ref } from 'vue';
import { getApiUrl } from './net';
import type { Teams } from './models';
export const getTeams = (teams : Ref<Teams>) => {
fetch(
getApiUrl("/teams")
)
.then(response => response.json())
.then(data => {
teams.value = data
})
.catch(error => {
console.error('Ошибка:', error)
});
}

17
src/components/models.ts Normal file
View File

@ -0,0 +1,17 @@
export type Application = {
id: number
name: string
}
export type Team = {
id: number
name: string
password: string
url: string
spendTime: number
applications: Application[]
}
export type Teams = {
teams: Team[]
}