generated from VLADIMIR/template_frontend
add story
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { Settings } from '@vicons/carbon'
|
||||
import { Icon } from '@vicons/utils'
|
||||
import { NButton, type UploadFileInfo, useMessage } from 'naive-ui'
|
||||
import { NCard, NFlex, NInput, NModal, NSpace, NText, NUpload, NUploadDragger, NAlert } from 'naive-ui'
|
||||
import { NCard, NFlex, NInput, NModal, NSpace, NText, NUpload, NUploadDragger, NAlert, NTag } from 'naive-ui'
|
||||
import { ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
@@ -69,7 +69,28 @@ async function publicScenario(id: number) {
|
||||
showSettingsScenarioModal.value = false
|
||||
}
|
||||
|
||||
|
||||
async function addGame(name: string, id: number) {
|
||||
const now = new Date().toISOString()
|
||||
const resAddGame = await client.AddGame({
|
||||
name: ('Тестовая игра: ' + name).trim(),
|
||||
description: 'Тестовая игра',
|
||||
startAt: now,
|
||||
scenarioId: id
|
||||
})
|
||||
if (resAddGame.error != '') {
|
||||
message.error(resAddGame.error!)
|
||||
return
|
||||
}
|
||||
const resAddTeam = await client.AddTeam({
|
||||
name: 'Тестовая команда',
|
||||
gameId: resAddGame.id!,
|
||||
})
|
||||
if (resAddTeam.error != '') {
|
||||
message.error(resAddTeam.error!)
|
||||
return
|
||||
}
|
||||
router.push("/team-story/" + resAddTeam.id! + '?password=' + resAddTeam.password!)
|
||||
}
|
||||
|
||||
async function draftScenario(id: number) {
|
||||
const res = await client.DraftScenario({ id: id })
|
||||
@@ -313,11 +334,21 @@ async function deletePlace(place: Place) {
|
||||
|
||||
<n-button @click="updateScenario()" ghost> Сохранить изменения </n-button>
|
||||
|
||||
<hr class="settings-hr" />
|
||||
<p>Создать тестовую игру</p>
|
||||
<n-button @click="addGame(scenario.name || '', scenario.id!)" ghost>
|
||||
Создать игру
|
||||
</n-button>
|
||||
|
||||
<hr class="settings-hr" />
|
||||
<p>Публикация</p>
|
||||
<p>Статус:
|
||||
<span v-if="scenario.status == 'public'">опубликовано</span>
|
||||
<span v-if="scenario.status == 'draft'">в разработке</span>
|
||||
<p>
|
||||
<n-tag v-if="scenario.status == 'public'" :bordered="false" type="success" class="status-block">
|
||||
Опубликовано
|
||||
</n-tag>
|
||||
<n-tag v-if="scenario.status == 'draft'" :bordered="false" type="warning" class="status-block">
|
||||
В разработке
|
||||
</n-tag>
|
||||
</p>
|
||||
<p>
|
||||
Введите название сценария <n-text class="name-text" strong>{{ scenario.name }}</n-text>
|
||||
|
||||
Reference in New Issue
Block a user