generated from VLADIMIR/template_frontend
add client
This commit is contained in:
@@ -6,7 +6,7 @@ import BeltBlock from './BeltBlock.vue';
|
||||
import MetalPlate from './MetalPlate.vue';
|
||||
import GameHeader from './GameHeader.vue';
|
||||
import type { Action, Door, Team } from './models';
|
||||
import { apiGetTeam, encodeUTF8ToBase64, getApiUrl } from './client';
|
||||
import { apiGetGame, apiGetTeam, apiLetsgo } from './client';
|
||||
import { UnauthorizedError } from './UnauthorizedError';
|
||||
|
||||
const router = useRouter();
|
||||
@@ -84,21 +84,8 @@ function addAction() {
|
||||
place.value = ""
|
||||
}
|
||||
|
||||
function letsgo(place: string) {
|
||||
console.log("letsgo to " + place)
|
||||
fetch(
|
||||
getApiUrl("/team/actions"),
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Id": encodeUTF8ToBase64(login.value),
|
||||
"X-Password": password.value
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"place": place
|
||||
})
|
||||
}
|
||||
)
|
||||
async function letsgo(place: string) {
|
||||
await apiLetsgo(login.value, password.value, place)
|
||||
}
|
||||
|
||||
const scrollToBottom = async (behavior: ScrollBehavior = 'smooth'): Promise<void> => {
|
||||
@@ -111,27 +98,19 @@ const scrollToBottom = async (behavior: ScrollBehavior = 'smooth'): Promise<void
|
||||
}
|
||||
};
|
||||
|
||||
function getGame() {
|
||||
async function getGame() {
|
||||
qrurl.value = location.href
|
||||
fetch(
|
||||
getApiUrl("/game")
|
||||
)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
gameState.value = data.state
|
||||
if (data.state === "NEW") {
|
||||
gameStateText.value = "Игра ещё не началась"
|
||||
}
|
||||
if (data.state === "RUN") {
|
||||
gameStateText.value = ""
|
||||
}
|
||||
if (data.state === "STOP") {
|
||||
gameStateText.value = "Игра остановлена"
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Ошибка:', error)
|
||||
});
|
||||
const data = await apiGetGame(login.value, password.value)
|
||||
gameState.value = data.state
|
||||
if (data.state === "NEW") {
|
||||
gameStateText.value = "Игра ещё не началась"
|
||||
}
|
||||
if (data.state === "RUN") {
|
||||
gameStateText.value = ""
|
||||
}
|
||||
if (data.state === "STOP") {
|
||||
gameStateText.value = "Игра остановлена"
|
||||
}
|
||||
}
|
||||
|
||||
// Автоматическая прокрутка при изменении items
|
||||
|
||||
Reference in New Issue
Block a user