generated from VLADIMIR/template_frontend
add qr-s
This commit is contained in:
@@ -8,6 +8,7 @@ import { ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import { getAuthClient } from '@/api/auth_client'
|
||||
import { getBinaryClient } from '@/api/binary_client'
|
||||
import type {
|
||||
Application,
|
||||
Game,
|
||||
@@ -22,6 +23,8 @@ import { applicationFileType, applicationFileURL } from '@/utils/application'
|
||||
import { formatGameDateTime, parseDateWithoutTimezone } from '@/utils/datetime'
|
||||
|
||||
const client = getAuthClient()
|
||||
const binaryClient = getBinaryClient()
|
||||
const isDownloadingQR = ref(false)
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const gameId = route.params.id
|
||||
@@ -95,6 +98,26 @@ async function toTeamStory(id: number, password: string, newTab: boolean = false
|
||||
router.push(uri)
|
||||
}
|
||||
|
||||
async function downloadTeamQR() {
|
||||
if (isDownloadingQR.value || !game.value.teams?.length) return
|
||||
isDownloadingQR.value = true
|
||||
try {
|
||||
const { blob, filename } = await binaryClient.downloadTeamQR(game.value.id!)
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = filename
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000)
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось скачать QR команд')
|
||||
} finally {
|
||||
isDownloadingQR.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toResults() {
|
||||
router.push('/games/' + gameId + '/results')
|
||||
}
|
||||
@@ -410,6 +433,9 @@ useSimplePolling(() => {
|
||||
</Icon>
|
||||
Итоги
|
||||
</n-button>
|
||||
<n-button v-if="game.teams?.length" quaternary :loading="isDownloadingQR" :disabled="isDownloadingQR" @click="downloadTeamQR()">
|
||||
QR команд
|
||||
</n-button>
|
||||
<n-button quaternary @click="openSettings()">
|
||||
<Icon class="settings-icon">
|
||||
<Settings />
|
||||
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
import { getArchiveClient } from '@/api/archive_client'
|
||||
import { getAuthClient } from '@/api/auth_client'
|
||||
import { getBinaryClient } from '@/api/binary_client'
|
||||
import type { Conclusion, Scenario } from '@/api/generated/crabs/evening_detective_server'
|
||||
import HeaderMenu from '@/components/HeaderMenu.vue'
|
||||
import IntroBlock from '@/components/IntroBlock.vue'
|
||||
@@ -36,7 +36,7 @@ import { applicationFileURL } from '@/utils/application'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const client = getAuthClient()
|
||||
const archiveClient = getArchiveClient()
|
||||
const archiveClient = getBinaryClient()
|
||||
const route = useRoute()
|
||||
const scenarioId = route.params.id
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ import {
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { getArchiveClient } from '@/api/archive_client'
|
||||
import { getAuthClient } from '@/api/auth_client'
|
||||
import { getBinaryClient } from '@/api/binary_client'
|
||||
import type { Scenario } from '@/api/generated/crabs/evening_detective_server'
|
||||
import HeaderMenu from '@/components/HeaderMenu.vue'
|
||||
|
||||
const client = getAuthClient()
|
||||
const archiveClient = getArchiveClient()
|
||||
const archiveClient = getBinaryClient()
|
||||
|
||||
const scenarios = ref<Scenario[]>([])
|
||||
|
||||
@@ -218,8 +218,8 @@ getScenarios()
|
||||
<style scoped>
|
||||
.center-block-custom {
|
||||
height: calc(100dvh - 70px);
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow: hidden auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user