diff --git a/dist/index.html b/dist/index.html index cdad031..26ac9a2 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ Вечерний детектив - + diff --git a/src/components/GamePage.vue b/src/components/GamePage.vue index 47b19bd..3154ebc 100644 --- a/src/components/GamePage.vue +++ b/src/components/GamePage.vue @@ -112,21 +112,13 @@ const screenPlan = ref() const screenPlanDraft = ref([]) const screenPlanDirty = ref(false) const screenPlanSaving = ref(false) +const screenPlanMode = ref<'use' | 'edit'>('use') const previewQuestions = ref([]) const previewTeams = ref([]) const mapItems = ref([]) const mapSaving = ref(false) const screenVolume = ref(100) const screenPosition = ref(0) -const timerDurationMinutes = ref(10) -const timerLabel = ref('Перерыв') -const timerFormInitialized = ref(false) -const currentScreenMode = computed(() => { - const modes = screens.value.map((screen) => screen.mode).filter(Boolean) - if (!modes.length || modes.some((mode) => mode !== modes[0])) return undefined - return modes[0] as ScreenMode -}) -const timerScreen = computed(() => screens.value[0]) const previewScreen = computed(() => screens.value.find((screen) => screen.status === 'connected') || screens.value[0]) const hasDisconnectedScreen = computed(() => screens.value.some((screen) => screen.status === 'disconnected')) const screenPlanModeOptions = [ @@ -139,22 +131,6 @@ const screenPlanModeOptions = [ { label: 'Таймер', value: 'SCREEN_MODE_TIMER' }, { label: 'Текст', value: 'SCREEN_MODE_TEXT' }, ] -const timerStateLabel = computed(() => { - switch (timerScreen.value?.timerState) { - case 'SCREEN_TIMER_STATE_RUNNING': - return 'Идёт' - case 'SCREEN_TIMER_STATE_PAUSED': - return 'Пауза' - case 'SCREEN_TIMER_STATE_FINISHED': - return 'Завершён' - default: - return 'Остановлен' - } -}) -const timerRemainingLabel = computed(() => { - const seconds = Math.max(0, timerScreen.value?.timerRemainingSeconds || 0) - return `${String(Math.floor(seconds / 60)).padStart(2, '0')}:${String(seconds % 60).padStart(2, '0')}` -}) const mapScale = ref(1) const mapOffset = ref({ x: 0, y: 0 }) let dragState: @@ -196,11 +172,6 @@ getGame(Number(gameId)) async function getGameScreens() { const res = await client.GetGameScreens({ gameID: Number(gameId) }) screens.value = res.screens || [] - if (!timerFormInitialized.value && screens.value[0]) { - timerDurationMinutes.value = Math.max(1, (screens.value[0].timerDurationSeconds || 600) / 60) - timerLabel.value = screens.value[0].timerLabel || 'Перерыв' - timerFormInitialized.value = true - } if (previewScreen.value?.mode === 'SCREEN_MODE_RESULTS') { const result = await client.GetGameResults({ gameID: Number(gameId) }) previewQuestions.value = result.questions || [] @@ -229,6 +200,20 @@ function addScreenPlanStep() { timerDurationSeconds: 600, }) screenPlanDirty.value = true + screenPlanMode.value = 'edit' +} + +function editScreenPlan() { + if (!screenPlan.value) return + screenPlanDraft.value = screenPlan.value.steps?.map((step) => ({ ...step })) || [] + screenPlanMode.value = 'edit' +} + +function cancelScreenPlanEdit() { + if (screenPlanDirty.value && !window.confirm('Отменить несохранённые изменения плана?')) return + screenPlanDraft.value = screenPlan.value?.steps?.map((step) => ({ ...step })) || [] + screenPlanDirty.value = false + screenPlanMode.value = 'use' } function removeScreenPlanStep(index: number) { @@ -271,7 +256,7 @@ async function saveScreenPlan() { screenPlan.value = res.plan screenPlanDraft.value = res.plan?.steps?.map((step) => ({ ...step })) || [] screenPlanDirty.value = false - await getGameScreens() + screenPlanMode.value = 'use' message.success(res.plan ? 'План экранов сохранён' : 'План экранов удалён') } catch (err) { message.error(err instanceof Error ? err.message : 'Не удалось сохранить план экранов') @@ -502,37 +487,6 @@ async function unbindScreen(screen: ScreenState) { await getGameScreens() } -async function setScreenMode(mode: ScreenMode) { - await client.SetScreenMode({ gameID: Number(gameId), mode }) -} - -async function configureScreenTimer() { - const durationMinutes = timerDurationMinutes.value - const label = timerLabel.value.trim() - if (!durationMinutes || durationMinutes <= 0 || !label) { - message.error('Укажите длительность и надпись таймера') - return - } - await client.SetScreenTimer({ - gameID: Number(gameId), - durationSeconds: Math.round(durationMinutes * 60), - label, - }) - await getGameScreens() -} - -async function sendScreenCommand(command: ScreenCommand) { - if (command === 'SCREEN_COMMAND_PLAY' || command === 'SCREEN_COMMAND_REPLAY') { - if (!window.confirm('Запустить медиа на всех экранах?')) return - } - await client.SendScreenCommand({ - gameID: Number(gameId), - command, - positionMs: Math.max(0, Math.round(screenPosition.value * 1000)), - volume: Math.max(0, Math.min(100, Math.round(screenVolume.value))), - }) -} - async function toTeamStory(id: number, password: string, newTab: boolean = false) { const uri = '/team-story/' + id + '?password=' + password if (newTab) { @@ -980,115 +934,26 @@ useSimplePolling(() => { -

План экранов

- + Создать план - - Сохранить план - + +
-