Compare commits

..

2 Commits

Author SHA1 Message Date
75c11b36a6 rm net 2025-05-18 22:59:20 +07:00
02c5451c5b errors 2025-05-18 22:13:25 +07:00
3 changed files with 36 additions and 20 deletions

View File

@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, nextTick, watch, onMounted } from 'vue'; import { ref, nextTick, watch, onMounted } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { host } from './net';
const router = useRouter(); const router = useRouter();
@ -28,7 +27,7 @@
function getTeam() { function getTeam() {
fetch( fetch(
host+"/team", "/team",
{ {
method: "GET", method: "GET",
headers: { headers: {
@ -52,16 +51,19 @@
} }
function addAction() { function addAction() {
fetch(host+"/team/actions", { fetch(
method: "POST", "/team/actions",
headers: { {
"X-Id": sessionStorage.getItem("teamId") || "", method: "POST",
"X-Password": sessionStorage.getItem("password") || "" headers: {
}, "X-Id": sessionStorage.getItem("teamId") || "",
body: JSON.stringify({ "X-Password": sessionStorage.getItem("password") || ""
"place": place.value },
}) body: JSON.stringify({
}) "place": place.value
})
}
)
.then(async () => {place.value = ""}) .then(async () => {place.value = ""})
} }

View File

@ -1,15 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { host } from './net';
const router = useRouter(); const router = useRouter();
const login = ref("") const login = ref("")
const password = ref("") const password = ref("")
const buttonText = ref("Вход")
const errorMsg = ref("")
function onClickLogin() { function onClickLogin() {
const oldText = buttonText.value
buttonText.value = "Загрузка..."
errorMsg.value = ""
fetch( fetch(
host+"/team", "/team",
{ {
method: "GET", method: "GET",
headers: { headers: {
@ -24,11 +29,15 @@
sessionStorage.setItem("password", password.value) sessionStorage.setItem("password", password.value)
router.push('/'); router.push('/');
} }
if (response.status == 401) {
errorMsg.value = "Не верны название команды или пароль"
}
}) })
.catch(error => {console.error('Ошибка:', error)}); .catch(() => {
errorMsg.value = "Сервер не доступен"
})
.finally(() => {buttonText.value = oldText});
} }
onClickLogin()
</script> </script>
<template> <template>
@ -45,12 +54,18 @@
<input class="input-custom" v-model="password" type="text" placeholder="Пароль" autocapitalize="off"> <input class="input-custom" v-model="password" type="text" placeholder="Пароль" autocapitalize="off">
</div> </div>
<div class="button-container"> <div class="button-container">
<button class="button-custom" type="submit">Вход</button> <button class="button-custom" type="submit">{{ buttonText }}</button>
</div>
<div class="error-message">
{{ errorMsg }}
</div> </div>
</form> </form>
</div> </div>
</template> </template>
<style scoped> <style scoped>
.error-message {
color: brown;
margin: 16px 0;
}
</style> </style>

View File

@ -1 +0,0 @@
export const host = "http://192.168.0.110:8090"