fix: bugs in flags & autoping
Build and Deploy Frontend via SSH / deploy (push) Successful in 43s

This commit is contained in:
austnv
2026-06-21 23:03:50 +03:00
parent 3dbacb4359
commit 43749647ca
2 changed files with 45 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.9.4",
"version": "0.9.5",
"private": true,
"type": "module",
"scripts": {
+44 -9
View File
@@ -34,11 +34,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-3 w-3">
<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-3 w-3"
:class="host.isOnline ? 'bg-green-600' : 'bg-red-600'"
></span>
</span>
</div>
@@ -73,21 +79,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 +190,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 +202,10 @@ const refreshData = async () => {
}
}
onMounted(() => {
fetchHosts()
// При первом открытии — загружаем и пингуем
onMounted(async () => {
await fetchHosts()
// Автоматический пинг только при первом открытии
await refreshData()
})
</script>