This commit is contained in:
2026-10-11 03:05:44 +07:00
parent 053f9bac68
commit a01fd5c452
3 changed files with 64 additions and 23 deletions
+13 -7
View File
@@ -8,18 +8,24 @@ import BeltBlock from './BeltBlock.vue'
import HeaderText from './HeaderText.vue' import HeaderText from './HeaderText.vue'
import MetalPlate from './MetalPlate.vue' import MetalPlate from './MetalPlate.vue'
const code = ref('')
const props = defineProps<{ const props = defineProps<{
addAction: (param: string) => void addAction: (param: string) => Promise<boolean>
allPlacesCount: number allPlacesCount: number
newPlacesCount: number newPlacesCount: number
gameStatus: string gameStatus: string
}>() }>()
const code = ref('')
const isSubmitting = ref(false)
async function addClickButton() { async function addClickButton() {
await props.addAction(code.value) if (isSubmitting.value || props.gameStatus != 'run' || code.value.length == 0) return
code.value = '' isSubmitting.value = true
try {
if (await props.addAction(code.value)) code.value = ''
} finally {
isSubmitting.value = false
}
} }
function getTextForCounter(count: number): string[] { function getTextForCounter(count: number): string[] {
@@ -87,14 +93,14 @@ function getTextForCounter(count: number): string[] {
v-model="code" v-model="code"
type="text" type="text"
:placeholder="props.gameStatus == 'run' ? 'Место назначения' : 'Ходы запрещены'" :placeholder="props.gameStatus == 'run' ? 'Место назначения' : 'Ходы запрещены'"
:disabled="props.gameStatus != 'run'" :disabled="props.gameStatus != 'run' || isSubmitting"
/> />
</div> </div>
<div class="game-button-run-shadow"></div> <div class="game-button-run-shadow"></div>
<button <button
class="game-button-run" class="game-button-run"
type="submit" type="submit"
:disabled="code.length == 0" :disabled="props.gameStatus != 'run' || code.length == 0 || isSubmitting"
v-on:click="addClickButton" v-on:click="addClickButton"
> >
<HeaderText v-if="props.gameStatus == 'run'">Поехали</HeaderText> <HeaderText v-if="props.gameStatus == 'run'">Поехали</HeaderText>
+35 -5
View File
@@ -1028,27 +1028,57 @@ useSimplePolling(() => {
</n-tag> </n-tag>
</n-space> </n-space>
<n-flex justify="end"> <n-flex justify="end">
<n-button type="info" v-if="game.status != 'draft'" dashed @click="resetGame()"> <n-button
type="info"
v-if="game.status != 'draft'"
dashed
aria-label="Сбросить игру"
@click="resetGame()"
>
<Icon> <Icon>
<Reset /> <Reset />
</Icon> </Icon>
</n-button> </n-button>
<n-button type="info" v-if="game.status == 'draft'" dashed @click="startGame()"> <n-button
type="info"
v-if="game.status == 'draft'"
dashed
aria-label="Начать игру"
@click="startGame()"
>
<Icon> <Icon>
<Play /> <Play />
</Icon> </Icon>
</n-button> </n-button>
<n-button type="info" v-if="game.status == 'pause'" dashed @click="playGame()"> <n-button
type="info"
v-if="game.status == 'pause'"
dashed
aria-label="Продолжить игру"
@click="playGame()"
>
<Icon> <Icon>
<Play /> <Play />
</Icon> </Icon>
</n-button> </n-button>
<n-button type="info" v-if="game.status == 'run'" dashed @click="pauseGame()"> <n-button
type="info"
v-if="game.status == 'run'"
dashed
aria-label="Поставить игру на паузу"
@click="pauseGame()"
>
<Icon> <Icon>
<Pause /> <Pause />
</Icon> </Icon>
</n-button> </n-button>
<n-button type="info" v-if="game.status != 'finish'" dashed @click="finishGame()"> <n-button
type="info"
v-if="game.status != 'finish'"
dashed
aria-label="Завершить игру"
@click="finishGame()"
>
<Icon> <Icon>
<Flag /> <Flag />
</Icon> </Icon>
+16 -11
View File
@@ -126,17 +126,22 @@ async function getStory() {
getStory() getStory()
getAnswers() getAnswers()
async function addAction(newCode: string) { async function addAction(newCode: string): Promise<boolean> {
await client.AddTeamAction({ try {
ID: Number(teamId), await client.AddTeamAction({
password: password as string, ID: Number(teamId),
code: newCode, password: password as string,
}) code: newCode,
await getStory() })
code.value = '' await getStory()
code.value = ''
await nextTick() await nextTick()
newPlacesCount.value = 0 newPlacesCount.value = 0
return true
} catch (err) {
message.error(err instanceof Error ? err.message : 'Не удалось сделать ход')
return false
}
} }
type AdvancedStory = { type AdvancedStory = {