5 Commits
Author SHA1 Message Date
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 62 additions and 23 deletions
+1
View File
@@ -18,5 +18,6 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<script async src="https://comments.app/js/widget.js?3" data-comments-app-website="JSnN9CyA" data-limit="5" data-dislikes="1" data-outlined="1" data-dark="1"></script>
</body>
</html>
+3 -2
View File
@@ -1,12 +1,13 @@
{
"name": "frontend",
"version": "0.9.4",
"version": "0.9.6",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"postbuild": "scp -r dist/. root@uvpn.shop:/opt/uvpn.shop/frontend"
},
"dependencies": {
"@lucide/vue": "^1.16.0",
+58 -21
View File
@@ -1,17 +1,19 @@
<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>
<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"
>
<RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
{{ loading ? 'Обновление...' : 'Обновить пинг' }}
</button>
<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 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">
@@ -24,7 +26,7 @@
<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">
@@ -34,11 +36,17 @@
class="h-5 w-auto rounded-sm"
/>
<span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
<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' }}
<!-- Индикатор состояния (вместо online/offline) -->
<span class="relative flex h-2 w-2">
<span
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>
@@ -53,7 +61,7 @@
}"
>
<Wifi :size="14" />
{{ host.ping }}ms
{{ host.ping }} ms
</span>
<span v-else class="text-gray-300 font-mono"></span>
</div>
@@ -73,21 +81,48 @@ const error = ref(null)
const countriesList = getAllCountries()
// Ручной маппинг для проблемных стран
const countryOverrides = {
'United States': 'us',
'USA': 'us',
'U.S.A.': 'us',
'America': 'us',
'United Arab Emirates': 'ae',
'UAE': 'ae',
}
const findCountryByFirstWord = (name) => {
if (!name) return null
// 1. Проверяем ручные override
const override = countryOverrides[name]
if (override) {
return { code: override.toUpperCase() }
}
// 2. Ищем по первому слову
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
if (partial) return partial
// 3. Пробуем найти по полному имени
const fullMatch = countriesList.find(c =>
name.toLowerCase().includes(c.label.toLowerCase()) ||
c.label.toLowerCase().includes(name.toLowerCase())
)
return fullMatch || null
}
const sortedHosts = computed(() => {
@@ -157,7 +192,6 @@ const refreshData = async () => {
}
})
// Пингуем все хосты параллельно
const pings = await Promise.all(hosts.value.map(h => pingHost(h)))
hosts.value.forEach((h, i) => {
if (h.isOnline) h.ping = pings[i]
@@ -170,7 +204,10 @@ const refreshData = async () => {
}
}
onMounted(() => {
fetchHosts()
// При первом открытии — загружаем и пингуем
onMounted(async () => {
await fetchHosts()
// Автоматический пинг только при первом открытии
await refreshData()
})
</script>