This commit is contained in:
2026-05-17 16:06:19 +07:00
parent 578e22b8f0
commit a5acda73ae
6 changed files with 400 additions and 1122 deletions
+1
View File
@@ -0,0 +1 @@
VITE_API_URL='https://evening-detective-api.crabs-games.art'
+1
View File
@@ -0,0 +1 @@
VITE_API_URL=''
+7 -2
View File
@@ -1,4 +1,9 @@
build:
npm run build
build-macos:
npm run build:local_web
rm -rf ../evening_detective/cmd/evening_detective/static/user
cp -r dist ../evening_detective/cmd/evening_detective/static/user
build-linux:
npm run build:global_web
rm -rf ../evening_detective/cmd/evening_detective/static/user
cp -r dist ../evening_detective/cmd/evening_detective/static/user
+373 -1107
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -5,6 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite",
"build:local_web": "vite build --mode local_web",
"build:global_web": "vite build --mode global_web",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"build-only": "vite build",
@@ -21,7 +23,7 @@
},
"devDependencies": {
"@tsconfig/node22": "^22.0.1",
"@types/node": "^22.14.0",
"@types/node": "^22.19.19",
"@vitejs/plugin-vue": "^5.2.3",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.5.0",
+15 -12
View File
@@ -1,6 +1,8 @@
import type { Game, Team } from './models'
import { UnauthorizedError } from './UnauthorizedError'
const API_URL = import.meta.env.VITE_API_URL;
export const apiGetTeam = async (login: string, password: string): Promise<Team> => {
try {
const response = await fetch(getApiUrl('/team'), {
@@ -25,15 +27,15 @@ export const apiGetTeam = async (login: string, password: string): Promise<Team>
export const apiLetsgo = async (login: string, password: string, place: string) => {
try {
const response = await fetch(getApiUrl("/team/actions"), {
method: "POST",
const response = await fetch(getApiUrl('/team/actions'), {
method: 'POST',
headers: {
"X-Id": encodeUTF8ToBase64(login),
"X-Password": password
'X-Id': encodeUTF8ToBase64(login),
'X-Password': password,
},
body: JSON.stringify({
"place": place
})
place: place,
}),
})
if (response.status === 401) {
throw new UnauthorizedError('Ошибка авторизации')
@@ -50,7 +52,7 @@ export const apiLetsgo = async (login: string, password: string, place: string)
export const apiGetGame = async (login: string, password: string): Promise<Game> => {
try {
const response = await fetch(getApiUrl("/game"), {
const response = await fetch(getApiUrl('/game'), {
method: 'GET',
headers: {
'X-Id': encodeUTF8ToBase64(login),
@@ -70,13 +72,14 @@ export const apiGetGame = async (login: string, password: string): Promise<Game>
}
}
export function getApiUrl(path: string) {
// const url = 'http://' + window.location.host.split(':')[0] + ':8090' + path
// return url
return 'https://evening-detective-api.crabs-games.art' + path
function getApiUrl(path: string) {
if (API_URL === '') {
return 'http://' + window.location.host.split(':')[0] + ':8090' + path
}
return API_URL + path
}
export function encodeUTF8ToBase64(s: string) {
function encodeUTF8ToBase64(s: string) {
return btoa(
encodeURIComponent(s).replace(/%([0-9A-F]{2})/g, (_, p1) =>
String.fromCharCode(parseInt(p1, 16)),