generated from VLADIMIR/template_frontend
updates
This commit is contained in:
@@ -9,7 +9,6 @@ export type DownloadFileResult = {
|
||||
|
||||
export type UploadArchiveResult = {
|
||||
ID: number | null
|
||||
error: string | null
|
||||
}
|
||||
|
||||
// Клиент бинарных файлов: ZIP сценариев и PDF команд. Сгенерированный
|
||||
@@ -78,11 +77,10 @@ function buildBinaryClient(refreshTokens: () => Promise<boolean>, getToken: () =
|
||||
|
||||
const data = await response.json().catch(() => null)
|
||||
if (!response.ok) {
|
||||
return { ID: null, error: data?.message || `Ошибка сервера (${response.status})` }
|
||||
throw new Error(data?.message || `Ошибка сервера (${response.status})`)
|
||||
}
|
||||
|
||||
const error = typeof data?.error === 'string' && data.error !== '' ? data.error : null
|
||||
return { ID: typeof data?.ID === 'number' ? data.ID : null, error }
|
||||
return { ID: typeof data?.ID === 'number' ? data.ID : null }
|
||||
}
|
||||
|
||||
return { downloadScenarioArchive, downloadTeamQR, uploadScenarioArchive }
|
||||
|
||||
@@ -50,6 +50,12 @@ export function createHttpHandler(
|
||||
// Парсим ответ
|
||||
const data = await response.json()
|
||||
|
||||
if (data && typeof data === 'object' && 'code' in data && data.code !== 0) {
|
||||
throw new Error(
|
||||
'message' in data && typeof data.message === 'string' ? data.message : 'Ошибка запроса',
|
||||
)
|
||||
}
|
||||
|
||||
// Возвращаем в формате, который ожидает генератор
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ export type SignupReq = {
|
||||
};
|
||||
|
||||
export type SignupRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type RefreshPasswordReq = {
|
||||
@@ -60,7 +59,6 @@ export type RefreshPasswordReq = {
|
||||
};
|
||||
|
||||
export type RefreshPasswordRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type LoginReq = {
|
||||
@@ -69,7 +67,6 @@ export type LoginReq = {
|
||||
};
|
||||
|
||||
export type LoginRsp = {
|
||||
error: string | undefined;
|
||||
accessToken: string | undefined;
|
||||
refreshToken: string | undefined;
|
||||
};
|
||||
@@ -79,7 +76,6 @@ export type RefreshReq = {
|
||||
};
|
||||
|
||||
export type RefreshRsp = {
|
||||
error: string | undefined;
|
||||
accessToken: string | undefined;
|
||||
refreshToken: string | undefined;
|
||||
};
|
||||
@@ -92,7 +88,6 @@ export type DeleteAccountReq = {
|
||||
};
|
||||
|
||||
export type DeleteAccountRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
// Документы раздаются по постоянным URL, на которые ссылается сервис при
|
||||
@@ -101,7 +96,6 @@ export type GetTermsReq = {
|
||||
};
|
||||
|
||||
export type GetTermsRsp = {
|
||||
error: string | undefined;
|
||||
text: string | undefined;
|
||||
};
|
||||
|
||||
@@ -109,7 +103,6 @@ export type GetPrivacyReq = {
|
||||
};
|
||||
|
||||
export type GetPrivacyRsp = {
|
||||
error: string | undefined;
|
||||
text: string | undefined;
|
||||
};
|
||||
|
||||
@@ -117,7 +110,6 @@ export type GetConsentReq = {
|
||||
};
|
||||
|
||||
export type GetConsentRsp = {
|
||||
error: string | undefined;
|
||||
text: string | undefined;
|
||||
};
|
||||
|
||||
@@ -125,7 +117,6 @@ export type GetUsersReq = {
|
||||
};
|
||||
|
||||
export type GetUsersRsp = {
|
||||
error: string | undefined;
|
||||
users: User[] | undefined;
|
||||
};
|
||||
|
||||
@@ -148,7 +139,6 @@ export type GetUserByIDReq = {
|
||||
};
|
||||
|
||||
export type GetUserByIDRsp = {
|
||||
error: string | undefined;
|
||||
user: User | undefined;
|
||||
};
|
||||
|
||||
@@ -156,7 +146,6 @@ export type GetMeReq = {
|
||||
};
|
||||
|
||||
export type GetMeRsp = {
|
||||
error: string | undefined;
|
||||
user: User | undefined;
|
||||
};
|
||||
|
||||
@@ -174,7 +163,6 @@ export type AddUserRoleReq = {
|
||||
};
|
||||
|
||||
export type AddUserRoleRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteUserRoleReq = {
|
||||
@@ -183,14 +171,12 @@ export type DeleteUserRoleReq = {
|
||||
};
|
||||
|
||||
export type DeleteUserRoleRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type GetPermissionsReq = {
|
||||
};
|
||||
|
||||
export type GetPermissionsRsp = {
|
||||
error: string | undefined;
|
||||
permissions: string[] | undefined;
|
||||
};
|
||||
|
||||
@@ -200,7 +186,6 @@ export type UploadFileReq = {
|
||||
};
|
||||
|
||||
export type UploadFileRsp = {
|
||||
error: string | undefined;
|
||||
filename: string | undefined;
|
||||
// Тип загруженного файла: image | pdf | audio | video (определяется сервером по
|
||||
// содержимому). Удобен редактору для предзаполнения file_type улики.
|
||||
@@ -216,7 +201,6 @@ export type AddScenarioReq = {
|
||||
};
|
||||
|
||||
export type AddScenarioRsp = {
|
||||
error: string | undefined;
|
||||
ID: number | undefined;
|
||||
};
|
||||
|
||||
@@ -224,7 +208,6 @@ export type GetMyScenariosReq = {
|
||||
};
|
||||
|
||||
export type GetMyScenariosRsp = {
|
||||
error: string | undefined;
|
||||
scenarios: Scenario[] | undefined;
|
||||
};
|
||||
|
||||
@@ -307,7 +290,6 @@ export type GetScenariosCatalogReq = {
|
||||
};
|
||||
|
||||
export type GetScenariosCatalogRsp = {
|
||||
error: string | undefined;
|
||||
scenarios: Scenario[] | undefined;
|
||||
};
|
||||
|
||||
@@ -316,7 +298,6 @@ export type GetScenarioReq = {
|
||||
};
|
||||
|
||||
export type GetScenarioRsp = {
|
||||
error: string | undefined;
|
||||
scenario: Scenario | undefined;
|
||||
};
|
||||
|
||||
@@ -369,7 +350,6 @@ export type UpdateScenarioReq = {
|
||||
};
|
||||
|
||||
export type UpdateScenarioRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type PublicScenarioReq = {
|
||||
@@ -377,7 +357,6 @@ export type PublicScenarioReq = {
|
||||
};
|
||||
|
||||
export type PublicScenarioRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DraftScenarioReq = {
|
||||
@@ -385,7 +364,6 @@ export type DraftScenarioReq = {
|
||||
};
|
||||
|
||||
export type DraftScenarioRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteScenarioReq = {
|
||||
@@ -393,7 +371,6 @@ export type DeleteScenarioReq = {
|
||||
};
|
||||
|
||||
export type DeleteScenarioRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type AddScenarioPlaceReq = {
|
||||
@@ -402,7 +379,6 @@ export type AddScenarioPlaceReq = {
|
||||
};
|
||||
|
||||
export type AddScenarioPlaceRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type UpdateScenarioPlaceReq = {
|
||||
@@ -412,7 +388,6 @@ export type UpdateScenarioPlaceReq = {
|
||||
};
|
||||
|
||||
export type UpdateScenarioPlaceRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteScenarioPlaceReq = {
|
||||
@@ -421,7 +396,6 @@ export type DeleteScenarioPlaceReq = {
|
||||
};
|
||||
|
||||
export type DeleteScenarioPlaceRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type UpdateScenarioConclusionReq = {
|
||||
@@ -430,7 +404,6 @@ export type UpdateScenarioConclusionReq = {
|
||||
};
|
||||
|
||||
export type UpdateScenarioConclusionRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type UpdateScenarioIntroReq = {
|
||||
@@ -439,7 +412,6 @@ export type UpdateScenarioIntroReq = {
|
||||
};
|
||||
|
||||
export type UpdateScenarioIntroRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type AddScenarioQuestionReq = {
|
||||
@@ -448,7 +420,6 @@ export type AddScenarioQuestionReq = {
|
||||
};
|
||||
|
||||
export type AddScenarioQuestionRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type UpdateScenarioQuestionReq = {
|
||||
@@ -458,7 +429,6 @@ export type UpdateScenarioQuestionReq = {
|
||||
};
|
||||
|
||||
export type UpdateScenarioQuestionRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteScenarioQuestionReq = {
|
||||
@@ -467,7 +437,6 @@ export type DeleteScenarioQuestionReq = {
|
||||
};
|
||||
|
||||
export type DeleteScenarioQuestionRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DownloadScenarioArchiveReq = {
|
||||
@@ -475,7 +444,6 @@ export type DownloadScenarioArchiveReq = {
|
||||
};
|
||||
|
||||
export type UploadScenarioArchiveRsp = {
|
||||
error: string | undefined;
|
||||
ID: number | undefined;
|
||||
};
|
||||
|
||||
@@ -489,7 +457,6 @@ export type AddGameReq = {
|
||||
};
|
||||
|
||||
export type AddGameRsp = {
|
||||
error: string | undefined;
|
||||
ID: number | undefined;
|
||||
};
|
||||
|
||||
@@ -497,7 +464,6 @@ export type GetGamesReq = {
|
||||
};
|
||||
|
||||
export type GetGamesRsp = {
|
||||
error: string | undefined;
|
||||
games: Game[] | undefined;
|
||||
};
|
||||
|
||||
@@ -541,7 +507,6 @@ export type CreateScreenSessionReq = {
|
||||
};
|
||||
|
||||
export type CreateScreenSessionRsp = {
|
||||
error: string | undefined;
|
||||
screenID: string | undefined;
|
||||
accessToken: string | undefined;
|
||||
};
|
||||
@@ -552,7 +517,6 @@ export type GetScreenStateReq = {
|
||||
};
|
||||
|
||||
export type GetScreenStateRsp = {
|
||||
error: string | undefined;
|
||||
state: ScreenState | undefined;
|
||||
};
|
||||
|
||||
@@ -561,7 +525,6 @@ export type GetGameScreensReq = {
|
||||
};
|
||||
|
||||
export type GetGameScreensRsp = {
|
||||
error: string | undefined;
|
||||
screens: ScreenState[] | undefined;
|
||||
};
|
||||
|
||||
@@ -572,7 +535,6 @@ export type BindScreenReq = {
|
||||
};
|
||||
|
||||
export type BindScreenRsp = {
|
||||
error: string | undefined;
|
||||
state: ScreenState | undefined;
|
||||
};
|
||||
|
||||
@@ -581,7 +543,6 @@ export type UnbindScreenReq = {
|
||||
};
|
||||
|
||||
export type UnbindScreenRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type SetScreenSoundReq = {
|
||||
@@ -590,7 +551,6 @@ export type SetScreenSoundReq = {
|
||||
};
|
||||
|
||||
export type SetScreenSoundRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type MapItem = {
|
||||
@@ -609,7 +569,6 @@ export type GetGameMapReq = {
|
||||
};
|
||||
|
||||
export type GetGameMapRsp = {
|
||||
error: string | undefined;
|
||||
items: MapItem[] | undefined;
|
||||
};
|
||||
|
||||
@@ -623,7 +582,6 @@ export type UpdateGameMapItemReq = {
|
||||
};
|
||||
|
||||
export type UpdateGameMapItemRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type SetScreenModeReq = {
|
||||
@@ -632,7 +590,6 @@ export type SetScreenModeReq = {
|
||||
};
|
||||
|
||||
export type SetScreenModeRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type SetScreenTimerReq = {
|
||||
@@ -642,7 +599,6 @@ export type SetScreenTimerReq = {
|
||||
};
|
||||
|
||||
export type SetScreenTimerRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type SendScreenCommandReq = {
|
||||
@@ -653,7 +609,6 @@ export type SendScreenCommandReq = {
|
||||
};
|
||||
|
||||
export type SendScreenCommandRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type GetScreenResultsReq = {
|
||||
@@ -662,7 +617,6 @@ export type GetScreenResultsReq = {
|
||||
};
|
||||
|
||||
export type GetScreenResultsRsp = {
|
||||
error: string | undefined;
|
||||
questions: ResultsQuestion[] | undefined;
|
||||
teams: TeamResult[] | undefined;
|
||||
};
|
||||
@@ -701,8 +655,6 @@ export type AnswerParticipationReq = {
|
||||
};
|
||||
|
||||
export type ParticipationRsp = {
|
||||
// Пустая строка при успехе; иначе сообщение об ошибке для пользователя.
|
||||
error: string | undefined;
|
||||
// Название команды. Данные доступны только по действительному токену.
|
||||
teamName: string | undefined;
|
||||
// Название игры.
|
||||
@@ -723,7 +675,6 @@ export type GetGameReq = {
|
||||
};
|
||||
|
||||
export type GetGameRsp = {
|
||||
error: string | undefined;
|
||||
game: Game | undefined;
|
||||
};
|
||||
|
||||
@@ -732,7 +683,6 @@ export type GetGameAnswersReq = {
|
||||
};
|
||||
|
||||
export type GetGameAnswersRsp = {
|
||||
error: string | undefined;
|
||||
questions: Question[] | undefined;
|
||||
teams: TeamAnswers[] | undefined;
|
||||
};
|
||||
@@ -742,7 +692,6 @@ export type GetGameResultsReq = {
|
||||
};
|
||||
|
||||
export type GetGameResultsRsp = {
|
||||
error: string | undefined;
|
||||
questions: ResultsQuestion[] | undefined;
|
||||
teams: TeamResult[] | undefined;
|
||||
};
|
||||
@@ -768,7 +717,6 @@ export type CreateGameReviewReq = {
|
||||
};
|
||||
|
||||
export type CreateGameReviewRsp = {
|
||||
error: string | undefined;
|
||||
review: GameReview | undefined;
|
||||
};
|
||||
|
||||
@@ -784,7 +732,6 @@ export type GetReviewsForModerationReq = {
|
||||
};
|
||||
|
||||
export type GetGameReviewsRsp = {
|
||||
error: string | undefined;
|
||||
averageRating: number | undefined;
|
||||
reviewsCount: number | undefined;
|
||||
reviews: GameReview[] | undefined;
|
||||
@@ -796,7 +743,6 @@ export type ModerateGameReviewReq = {
|
||||
};
|
||||
|
||||
export type ModerateGameReviewRsp = {
|
||||
error: string | undefined;
|
||||
review: GameReview | undefined;
|
||||
};
|
||||
|
||||
@@ -811,7 +757,6 @@ export type UpdateGameReq = {
|
||||
};
|
||||
|
||||
export type UpdateGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type StartGameReq = {
|
||||
@@ -819,7 +764,6 @@ export type StartGameReq = {
|
||||
};
|
||||
|
||||
export type StartGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type PauseGameReq = {
|
||||
@@ -827,7 +771,6 @@ export type PauseGameReq = {
|
||||
};
|
||||
|
||||
export type PauseGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type PlayGameReq = {
|
||||
@@ -835,7 +778,6 @@ export type PlayGameReq = {
|
||||
};
|
||||
|
||||
export type PlayGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type FinishGameReq = {
|
||||
@@ -843,7 +785,6 @@ export type FinishGameReq = {
|
||||
};
|
||||
|
||||
export type FinishGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type ResetGameReq = {
|
||||
@@ -851,7 +792,6 @@ export type ResetGameReq = {
|
||||
};
|
||||
|
||||
export type ResetGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteGameReq = {
|
||||
@@ -859,7 +799,6 @@ export type DeleteGameReq = {
|
||||
};
|
||||
|
||||
export type DeleteGameRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type AddTeamReq = {
|
||||
@@ -869,7 +808,6 @@ export type AddTeamReq = {
|
||||
};
|
||||
|
||||
export type AddTeamRsp = {
|
||||
error: string | undefined;
|
||||
ID: number | undefined;
|
||||
password: string | undefined;
|
||||
};
|
||||
@@ -880,7 +818,6 @@ export type UpdateTeamReq = {
|
||||
};
|
||||
|
||||
export type UpdateTeamRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteTeamReq = {
|
||||
@@ -888,7 +825,6 @@ export type DeleteTeamReq = {
|
||||
};
|
||||
|
||||
export type DeleteTeamRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type GiveTeamApplicationsReq = {
|
||||
@@ -897,7 +833,6 @@ export type GiveTeamApplicationsReq = {
|
||||
};
|
||||
|
||||
export type GiveTeamApplicationsRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type GetTeamStoryReq = {
|
||||
@@ -906,7 +841,6 @@ export type GetTeamStoryReq = {
|
||||
};
|
||||
|
||||
export type GetTeamStoryRsp = {
|
||||
error: string | undefined;
|
||||
story: Story | undefined;
|
||||
game: Game | undefined;
|
||||
actions: TeamAction[] | undefined;
|
||||
@@ -924,7 +858,6 @@ export type AddTeamActionReq = {
|
||||
};
|
||||
|
||||
export type AddTeamActionRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type DeleteLastTeamActionReq = {
|
||||
@@ -932,7 +865,6 @@ export type DeleteLastTeamActionReq = {
|
||||
};
|
||||
|
||||
export type DeleteLastTeamActionRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type GetTeamAnswersReq = {
|
||||
@@ -941,7 +873,6 @@ export type GetTeamAnswersReq = {
|
||||
};
|
||||
|
||||
export type GetTeamAnswersRsp = {
|
||||
error: string | undefined;
|
||||
answers: Answer[] | undefined;
|
||||
};
|
||||
|
||||
@@ -952,7 +883,6 @@ export type SubmitTeamAnswersReq = {
|
||||
};
|
||||
|
||||
export type SubmitTeamAnswersRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type SetTeamAnswerScoreReq = {
|
||||
@@ -963,7 +893,6 @@ export type SetTeamAnswerScoreReq = {
|
||||
};
|
||||
|
||||
export type SetTeamAnswerScoreRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type UpdateScenarioBackgroundReq = {
|
||||
@@ -972,7 +901,6 @@ export type UpdateScenarioBackgroundReq = {
|
||||
};
|
||||
|
||||
export type UpdateScenarioBackgroundRsp = {
|
||||
error: string | undefined;
|
||||
};
|
||||
|
||||
export type IssueGameTicketsReq = {
|
||||
@@ -981,7 +909,6 @@ export type IssueGameTicketsReq = {
|
||||
};
|
||||
|
||||
export type IssueGameTicketsRsp = {
|
||||
error: string | undefined;
|
||||
tickets: Ticket[] | undefined;
|
||||
};
|
||||
|
||||
@@ -995,7 +922,6 @@ export type GetTicketReq = {
|
||||
};
|
||||
|
||||
export type GetTicketRsp = {
|
||||
error: string | undefined;
|
||||
ticket: TicketPage | undefined;
|
||||
};
|
||||
|
||||
@@ -1015,7 +941,6 @@ export type AcceptTicketReq = {
|
||||
};
|
||||
|
||||
export type AcceptTicketRsp = {
|
||||
error: string | undefined;
|
||||
ticket: TicketPage | undefined;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,11 +30,7 @@ onMounted(async () => {
|
||||
|
||||
try {
|
||||
const res = await fetchers[props.kind]()
|
||||
if (res.error) {
|
||||
error.value = res.error
|
||||
} else {
|
||||
text.value = res.text || ''
|
||||
}
|
||||
text.value = res.text || ''
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Не удалось загрузить документ'
|
||||
} finally {
|
||||
|
||||
+21
-105
@@ -136,10 +136,6 @@ let panState: { startX: number; startY: number; offsetX: number; offsetY: number
|
||||
|
||||
async function getGame(id: number) {
|
||||
const res = await client.GetGame({ ID: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
game.value = res.game!
|
||||
game.value.teams = game.value.teams?.sort((a, b) => {
|
||||
let aLen = 0
|
||||
@@ -172,9 +168,6 @@ getGame(Number(gameId))
|
||||
|
||||
async function getGameScreens() {
|
||||
const res = await client.GetGameScreens({ gameID: Number(gameId) })
|
||||
if (res.error != '') {
|
||||
return
|
||||
}
|
||||
screens.value = res.screens || []
|
||||
if (!timerFormInitialized.value && screens.value[0]) {
|
||||
timerDurationMinutes.value = Math.max(1, (screens.value[0].timerDurationSeconds || 600) / 60)
|
||||
@@ -183,10 +176,8 @@ async function getGameScreens() {
|
||||
}
|
||||
if (previewScreen.value?.mode === 'SCREEN_MODE_RESULTS') {
|
||||
const result = await client.GetGameResults({ gameID: Number(gameId) })
|
||||
if (result.error == '') {
|
||||
previewQuestions.value = result.questions || []
|
||||
previewTeams.value = result.teams || []
|
||||
}
|
||||
previewQuestions.value = result.questions || []
|
||||
previewTeams.value = result.teams || []
|
||||
} else {
|
||||
previewQuestions.value = []
|
||||
previewTeams.value = []
|
||||
@@ -197,14 +188,14 @@ getGameScreens()
|
||||
async function getGameMap() {
|
||||
if (dragState || mapSaving.value) return
|
||||
const res = await client.GetGameMap({ gameID: Number(gameId) })
|
||||
if (res.error == '') mapItems.value = res.items || []
|
||||
mapItems.value = res.items || []
|
||||
}
|
||||
getGameMap()
|
||||
|
||||
async function saveMapItem(item: MapItem, hidden = item.hidden) {
|
||||
mapSaving.value = true
|
||||
try {
|
||||
const res = await client.UpdateGameMapItem({
|
||||
await client.UpdateGameMapItem({
|
||||
gameID: Number(gameId),
|
||||
kind: item.kind,
|
||||
itemID: item.itemID,
|
||||
@@ -212,7 +203,6 @@ async function saveMapItem(item: MapItem, hidden = item.hidden) {
|
||||
y: Math.round(item.y || 0),
|
||||
hidden,
|
||||
})
|
||||
if (res.error != '') message.error(res.error || 'Не удалось сохранить координаты')
|
||||
} finally {
|
||||
mapSaving.value = false
|
||||
}
|
||||
@@ -295,26 +285,17 @@ function zoomMap(event: WheelEvent) {
|
||||
}
|
||||
|
||||
async function setSoundScreen(screen: ScreenState) {
|
||||
const res = await client.SetScreenSound({ screenID: screen.ID, soundEnabled: true })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.SetScreenSound({ screenID: screen.ID, soundEnabled: true })
|
||||
await getGameScreens()
|
||||
}
|
||||
|
||||
async function unbindScreen(screen: ScreenState) {
|
||||
const res = await client.UnbindScreen({ screenID: screen.ID })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.UnbindScreen({ screenID: screen.ID })
|
||||
await getGameScreens()
|
||||
}
|
||||
|
||||
async function setScreenMode(mode: ScreenMode) {
|
||||
const res = await client.SetScreenMode({ gameID: Number(gameId), mode })
|
||||
if (res.error != '') message.error(res.error || 'Не удалось изменить режим экранов')
|
||||
await client.SetScreenMode({ gameID: Number(gameId), mode })
|
||||
}
|
||||
|
||||
async function configureScreenTimer() {
|
||||
@@ -324,15 +305,11 @@ async function configureScreenTimer() {
|
||||
message.error('Укажите длительность и надпись таймера')
|
||||
return
|
||||
}
|
||||
const res = await client.SetScreenTimer({
|
||||
await client.SetScreenTimer({
|
||||
gameID: Number(gameId),
|
||||
durationSeconds: Math.round(durationMinutes * 60),
|
||||
label,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error || 'Не удалось настроить таймер')
|
||||
return
|
||||
}
|
||||
await getGameScreens()
|
||||
}
|
||||
|
||||
@@ -340,13 +317,12 @@ async function sendScreenCommand(command: ScreenCommand) {
|
||||
if (command === 'SCREEN_COMMAND_PLAY' || command === 'SCREEN_COMMAND_REPLAY') {
|
||||
if (!window.confirm('Запустить медиа на всех экранах?')) return
|
||||
}
|
||||
const res = await client.SendScreenCommand({
|
||||
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))),
|
||||
})
|
||||
if (res.error != '') message.error(res.error || 'Не удалось выполнить команду экранов')
|
||||
}
|
||||
|
||||
async function toTeamStory(id: number, password: string, newTab: boolean = false) {
|
||||
@@ -397,7 +373,7 @@ function closeSettings() {
|
||||
}
|
||||
|
||||
async function updateGame() {
|
||||
const res = await client.UpdateGame({
|
||||
await client.UpdateGame({
|
||||
ID: game.value.ID,
|
||||
name: settingsDraft.value.name,
|
||||
description: settingsDraft.value.description,
|
||||
@@ -406,10 +382,6 @@ async function updateGame() {
|
||||
startAt: game.value.startAt,
|
||||
scenarioID: game.value.scenario?.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
showSettingsModal.value = false
|
||||
}
|
||||
@@ -460,29 +432,21 @@ function giveApplication(team: Team, application: Application) {
|
||||
}
|
||||
|
||||
async function addTeam() {
|
||||
const res = await client.AddTeam({
|
||||
await client.AddTeam({
|
||||
gameID: game.value.ID,
|
||||
name: newTeamName.value,
|
||||
captainEmail: newTeamEmail.value.trim(),
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
showAddTeamModal.value = false
|
||||
newTeamEmail.value = ''
|
||||
}
|
||||
|
||||
async function confirmGiveApplication() {
|
||||
const res = await client.GiveTeamApplications({
|
||||
await client.GiveTeamApplications({
|
||||
ID: giveApplicationTeam.value.ID,
|
||||
name: giveApplicationApplication.value.name,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
showGiveApplicationModal.value = false
|
||||
}
|
||||
@@ -493,25 +457,17 @@ async function deleteTeam(team: Team) {
|
||||
}
|
||||
|
||||
async function confirmDeleteTeam() {
|
||||
const res = await client.DeleteTeam({
|
||||
await client.DeleteTeam({
|
||||
ID: deletedTeam.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
showDeleteTeamModal.value = false
|
||||
}
|
||||
|
||||
async function deleteGame() {
|
||||
const res = await client.DeleteGame({
|
||||
await client.DeleteGame({
|
||||
ID: game.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
message.success('Игра удалена')
|
||||
router.push('/games')
|
||||
}
|
||||
@@ -540,10 +496,6 @@ async function issueTickets() {
|
||||
gameID: game.value.ID,
|
||||
count: ticketCount.value,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
issuedTickets.value = res.tickets || []
|
||||
message.success(`Выпущено билетов: ${issuedTickets.value.length}`)
|
||||
} catch (err) {
|
||||
@@ -560,57 +512,37 @@ useSimplePolling(() => {
|
||||
}, 2000)
|
||||
|
||||
async function resetGame() {
|
||||
const res = await client.ResetGame({
|
||||
await client.ResetGame({
|
||||
ID: game.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
}
|
||||
|
||||
async function startGame() {
|
||||
const res = await client.StartGame({
|
||||
await client.StartGame({
|
||||
ID: game.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
}
|
||||
|
||||
async function pauseGame() {
|
||||
const res = await client.PauseGame({
|
||||
await client.PauseGame({
|
||||
ID: game.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
}
|
||||
|
||||
async function playGame() {
|
||||
const res = await client.PlayGame({
|
||||
await client.PlayGame({
|
||||
ID: game.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
}
|
||||
|
||||
async function finishGame() {
|
||||
const res = await client.FinishGame({
|
||||
await client.FinishGame({
|
||||
ID: game.value.ID,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getGame(game.value.ID!)
|
||||
}
|
||||
|
||||
@@ -640,10 +572,6 @@ function onScoreUpdate(key: string, value: number | null) {
|
||||
|
||||
async function loadGameAnswers() {
|
||||
const res = await client.GetGameAnswers({ gameID: Number(gameId) })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
answersQuestions.value = res.questions || []
|
||||
answersTeams.value = res.teams || []
|
||||
const next: Record<string, number | undefined> = {}
|
||||
@@ -663,21 +591,13 @@ async function openAnswersModal() {
|
||||
async function openReviewsModal() {
|
||||
showReviewsModal.value = true
|
||||
const res = await client.GetGameReviewsForModeration({ gameID: Number(gameId) })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
gameReviews.value = res.reviews || []
|
||||
reviewsAverage.value = res.averageRating || 0
|
||||
reviewsCount.value = res.reviewsCount || 0
|
||||
}
|
||||
|
||||
async function moderateReview(review: GameReview, status: string) {
|
||||
const res = await client.ModerateGameReview({ ID: review.ID, status })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.ModerateGameReview({ ID: review.ID, status })
|
||||
await openReviewsModal()
|
||||
}
|
||||
|
||||
@@ -686,15 +606,11 @@ async function saveAllScores() {
|
||||
for (const question of answersQuestions.value) {
|
||||
for (const team of answersTeams.value) {
|
||||
const score = scores.value[scoreKey(team.team?.ID, question.code)]
|
||||
const res = await client.SetTeamAnswerScore({
|
||||
await client.SetTeamAnswerScore({
|
||||
ID: team.team?.ID,
|
||||
questionCode: question.code,
|
||||
score: score === undefined || score === null ? undefined : score,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
message.success('Баллы сохранены')
|
||||
|
||||
@@ -41,13 +41,6 @@ async function loadGameResults() {
|
||||
sessionIssue.value = false
|
||||
try {
|
||||
const res = await client.GetGameResults({ gameID: Number(gameId) })
|
||||
if (res.error != '') {
|
||||
// res.error может отсутствовать, если сервер ответил не-Rsp-ошибкой (например, 403)
|
||||
loadError.value = res.error || 'Не удалось загрузить результаты'
|
||||
message.error(loadError.value)
|
||||
loadFailed.value = true
|
||||
return
|
||||
}
|
||||
questions.value = res.questions || []
|
||||
teams.value = res.teams || []
|
||||
loaded.value = true
|
||||
|
||||
@@ -25,13 +25,13 @@ const router = useRouter()
|
||||
const games = ref<Game[]>([])
|
||||
|
||||
async function getGames() {
|
||||
games.value = []
|
||||
const res = await client.GetGames({})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
games.value = []
|
||||
const res = await client.GetGames({})
|
||||
games.value = res.games || []
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить игры')
|
||||
}
|
||||
games.value = res.games || []
|
||||
}
|
||||
getGames()
|
||||
|
||||
@@ -68,11 +68,6 @@ async function getCatalogScenarios() {
|
||||
catalogError.value = false
|
||||
try {
|
||||
const res = await client.GetScenariosCatalog({})
|
||||
if (res.error != '') {
|
||||
catalogError.value = true
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
catalogScenarios.value = res.scenarios || []
|
||||
} catch (err) {
|
||||
catalogError.value = true
|
||||
@@ -111,10 +106,6 @@ async function createGame() {
|
||||
startAt: new Date(startAtMs).toISOString(),
|
||||
scenarioID: scenarioId,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
message.success('Игра создана')
|
||||
showCreateGameModal.value = false
|
||||
router.push('/games/' + res.ID!)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NCard, NSpace, useMessage } from 'naive-ui'
|
||||
import { NButton, NCard, NSpace } from 'naive-ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
@@ -15,7 +15,6 @@ const token = params.get('token') || ''
|
||||
const answer = ref(params.get('answer') === 'cancelled' ? 'cancelled' : 'confirmed')
|
||||
const client = buildClient()
|
||||
const authStore = useAuthStore()
|
||||
const message = useMessage()
|
||||
const participation = ref<ParticipationRsp>()
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
@@ -25,11 +24,6 @@ async function load() {
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await client.GetParticipation({ token })
|
||||
if (res.error) {
|
||||
error.value = res.error
|
||||
message.error(res.error)
|
||||
return
|
||||
}
|
||||
participation.value = res
|
||||
} catch {
|
||||
error.value = 'Не удалось загрузить данные. Попробуйте ещё раз.'
|
||||
@@ -44,11 +38,7 @@ async function submit() {
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await client.AnswerParticipation({ token, answer: answer.value })
|
||||
if (res.status) participation.value = res
|
||||
if (res.error) {
|
||||
error.value = res.error
|
||||
message.error(res.error)
|
||||
}
|
||||
participation.value = res
|
||||
} catch {
|
||||
error.value = 'Не удалось сохранить ответ. Попробуйте ещё раз.'
|
||||
} finally {
|
||||
|
||||
@@ -11,21 +11,21 @@ const message = useMessage()
|
||||
const reviews = ref<GameReview[]>([])
|
||||
|
||||
async function loadReviews() {
|
||||
const res = await client.GetReviewsForModeration({})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
const res = await client.GetReviewsForModeration({})
|
||||
reviews.value = res.reviews || []
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить отзывы')
|
||||
}
|
||||
reviews.value = res.reviews || []
|
||||
}
|
||||
|
||||
async function moderate(review: GameReview, status: string) {
|
||||
const res = await client.ModerateGameReview({ ID: review.ID, status })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
await client.ModerateGameReview({ ID: review.ID, status })
|
||||
await loadReviews()
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось изменить отзыв')
|
||||
}
|
||||
await loadReviews()
|
||||
}
|
||||
|
||||
loadReviews()
|
||||
|
||||
@@ -28,22 +28,22 @@ const scenario = ref<Scenario>({
|
||||
})
|
||||
|
||||
async function getScenario(id: number) {
|
||||
const res = await client.GetScenario({ ID: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
const res = await client.GetScenario({ ID: id })
|
||||
scenario.value = res.scenario!
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить сценарий')
|
||||
}
|
||||
scenario.value = res.scenario!
|
||||
}
|
||||
getScenario(Number(scenarioId))
|
||||
|
||||
async function getReviews(id: number) {
|
||||
const res = await client.GetScenarioReviews({ scenarioID: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
const res = await client.GetScenarioReviews({ scenarioID: id })
|
||||
reviews.value = res.reviews || []
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить отзывы')
|
||||
}
|
||||
reviews.value = res.reviews || []
|
||||
}
|
||||
getReviews(Number(scenarioId))
|
||||
</script>
|
||||
|
||||
@@ -101,11 +101,7 @@ async function updateConclusion(remove = false) {
|
||||
video = uploaded.filename
|
||||
}
|
||||
const saved = remove ? { text: '', video: '' } : { text: conclusion.value.text, video }
|
||||
const res = await client.UpdateScenarioConclusion({ ID: scenario.value.ID, conclusion: saved })
|
||||
if (res.error) {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.UpdateScenarioConclusion({ ID: scenario.value.ID, conclusion: saved })
|
||||
scenario.value.story!.conclusion = saved
|
||||
resetConclusion()
|
||||
message.success(remove ? 'Закрывашка удалена' : 'Закрывашка сохранена')
|
||||
@@ -148,10 +144,6 @@ const editorQuestions = computed<EditableQuestion[]>(() => {
|
||||
|
||||
async function getScenario(id: number) {
|
||||
const res = await client.GetFullScenario({ ID: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
scenario.value = res.scenario!
|
||||
resetConclusion()
|
||||
scenario.value.story?.places?.forEach((item) => {
|
||||
@@ -170,20 +162,12 @@ async function getScenario(id: number) {
|
||||
getScenario(Number(scenarioId))
|
||||
|
||||
async function deleteScenario(id: number) {
|
||||
const res = await client.DeleteScenario({ ID: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.DeleteScenario({ ID: id })
|
||||
router.push('/scenarios')
|
||||
}
|
||||
|
||||
async function publicScenario(id: number) {
|
||||
const res = await client.PublicScenario({ ID: id })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.PublicScenario({ ID: id })
|
||||
await getScenario(Number(scenarioId))
|
||||
statusScenarioName.value = ''
|
||||
showSettingsModal.value = false
|
||||
@@ -199,28 +183,16 @@ async function addGame(name: string, id: number) {
|
||||
startAt: now,
|
||||
scenarioID: id,
|
||||
})
|
||||
if (resAddGame.error != '') {
|
||||
message.error(resAddGame.error!)
|
||||
return
|
||||
}
|
||||
const resAddTeam = await client.AddTeam({
|
||||
name: 'Тестовая команда',
|
||||
captainEmail: '',
|
||||
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 })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await client.DraftScenario({ ID: id })
|
||||
await getScenario(Number(scenarioId))
|
||||
statusScenarioName.value = ''
|
||||
showSettingsModal.value = false
|
||||
@@ -265,11 +237,6 @@ async function uploadFile(file: File | null, filename: string): Promise<UploadFi
|
||||
filename: filename,
|
||||
data: uint8ToBase64(bytes),
|
||||
})
|
||||
if (resUploadFile.error != '') {
|
||||
message.error(resUploadFile.error!)
|
||||
return { filename: '', fileType: '' }
|
||||
}
|
||||
|
||||
// file_type возвращает сервер по содержимому файла (image | pdf | audio | video) —
|
||||
// редактор сохраняет его на улике.
|
||||
return {
|
||||
@@ -292,16 +259,12 @@ async function updateScenario() {
|
||||
resUploadFilename = uploaded.filename
|
||||
}
|
||||
|
||||
const res = await client.UpdateScenario({
|
||||
await client.UpdateScenario({
|
||||
ID: scenario.value.ID,
|
||||
name: scenario.value.name,
|
||||
description: scenario.value.description,
|
||||
image: resUploadFilename,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
showSettingsModal.value = false
|
||||
}
|
||||
@@ -328,7 +291,7 @@ const text = ref('')
|
||||
const mode = ref('mini-add')
|
||||
|
||||
async function addPlace() {
|
||||
const res = await client.AddScenarioPlace({
|
||||
await client.AddScenarioPlace({
|
||||
ID: scenario.value.ID,
|
||||
place: {
|
||||
code: code.value,
|
||||
@@ -341,10 +304,6 @@ async function addPlace() {
|
||||
keys: undefined,
|
||||
},
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
|
||||
code.value = ''
|
||||
@@ -366,7 +325,7 @@ async function addNotFoundDoors(scenario: Scenario, place: EditablePlace) {
|
||||
return place.code == door.code
|
||||
})
|
||||
if (place == undefined) {
|
||||
const res = await client.AddScenarioPlace({
|
||||
await client.AddScenarioPlace({
|
||||
ID: scenario.ID,
|
||||
place: {
|
||||
code: door.code,
|
||||
@@ -379,10 +338,6 @@ async function addNotFoundDoors(scenario: Scenario, place: EditablePlace) {
|
||||
keys: undefined,
|
||||
},
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,29 +386,21 @@ async function updatePlace(place: EditablePlace) {
|
||||
}
|
||||
|
||||
await addNotFoundDoors(scenario.value, place)
|
||||
const res = await client.UpdateScenarioPlace({
|
||||
await client.UpdateScenarioPlace({
|
||||
ID: scenario.value.ID,
|
||||
code: place.oldCode,
|
||||
place: place,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
|
||||
place.mode = 'show-editor'
|
||||
}
|
||||
|
||||
async function deletePlace(place: EditablePlace) {
|
||||
const res = await client.DeleteScenarioPlace({
|
||||
await client.DeleteScenarioPlace({
|
||||
ID: scenario.value.ID,
|
||||
code: place.oldCode,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
}
|
||||
|
||||
@@ -463,7 +410,7 @@ const newQuestionAnswer = ref('')
|
||||
const questionMode = ref('mini-add')
|
||||
|
||||
async function addQuestion() {
|
||||
const res = await client.AddScenarioQuestion({
|
||||
await client.AddScenarioQuestion({
|
||||
ID: scenario.value.ID,
|
||||
question: {
|
||||
code: newQuestionCode.value,
|
||||
@@ -471,10 +418,6 @@ async function addQuestion() {
|
||||
answer: newQuestionAnswer.value,
|
||||
},
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
|
||||
newQuestionCode.value = ''
|
||||
@@ -491,7 +434,7 @@ async function cancelAddQuestion() {
|
||||
}
|
||||
|
||||
async function updateQuestion(question: EditableQuestion) {
|
||||
const res = await client.UpdateScenarioQuestion({
|
||||
await client.UpdateScenarioQuestion({
|
||||
ID: scenario.value.ID,
|
||||
code: question.oldCode,
|
||||
question: {
|
||||
@@ -500,10 +443,6 @@ async function updateQuestion(question: EditableQuestion) {
|
||||
answer: question.answer,
|
||||
},
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
|
||||
question.mode = 'show-editor'
|
||||
@@ -516,14 +455,10 @@ async function cancelUpdateQuestion(question: EditableQuestion) {
|
||||
}
|
||||
|
||||
async function deleteQuestion(question: EditableQuestion) {
|
||||
const res = await client.DeleteScenarioQuestion({
|
||||
await client.DeleteScenarioQuestion({
|
||||
ID: scenario.value.ID,
|
||||
code: question.oldCode,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
}
|
||||
|
||||
@@ -553,17 +488,13 @@ async function updateIntro() {
|
||||
audio = toRawFilename(intro.value.audio)
|
||||
}
|
||||
|
||||
const res = await client.UpdateScenarioIntro({
|
||||
await client.UpdateScenarioIntro({
|
||||
ID: scenario.value.ID,
|
||||
introduction: {
|
||||
text: intro.value.text,
|
||||
audio: audio,
|
||||
},
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getScenario(Number(scenarioId))
|
||||
}
|
||||
|
||||
@@ -585,11 +516,7 @@ async function updateBackground(remove = false) {
|
||||
}
|
||||
background = uploaded.filename
|
||||
}
|
||||
const res = await client.UpdateScenarioBackground({ ID: scenario.value.ID, background })
|
||||
if (res.error) {
|
||||
message.error(res.error)
|
||||
return
|
||||
}
|
||||
await client.UpdateScenarioBackground({ ID: scenario.value.ID, background })
|
||||
await getScenario(Number(scenarioId))
|
||||
backgroundFiles.value = []
|
||||
} catch {
|
||||
|
||||
@@ -39,18 +39,22 @@ const importFileList = ref<UploadFileInfo[]>([])
|
||||
const isImporting = ref(false)
|
||||
|
||||
async function getScenarios() {
|
||||
scenarios.value = []
|
||||
const res = await client.GetMyScenarios({})
|
||||
scenarios.value = res.scenarios!
|
||||
try {
|
||||
scenarios.value = []
|
||||
const res = await client.GetMyScenarios({})
|
||||
scenarios.value = res.scenarios!
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить сценарии')
|
||||
}
|
||||
}
|
||||
|
||||
async function addScenario(name: string) {
|
||||
const res = await client.AddScenario({ name: name })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
const res = await client.AddScenario({ name: name })
|
||||
await toScenarioEditor(res.ID!)
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось создать сценарий')
|
||||
}
|
||||
await toScenarioEditor(res.ID!)
|
||||
}
|
||||
|
||||
async function toScenarioEditor(id: number) {
|
||||
@@ -70,10 +74,6 @@ async function importScenario() {
|
||||
isImporting.value = true
|
||||
try {
|
||||
const res = await archiveClient.uploadScenarioArchive(file)
|
||||
if (res.error) {
|
||||
message.error(res.error)
|
||||
return
|
||||
}
|
||||
message.success('Сценарий импортирован из архива')
|
||||
resetImport()
|
||||
await toScenarioEditor(res.ID!)
|
||||
|
||||
@@ -100,9 +100,7 @@ function readSession() {
|
||||
|
||||
async function createSession() {
|
||||
const res = await client.CreateScreenSession({})
|
||||
if (res.error || !res.screenID || !res.accessToken) {
|
||||
throw new Error(res.error || 'Не удалось создать сессию экрана')
|
||||
}
|
||||
if (!res.screenID || !res.accessToken) throw new Error('Не удалось создать сессию экрана')
|
||||
screenId.value = res.screenID
|
||||
accessToken.value = res.accessToken
|
||||
saveSession()
|
||||
@@ -112,7 +110,6 @@ async function loadState() {
|
||||
if (!screenId.value || !accessToken.value) return
|
||||
try {
|
||||
const res = await client.GetScreenState({ screenID: screenId.value, accessToken: accessToken.value })
|
||||
if (res.error) throw new Error(res.error)
|
||||
state.value = res.state
|
||||
syncTimer(state.value)
|
||||
if (state.value?.gameID && state.value.mode === 'SCREEN_MODE_RESULTS') await loadResults()
|
||||
@@ -124,23 +121,21 @@ async function loadState() {
|
||||
async function loadResults() {
|
||||
if (!screenId.value || !accessToken.value) return
|
||||
const res = await client.GetScreenResults({ screenID: screenId.value, accessToken: accessToken.value })
|
||||
if (res.error == '') {
|
||||
resultQuestions.value = res.questions || []
|
||||
resultTeams.value = res.teams || []
|
||||
if (!resultsScrollStarted) {
|
||||
resultsScrollStarted = true
|
||||
await nextTick()
|
||||
const container = resultsContainer.value
|
||||
if (container) {
|
||||
container.scrollTop = container.scrollHeight
|
||||
resultsScrollTimer = window.setInterval(() => {
|
||||
container.scrollTop = Math.max(0, container.scrollTop - 32)
|
||||
if (container.scrollTop === 0 && resultsScrollTimer != null) {
|
||||
window.clearInterval(resultsScrollTimer)
|
||||
resultsScrollTimer = undefined
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
resultQuestions.value = res.questions || []
|
||||
resultTeams.value = res.teams || []
|
||||
if (!resultsScrollStarted) {
|
||||
resultsScrollStarted = true
|
||||
await nextTick()
|
||||
const container = resultsContainer.value
|
||||
if (container) {
|
||||
container.scrollTop = container.scrollHeight
|
||||
resultsScrollTimer = window.setInterval(() => {
|
||||
container.scrollTop = Math.max(0, container.scrollTop - 32)
|
||||
if (container.scrollTop === 0 && resultsScrollTimer != null) {
|
||||
window.clearInterval(resultsScrollTimer)
|
||||
resultsScrollTimer = undefined
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,7 +143,6 @@ async function loadResults() {
|
||||
async function loadGames() {
|
||||
try {
|
||||
const res = await client.GetGames({})
|
||||
if (res.error) throw new Error(res.error)
|
||||
games.value = res.games || []
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить игры')
|
||||
@@ -183,12 +177,11 @@ async function bind() {
|
||||
if (!selectedGameId.value || !route.query.screenID || !route.query.accessToken) return
|
||||
binding.value = true
|
||||
try {
|
||||
const res = await client.BindScreen({
|
||||
await client.BindScreen({
|
||||
screenID: String(route.query.screenID),
|
||||
accessToken: String(route.query.accessToken),
|
||||
gameID: selectedGameId.value,
|
||||
})
|
||||
if (res.error) throw new Error(res.error)
|
||||
bindSuccess.value = true
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось привязать экран')
|
||||
|
||||
@@ -74,11 +74,6 @@ async function getStory() {
|
||||
ID: Number(teamId),
|
||||
password: password as string,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
|
||||
game.value = res.game
|
||||
|
||||
const wasAtBottom = isAtBottom()
|
||||
@@ -121,15 +116,11 @@ getStory()
|
||||
getAnswers()
|
||||
|
||||
async function addAction(newCode: string) {
|
||||
const res = await client.AddTeamAction({
|
||||
await client.AddTeamAction({
|
||||
ID: Number(teamId),
|
||||
password: password as string,
|
||||
code: newCode,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getStory()
|
||||
code.value = ''
|
||||
|
||||
@@ -157,10 +148,6 @@ async function getAnswers() {
|
||||
ID: Number(teamId),
|
||||
password: password as string,
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
const next: Record<string, string> = {}
|
||||
for (const answer of res.answers || []) {
|
||||
next[answer.questionCode || ''] = answer.answer || ''
|
||||
@@ -169,7 +156,7 @@ async function getAnswers() {
|
||||
}
|
||||
|
||||
async function submitAnswers() {
|
||||
const res = await client.SubmitTeamAnswers({
|
||||
await client.SubmitTeamAnswers({
|
||||
ID: Number(teamId),
|
||||
password: password as string,
|
||||
answers: (story.value.questions || []).map((question) => ({
|
||||
@@ -177,10 +164,6 @@ async function submitAnswers() {
|
||||
answer: answers.value[question.code || ''] || '',
|
||||
})),
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
message.success('Ответы сохранены')
|
||||
await getAnswers()
|
||||
}
|
||||
@@ -230,7 +213,7 @@ async function submitReview() {
|
||||
return
|
||||
}
|
||||
reviewLoading.value = true
|
||||
const res = await client.CreateGameReview({
|
||||
await client.CreateGameReview({
|
||||
gameID: Number(game.value?.ID),
|
||||
teamID: Number(teamId),
|
||||
password: password as string,
|
||||
@@ -238,23 +221,15 @@ async function submitReview() {
|
||||
text: reviewText.value.trim(),
|
||||
})
|
||||
reviewLoading.value = false
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
reviewSubmitted.value = true
|
||||
localStorage.setItem(reviewKey, '1')
|
||||
message.success('Спасибо за отзыв')
|
||||
}
|
||||
|
||||
async function deleteLast() {
|
||||
const res = await client.DeleteLastTeamAction({
|
||||
await client.DeleteLastTeamAction({
|
||||
ID: Number(teamId),
|
||||
})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
}
|
||||
await getStory()
|
||||
code.value = ''
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ async function load() {
|
||||
error.value = ''
|
||||
try {
|
||||
const result = await client.GetTicket({ token: token.value })
|
||||
if (result.error || !result.ticket) {
|
||||
error.value = result.error || 'Билет не найден'
|
||||
if (!result.ticket) {
|
||||
error.value = 'Билет не найден'
|
||||
return
|
||||
}
|
||||
ticket.value = result.ticket
|
||||
|
||||
@@ -39,7 +39,7 @@ async function findTicket() {
|
||||
ticket.value = undefined
|
||||
try {
|
||||
const result = await client.GetTicket({ token: token.value })
|
||||
if (result.error || !result.ticket) error.value = result.error || 'Билет не найден'
|
||||
if (!result.ticket) error.value = 'Билет не найден'
|
||||
else ticket.value = result.ticket
|
||||
} catch (err) {
|
||||
error.value = err instanceof Error ? err.message : 'Не удалось проверить билет'
|
||||
@@ -54,7 +54,7 @@ async function acceptTicket() {
|
||||
error.value = ''
|
||||
try {
|
||||
const result = await client.AcceptTicket({ token: token.value })
|
||||
if (result.error || !result.ticket) error.value = result.error || 'Не удалось принять билет'
|
||||
if (!result.ticket) error.value = 'Не удалось принять билет'
|
||||
else {
|
||||
ticket.value = result.ticket
|
||||
message.success('Билет принят')
|
||||
|
||||
@@ -46,31 +46,31 @@ async function changePassword() {
|
||||
}
|
||||
|
||||
async function getUsers() {
|
||||
const res = await client.GetUsers({})
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
const res = await client.GetUsers({})
|
||||
users.value = res.users!
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось загрузить пользователей')
|
||||
}
|
||||
users.value = res.users!
|
||||
}
|
||||
getUsers()
|
||||
|
||||
async function addRole(userId: number, role: string) {
|
||||
const res = await client.AddUserRole({ ID: userId, role: role })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
await client.AddUserRole({ ID: userId, role: role })
|
||||
await getUsers()
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось изменить роль')
|
||||
}
|
||||
await getUsers()
|
||||
}
|
||||
|
||||
async function deleteRole(userId: number, role: string) {
|
||||
const res = await client.DeleteUserRole({ ID: userId, role: role })
|
||||
if (res.error != '') {
|
||||
message.error(res.error!)
|
||||
return
|
||||
try {
|
||||
await client.DeleteUserRole({ ID: userId, role: role })
|
||||
await getUsers()
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : 'Не удалось изменить роль')
|
||||
}
|
||||
await getUsers()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
+4
-29
@@ -45,11 +45,6 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const client = buildClient(getToken)
|
||||
const response = await client.GetMe({})
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
return
|
||||
}
|
||||
|
||||
if (response.user) {
|
||||
user.value = response.user
|
||||
}
|
||||
@@ -71,11 +66,6 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const client = buildClient(getToken)
|
||||
const response = await client.Login({ email, password })
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
return false
|
||||
}
|
||||
|
||||
// Сохраняем токены
|
||||
if (response.accessToken) {
|
||||
accessToken.value = response.accessToken
|
||||
@@ -112,7 +102,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
refreshToken: refreshToken.value,
|
||||
})
|
||||
|
||||
if (response.error || !response.accessToken) {
|
||||
if (!response.accessToken) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -143,12 +133,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
|
||||
try {
|
||||
const client = buildClient(getToken)
|
||||
const response = await client.Signup({ username, email, acceptTerms, acceptPrivacy })
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
return false
|
||||
}
|
||||
await client.Signup({ username, email, acceptTerms, acceptPrivacy })
|
||||
|
||||
return true
|
||||
} catch (err) {
|
||||
@@ -167,12 +152,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
try {
|
||||
// Пароль передаётся HTTP-заголовком X-Password, а не в URL или body
|
||||
const client = buildClient(getToken, () => ({ 'X-Password': password }))
|
||||
const response = await client.DeleteAccount({})
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
return false
|
||||
}
|
||||
await client.DeleteAccount({})
|
||||
|
||||
await logout()
|
||||
return true
|
||||
@@ -191,12 +171,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
|
||||
try {
|
||||
const client = buildClient(getToken)
|
||||
const response = await client.RefreshPassword({ email })
|
||||
|
||||
if (response.error) {
|
||||
error.value = response.error
|
||||
return false
|
||||
}
|
||||
await client.RefreshPassword({ email })
|
||||
|
||||
return true
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user