add game
This commit is contained in:
parent
6a8b7edb45
commit
ceb744ec12
@ -28,6 +28,10 @@
|
|||||||
opacity: 0.9;
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button-custom:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
.input-custom, .button-custom {
|
.input-custom, .button-custom {
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
const team = ref<Team>({name: "", actions: []})
|
const team = ref<Team>({name: "", actions: []})
|
||||||
const actions = ref<Action[]>([])
|
const actions = ref<Action[]>([])
|
||||||
const scrollContainer = ref<HTMLDivElement | null>();
|
const scrollContainer = ref<HTMLDivElement | null>();
|
||||||
|
const gameState = ref("")
|
||||||
|
const gameStateText = ref("")
|
||||||
|
|
||||||
function getTeam() {
|
function getTeam() {
|
||||||
fetch(
|
fetch(
|
||||||
@ -87,6 +89,28 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getGame() {
|
||||||
|
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)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Автоматическая прокрутка при изменении items
|
// Автоматическая прокрутка при изменении items
|
||||||
watch(actions, () => {
|
watch(actions, () => {
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
@ -105,7 +129,10 @@
|
|||||||
|
|
||||||
getTeam()
|
getTeam()
|
||||||
|
|
||||||
intervalId = setInterval(() => {getTeam()}, 2000);
|
intervalId = setInterval(() => {
|
||||||
|
getTeam()
|
||||||
|
getGame()
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
@ -128,10 +155,19 @@
|
|||||||
<div class="center-block-custom">
|
<div class="center-block-custom">
|
||||||
<form @submit.prevent="addAction">
|
<form @submit.prevent="addAction">
|
||||||
<div>
|
<div>
|
||||||
<input class="input-custom" v-model="place" type="text" placeholder="Место назначения (А-1, а-1, а1)">
|
<input
|
||||||
|
class="input-custom"
|
||||||
|
v-model="place"
|
||||||
|
type="text"
|
||||||
|
placeholder="Место назначения (А-1, а-1, а1)"
|
||||||
|
:disabled="gameState == 'STOP'">
|
||||||
</div>
|
</div>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<button class="button-custom" type="submit">Поехали</button>
|
<div class="second-color">{{ gameStateText }}</div>
|
||||||
|
<button
|
||||||
|
class="button-custom"
|
||||||
|
type="submit"
|
||||||
|
:disabled="gameState == 'STOP'">Поехали</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -187,6 +223,10 @@ body {
|
|||||||
margin: 10px;
|
margin: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.second-color {
|
||||||
|
color: var(--second-color);
|
||||||
|
}
|
||||||
|
|
||||||
.form-custom {
|
.form-custom {
|
||||||
border: 1px solid #444444;
|
border: 1px solid #444444;
|
||||||
background-color: var(--main-back-color);
|
background-color: var(--main-back-color);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user