10 Commits
Author SHA1 Message Date
austnv b34adf908d Update package.json 2026-06-26 13:59:36 +03:00
austnv f7bcd58ba5 Update README.md 2026-06-26 13:58:56 +03:00
austnv 6a9b2ca31d v0.9.7
Build and Deploy Frontend via SSH / deploy (push) Failing after 42s
2026-06-26 13:47:19 +03:00
austnv 17a8db543e update NodesStatus.vue component: remove all invalid actions (LOL) 2026-06-26 13:46:25 +03:00
austnv 68aabbb361 remove comments 2026-06-26 12:31:08 +03:00
austnv 6e841b12f5 add comments.app script 2026-06-25 11:17:31 +03:00
austnv 7f227fcf05 fix: NodesStatus 2026-06-21 23:27:30 +03:00
austnv a34a646c71 fix: margin-bottom 2026-06-21 23:19:17 +03:00
austnv 4a0ce08338 fix: header & button
Build and Deploy Frontend via SSH / deploy (push) Successful in 43s
2026-06-21 23:16:28 +03:00
austnv 43749647ca fix: bugs in flags & autoping
Build and Deploy Frontend via SSH / deploy (push) Successful in 43s
2026-06-21 23:03:50 +03:00
3 changed files with 47 additions and 66 deletions
+1 -4
View File
@@ -14,7 +14,4 @@ npm install
npm run build
```
Ссылки:
* [Продакшн](https://uvpn.shop)
* [Тест](https://austnv-uvpn-frontend-7aca.twc1.net)
https://uvpn.shop
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.9.4",
"version": "0.9.7",
"private": true,
"type": "module",
"scripts": {
+30 -46
View File
@@ -1,18 +1,20 @@
<template>
<section class="px-6 py-20 md:px-12 max-w-7xl mx-auto">
<div class="flex items-center justify-between mb-10 flex-wrap gap-4">
<h2 class="text-3xl md:text-4xl font-bold">
<div class="mb-10">
<h2 class="text-3xl md:text-4xl font-bold text-center mb-14">
Статус серверов
</h2>
<div class="flex justify-center mt-6">
<button
@click="refreshData"
:disabled="loading"
class="px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-xl text-sm font-medium transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
class="px-5 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-xl text-sm font-medium transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 cursor-pointer"
>
<RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
{{ loading ? 'Обновление...' : 'Обновить пинг' }}
</button>
</div>
</div>
<div v-if="loading && !hosts.length" class="flex justify-center py-12">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
@@ -24,21 +26,28 @@
<div
v-for="host in sortedHosts"
:key="host.address"
class="flex items-center justify-between bg-white dark:bg-gray-900 rounded-xl px-4 py-2.5 border transition hover:shadow-md"
class="flex items-center justify-between bg-white dark:bg-gray-900 rounded-xl px-4 py-2.5 border"
:class="host.isOnline ? 'border-green-500/30' : 'border-red-500/30 opacity-60'"
>
<div class="flex items-center gap-3">
<img
v-if="host.countryCode"
:src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${host.countryCode}.svg`"
:src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${host.countryCode.toLowerCase()}.svg`"
class="h-5 w-auto rounded-sm"
:alt="host.name"
/>
<span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
<!-- Индикатор состояния -->
<span class="relative flex h-2 w-2">
<span
class="text-[10px] px-2 py-0.5 rounded-full font-medium"
:class="host.isOnline ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'"
>
{{ host.isOnline ? 'online' : 'offline' }}
class="animate-ping absolute inline-flex h-full w-full rounded-full opacity-75"
:class="host.isOnline ? 'bg-green-500' : 'bg-red-500'"
></span>
<span
class="relative inline-flex rounded-full h-2 w-2"
:class="host.isOnline ? 'bg-green-600' : 'bg-red-600'"
></span>
</span>
</div>
@@ -65,31 +74,11 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
import { Wifi, RefreshCw } from '@lucide/vue'
import { getAllCountries } from '@tw-labs/countries'
const hosts = ref([])
const loading = ref(true)
const error = ref(null)
const countriesList = getAllCountries()
const findCountryByFirstWord = (name) => {
if (!name) return null
const firstWord = name.split(' ')[0]
if (!firstWord) return null
const exact = countriesList.find(c =>
c.label.toLowerCase() === firstWord.toLowerCase()
)
if (exact) return exact
const partial = countriesList.find(c =>
firstWord.toLowerCase().includes(c.label.toLowerCase()) ||
c.label.toLowerCase().includes(firstWord.toLowerCase())
)
return partial || null
}
const sortedHosts = computed(() => {
return [...hosts.value].sort((a, b) => {
if (a.ping === null && b.ping === null) return 0
@@ -122,17 +111,14 @@ const fetchHosts = async () => {
if (!res.ok) throw new Error()
const data = await res.json()
hosts.value = data.map((h) => {
const country = findCountryByFirstWord(h.name)
return {
hosts.value = data.map((h) => ({
...h,
countryCode: country?.code?.toLowerCase() || null,
countryCode: h.country_code ? h.country_code.toLowerCase() : null,
isOnline: true,
ping: null,
}
})
}))
} catch {
error.value = 'Ошибка загрузки'
error.value = 'Ошибка загрузки данных'
} finally {
loading.value = false
}
@@ -147,30 +133,28 @@ const refreshData = async () => {
if (!res.ok) throw new Error()
const data = await res.json()
hosts.value = data.map((h) => {
const country = findCountryByFirstWord(h.name)
return {
hosts.value = data.map((h) => ({
...h,
countryCode: country?.code?.toLowerCase() || null,
countryCode: h.country_code ? h.country_code.toLowerCase() : null,
isOnline: true,
ping: null,
}
})
}))
// Пингуем все хосты параллельно
const pings = await Promise.all(hosts.value.map(h => pingHost(h)))
hosts.value.forEach((h, i) => {
if (h.isOnline) h.ping = pings[i]
h.ping = pings[i]
})
} catch {
error.value = 'Ошибка обновления'
error.value = 'Ошибка обновления данных'
} finally {
loading.value = false
}
}
onMounted(() => {
fetchHosts()
onMounted(async () => {
await fetchHosts()
await refreshData()
})
</script>