Compare commits
9
Commits
a34a646c71
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d5902ea1f | ||
|
|
d17afb505a | ||
|
|
b34adf908d | ||
|
|
f7bcd58ba5 | ||
|
|
6a9b2ca31d | ||
|
|
17a8db543e | ||
|
|
68aabbb361 | ||
|
|
6e841b12f5 | ||
|
|
7f227fcf05 |
@@ -14,7 +14,4 @@ npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
Ссылки:
|
||||
|
||||
* [Продакшн](https://uvpn.shop)
|
||||
* [Тест](https://austnv-uvpn-frontend-7aca.twc1.net)
|
||||
https://uvpn.shop
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "0.9.6",
|
||||
"version": "0.9.7",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -36,7 +36,7 @@ const faqItems = [
|
||||
},
|
||||
{
|
||||
question: 'Какая реальная скорость соединения?',
|
||||
answer: 'Наши серверы поддерживают до 1 Гбит/с. Для стриминга 4K достаточно 25 Мбит/с — этого у нас с запасом. Реальная скорость зависит от вашего провайдера и выбранного сервера.'
|
||||
answer: 'Наши серверы поддерживают до 10 Гбит/с. Для стриминга 4K достаточно 25 Мбит/с — этого у нас с запасом. Реальная скорость зависит от вашего провайдера и выбранного сервера.'
|
||||
},
|
||||
{
|
||||
question: 'Есть ли гарантия возврата денег?',
|
||||
@@ -44,7 +44,7 @@ const faqItems = [
|
||||
},
|
||||
{
|
||||
question: 'Сколько устройств можно подключить одновременно?',
|
||||
answer: 'Standard — до 3 устройств, Premium — до 10 устройств одновременно. Для семьи или небольшого офиса идеально подойдёт Premium.'
|
||||
answer: 'Lite — до 3 устройств, Pro — до 5 устройств, Ultra — до 10 устройств одновременно. Для личного пользования лучший выбор Lite, для себя и друга — Pro. Для семьи или небольшого офиса идеально подойдёт Ultra.'
|
||||
},
|
||||
{
|
||||
question: 'Хранит ли uVPN логи моей активности?',
|
||||
|
||||
@@ -25,26 +25,30 @@
|
||||
<div v-else class="space-y-2 max-w-3xl mx-auto">
|
||||
<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"
|
||||
:key="host.address + host.port"
|
||||
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"
|
||||
@error="handleFlagError"
|
||||
/>
|
||||
<div v-else class="h-5 w-7 rounded-sm bg-gray-200 dark:bg-gray-700 flex items-center justify-center text-xs">
|
||||
🌐
|
||||
</div>
|
||||
<span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
|
||||
|
||||
<!-- Индикатор состояния (вместо online/offline) -->
|
||||
<span class="relative flex h-3 w-3">
|
||||
<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-3 w-3"
|
||||
class="relative inline-flex rounded-full h-2 w-2"
|
||||
:class="host.isOnline ? 'bg-green-600' : 'bg-red-600'"
|
||||
></span>
|
||||
</span>
|
||||
@@ -52,7 +56,7 @@
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<span
|
||||
v-if="host.ping !== undefined && host.ping !== null"
|
||||
v-if="host.ping !== undefined && host.ping !== null && host.ping !== 0"
|
||||
class="font-mono font-semibold flex items-center gap-1.5"
|
||||
:class="{
|
||||
'text-green-600': host.ping < 200,
|
||||
@@ -61,9 +65,9 @@
|
||||
}"
|
||||
>
|
||||
<Wifi :size="14" />
|
||||
{{ host.ping }}ms
|
||||
{{ host.ping }} ms
|
||||
</span>
|
||||
<span v-else class="text-gray-300 font-mono">—</span>
|
||||
<span v-else class="text-gray-400 font-mono text-sm">⏳</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,58 +77,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 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())
|
||||
)
|
||||
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(() => {
|
||||
return [...hosts.value].sort((a, b) => {
|
||||
if (a.ping === null && b.ping === null) return 0
|
||||
@@ -134,6 +91,10 @@ const sortedHosts = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
const handleFlagError = (e) => {
|
||||
e.target.style.display = 'none'
|
||||
}
|
||||
|
||||
const pingHost = async (host) => {
|
||||
const url = `https://${host.address}:${host.port}`
|
||||
const start = performance.now()
|
||||
@@ -151,25 +112,20 @@ const pingHost = async (host) => {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchHosts = async () => {
|
||||
const loadData = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/v1/hosts')
|
||||
if (!res.ok) throw new Error()
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`)
|
||||
const data = await res.json()
|
||||
|
||||
hosts.value = data.map((h) => {
|
||||
const country = findCountryByFirstWord(h.name)
|
||||
return {
|
||||
...h,
|
||||
countryCode: country?.code?.toLowerCase() || null,
|
||||
isOnline: true,
|
||||
ping: null,
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
error.value = 'Ошибка загрузки'
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
return data.map((h) => ({
|
||||
...h,
|
||||
countryCode: h.country_code ? h.country_code.toLowerCase() : null,
|
||||
isOnline: true,
|
||||
ping: null
|
||||
}))
|
||||
} catch (err) {
|
||||
throw new Error('Ошибка загрузки данных')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,36 +134,22 @@ const refreshData = async () => {
|
||||
error.value = null
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/v1/hosts')
|
||||
if (!res.ok) throw new Error()
|
||||
const data = await res.json()
|
||||
|
||||
hosts.value = data.map((h) => {
|
||||
const country = findCountryByFirstWord(h.name)
|
||||
return {
|
||||
...h,
|
||||
countryCode: country?.code?.toLowerCase() || null,
|
||||
isOnline: true,
|
||||
ping: null,
|
||||
}
|
||||
})
|
||||
const data = await loadData()
|
||||
hosts.value = data
|
||||
|
||||
// Пингуем все хосты
|
||||
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 = 'Ошибка обновления'
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// При первом открытии — загружаем и пингуем
|
||||
onMounted(async () => {
|
||||
await fetchHosts()
|
||||
// Автоматический пинг только при первом открытии
|
||||
await refreshData()
|
||||
onMounted(() => {
|
||||
refreshData()
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user