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