8 Commits
Author SHA1 Message Date
austnv 4b7b2bc5c6 refactor NodesStatus.vue
Build and Deploy Frontend via SSH / deploy (push) Successful in 46s
2026-06-21 20:45:40 +03:00
austnv f6af141f56 update NodesStatus 2026-06-21 17:51:54 +03:00
austnv c5c0a6614a fix: update NodesStatus
Build and Deploy Frontend via SSH / deploy (push) Has been cancelled
2026-06-21 17:42:05 +03:00
austnv acb11b43c7 fix(workflow): finish deploy.yml 2026-06-21 17:22:48 +03:00
austnv b12c1a07c9 update workflow 2026-06-21 17:20:10 +03:00
austnv 03fbbed39c change ssh key managment system 2026-06-21 17:17:21 +03:00
austnv 0c825abad2 update workflow 2026-06-21 17:16:08 +03:00
austnv 89ffe3c50e update workflow 2026-06-21 17:07:58 +03:00
4 changed files with 123 additions and 358 deletions
+6 -5
View File
@@ -4,6 +4,7 @@ on:
push: push:
tags: tags:
- '*' - '*'
workflow_dispatch:
jobs: jobs:
deploy: deploy:
@@ -23,15 +24,15 @@ jobs:
- name: Build project - name: Build project
run: npm run build run: npm run build
- name: Install SSH key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Deploy via SCP - name: Deploy via SCP
run: | run: |
# Создаём архив собранных файлов
tar -czf frontend.tar.gz -C dist . tar -czf frontend.tar.gz -C dist .
# Копируем архив на хост через SCP
scp -o StrictHostKeyChecking=no frontend.tar.gz ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:/tmp/ scp -o StrictHostKeyChecking=no frontend.tar.gz ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:/tmp/
# Распаковываем и перемещаем файлы на хосте
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'EOF' ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'EOF'
mkdir -p /opt/uvpn.shop/frontend mkdir -p /opt/uvpn.shop/frontend
rm -rf /opt/uvpn.shop/frontend/* rm -rf /opt/uvpn.shop/frontend/*
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "uvpn.shop", "name": "frontend",
"version": "0.8.0", "version": "0.9.0",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+102 -293
View File
@@ -1,333 +1,142 @@
<template> <template>
<section id="nodes" class="px-6 py-20 md:px-12 max-w-7xl mx-auto"> <section class="px-6 py-20 md:px-12 max-w-7xl mx-auto">
<div class="flex justify-between items-center mb-10 flex-wrap gap-4"> <h2 class="text-3xl md:text-4xl font-bold text-center mb-14">
<div> Статус серверов
<h2 class="text-3xl md:text-4xl font-bold text-gray-900 dark:text-white"> </h2>
🌍 Статус серверов
</h2>
<p class="text-gray-500 dark:text-gray-400 mt-2">
{{ onlineCount }} из {{ nodes.length }} серверов онлайн
<span v-if="averagePing !== null" class="ml-4">
📶 Средний пинг: <span class="font-semibold text-blue-600 dark:text-blue-400">{{ averagePing }}ms</span>
</span>
</p>
</div>
<button
@click="refreshData"
:disabled="loading"
class="px-4 py-2 bg-gray-200 dark:bg-gray-700 rounded-lg text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600 transition disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
>
<span :class="{ 'animate-spin': loading }">🔄</span>
{{ loading ? 'Обновление...' : 'Обновить' }}
</button>
</div>
<!-- Состояние загрузки --> <div v-if="loading" class="flex justify-center py-12">
<div v-if="loading && !nodes.length" class="flex justify-center py-20">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div> <div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
</div> </div>
<!-- Ошибка --> <p v-else-if="error" class="text-center text-red-500 py-12">{{ error }}</p>
<div v-else-if="error" class="text-center text-red-500 py-12">
<p class="text-lg">{{ error }}</p>
<button @click="refreshData" class="mt-4 text-blue-600 dark:text-blue-400 hover:underline">
Попробовать снова
</button>
</div>
<!-- Сетка серверов --> <div v-else class="space-y-3 max-w-3xl mx-auto">
<div v-else class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
<div <div
v-for="node in sortedNodes" v-for="host in hosts"
:key="node.name" :key="host.address"
class="bg-white dark:bg-gray-900 rounded-xl p-5 border transition hover:shadow-lg" class="flex items-center justify-between bg-white dark:bg-gray-900 rounded-xl px-4 py-3 border transition hover:shadow-md"
:class="[ :class="host.isOnline ? 'border-green-500/30' : 'border-red-500/30 opacity-60'"
node.isOnline
? 'border-green-500/30 dark:border-green-500/20 hover:border-green-500'
: 'border-red-500/30 dark:border-red-500/20 opacity-60'
]"
> >
<!-- Шапка --> <div class="flex items-center gap-3">
<div class="flex items-start justify-between mb-3"> <img
<div class="flex items-center gap-2"> v-if="host.countryCode"
<!-- Флаг из CDN --> :src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${host.countryCode}.svg`"
<img class="h-5 w-auto rounded-sm"
v-if="node.country_code" />
:src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${node.country_code.toLowerCase()}.svg`" <span class="font-semibold text-gray-800 dark:text-white">{{ host.cleanName }}</span>
:alt="node.country_code.toLowerCase()"
class="h-5 w-auto rounded-sm"
/>
<div>
<h3 class="font-semibold text-gray-900 dark:text-white">
{{ node.name }}
</h3>
<span class="text-xs text-gray-500 dark:text-gray-400">
{{ node.country_code }}
</span>
</div>
</div>
<span <span
class="text-xs px-2 py-1 rounded-full font-medium" class="text-[10px] px-2 py-0.5 rounded-full font-medium"
:class="node.isOnline :class="host.isOnline ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700'"
? 'bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400'
: 'bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-400'"
> >
{{ node.isOnline ? '🟢 Онлайн' : '🔴 Офлайн' }} {{ host.isOnline ? 'online' : 'offline' }}
</span> </span>
</div> </div>
<!-- IP и порт --> <div class="flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400">
<div class="text-sm text-gray-500 dark:text-gray-400 mb-3 font-mono"> <span
{{ node.ip }}:{{ node.port }} v-if="host.ping !== undefined && host.ping !== null"
class="font-mono font-semibold flex items-center gap-1"
:class="{
'text-green-600': host.ping < 50,
'text-yellow-600': host.ping >= 50 && host.ping < 150,
'text-orange-600': host.ping >= 150 && host.ping < 300,
'text-red-600': host.ping >= 300,
}"
>
<Wifi :size="14" />
{{ host.ping }}ms
</span>
<span v-else class="text-gray-300"></span>
</div> </div>
<!-- Статистика -->
<div class="grid grid-cols-2 gap-2 text-sm">
<div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-2 text-center">
<div class="text-gray-500 dark:text-gray-400 text-xs">Пользователи</div>
<div class="font-semibold text-gray-900 dark:text-white">
{{ node.users_online }}
</div>
</div>
<div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-2 text-center">
<div class="text-gray-500 dark:text-gray-400 text-xs">Uptime</div>
<div class="font-semibold text-gray-900 dark:text-white">
{{ formatUptime(node.uptime) }}
</div>
</div>
</div>
<!-- Пинг (если измерен) -->
<div v-if="node.ping !== undefined && node.ping !== null" class="mt-3 pt-3 border-t border-gray-200 dark:border-gray-700">
<div class="flex justify-between items-center text-sm">
<span class="text-gray-500 dark:text-gray-400">📶 Пинг</span>
<span
class="font-semibold"
:class="{
'text-green-600 dark:text-green-400': node.ping < 50,
'text-yellow-600 dark:text-yellow-400': node.ping >= 50 && node.ping < 150,
'text-orange-600 dark:text-orange-400': node.ping >= 150 && node.ping < 300,
'text-red-600 dark:text-red-400': node.ping >= 300
}"
>
{{ node.ping }}ms
</span>
</div>
<!-- Прогресс-бар пинга -->
<div class="w-full h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full mt-1 overflow-hidden">
<div
class="h-full rounded-full transition-all duration-500"
:class="{
'bg-green-500': node.ping < 50,
'bg-yellow-500': node.ping >= 50 && node.ping < 150,
'bg-orange-500': node.ping >= 150 && node.ping < 300,
'bg-red-500': node.ping >= 300
}"
:style="{ width: Math.min((node.ping / 300) * 100, 100) + '%' }"
></div>
</div>
</div>
<!-- Кнопка проверки пинга -->
<button
@click="pingNode(node)"
:disabled="node.pinging || !node.isOnline"
class="mt-3 w-full text-xs py-1.5 rounded-lg transition font-medium"
:class="[
node.isOnline
? 'bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/30 disabled:opacity-50'
: 'bg-gray-100 dark:bg-gray-800 text-gray-400 cursor-not-allowed'
]"
>
{{ node.pinging ? '⏳ Измерение...' : 'Проверить пинг' }}
</button>
</div>
</div>
<!-- Футер с статистикой -->
<div
v-if="!loading && nodes.length"
class="mt-10 grid grid-cols-2 md:grid-cols-4 gap-4 text-center"
>
<div class="bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4">
<div class="text-2xl font-bold text-gray-900 dark:text-white">
{{ nodes.length }}
</div>
<div class="text-sm text-gray-500 dark:text-gray-400">Всего серверов</div>
</div>
<div class="bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4">
<div class="text-2xl font-bold text-green-600 dark:text-green-400">
{{ onlineCount }}
</div>
<div class="text-sm text-gray-500 dark:text-gray-400">Онлайн</div>
</div>
<div class="bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4">
<div class="text-2xl font-bold text-red-600 dark:text-red-400">
{{ offlineCount }}
</div>
<div class="text-sm text-gray-500 dark:text-gray-400">Офлайн</div>
</div>
<div class="bg-gray-50 dark:bg-gray-800/50 rounded-xl p-4">
<div class="text-2xl font-bold text-blue-600 dark:text-blue-400">
{{ totalUsers }}
</div>
<div class="text-sm text-gray-500 dark:text-gray-400">Всего пользователей</div>
</div> </div>
</div> </div>
</section> </section>
</template> </template>
<script setup> <script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue' import { ref, onMounted, onUnmounted } from 'vue'
import { Wifi } from '@lucide/vue'
import { getAllCountries } from '@tw-labs/countries'
// Состояние const hosts = ref([])
const nodes = ref([]) const loading = ref(true)
const loading = ref(false)
const error = ref(null) const error = ref(null)
let updateInterval = null let interval = null
// Вычисляемые свойства const countriesList = getAllCountries()
const sortedNodes = computed(() => {
return [...nodes.value].sort((a, b) => {
// Сначала онлайн
if (a.isOnline !== b.isOnline) {
return a.isOnline ? -1 : 1
}
// Потом по имени
return a.name.localeCompare(b.name)
})
})
const onlineCount = computed(() => { // Поиск страны по названию (из IpSecurity.vue)
return nodes.value.filter(n => n.isOnline).length const findCountryByName = (countryName) => {
}) if (!countryName) return null
const found = countriesList.find(c => c.label.toLowerCase() === countryName.toLowerCase())
const offlineCount = computed(() => { if (found) return found
return nodes.value.filter(n => !n.isOnline).length const partial = countriesList.find(c =>
}) countryName.toLowerCase().includes(c.label.toLowerCase()) ||
c.label.toLowerCase().includes(countryName.toLowerCase())
const totalUsers = computed(() => { )
return nodes.value.reduce((sum, n) => sum + (n.users_online || 0), 0) return partial || null
})
const averagePing = computed(() => {
const pings = nodes.value
.filter(n => n.ping !== undefined && n.ping !== null)
.map(n => n.ping)
if (pings.length === 0) return null
return Math.round(pings.reduce((a, b) => a + b, 0) / pings.length)
})
// Методы
const formatUptime = (seconds) => {
if (!seconds) return '0м'
const days = Math.floor(seconds / 86400)
const hours = Math.floor((seconds % 86400) / 3600)
const minutes = Math.floor((seconds % 3600) / 60)
if (days > 0) return `${days}д ${hours}ч`
if (hours > 0) return `${hours}ч ${minutes}м`
return `${minutes}м`
} }
// Загрузка данных // Очистка имени от эмодзи и лишних символов
const fetchNodes = async () => { const cleanName = (name) => {
loading.value = true return name.replace(/^[🇷🇺🇫🇮🇸🇪🇺🇸🇵🇱🇱🇻🇳🇱🇩🇪]\s*/, '').replace(/[🚀⭐🔥]/g, '').trim()
error.value = null }
// Извлечение названия страны из name (удаляем эмодзи)
const extractCountryName = (name) => {
const cleaned = cleanName(name)
return cleaned.replace(/\s*\d+$/, '').trim() // убираем цифры в конце (например "Finland 2" -> "Finland")
}
// Пинг через fetch (работает даже с невалидным сертификатом)
const pingHost = async (host) => {
const url = `https://${host.address}:${host.port}`
const start = performance.now()
try { try {
const response = await fetch('/api/v1/nodes') await fetch(url, {
method: 'HEAD',
mode: 'no-cors',
cache: 'no-cache',
signal: AbortSignal.timeout(5000),
})
return Math.round(performance.now() - start)
} catch {
return Math.round(performance.now() - start)
}
}
if (!response.ok) { const fetchHosts = async () => {
throw new Error(`Ошибка: ${response.status}`) try {
} const res = await fetch('/api/v1/hosts')
if (!res.ok) throw new Error()
const data = await res.json()
const data = await response.json() hosts.value = data.map((h) => {
const countryName = extractCountryName(h.name)
const country = findCountryByName(countryName)
// Добавляем поле isOnline и инициализируем пинг return {
nodes.value = data.map(node => ({ ...h,
...node, cleanName: cleanName(h.name),
isOnline: true, // Все ноды из бэкенда считаем онлайн countryCode: country?.code?.toLowerCase() || null,
ping: undefined, isOnline: true,
pinging: false ping: null,
})) }
})
} catch (err) { const pings = await Promise.all(hosts.value.map((h) => pingHost(h)))
console.error('Failed to load nodes:', err) hosts.value.forEach((h, i) => (h.ping = pings[i]))
error.value = 'Не удалось загрузить статус серверов' } catch {
error.value = 'Ошибка загрузки'
} finally { } finally {
loading.value = false loading.value = false
} }
} }
// Измерение пинга через WebSocket
const pingNode = async (node) => {
if (!node.isOnline || node.pinging) return
node.pinging = true
node.ping = undefined
const startTime = performance.now()
const wsUrl = `wss://${node.ip}:${node.port}`
try {
const ws = new WebSocket(wsUrl)
const timeout = setTimeout(() => {
ws.close()
node.ping = null
node.pinging = false
}, 5000)
ws.onopen = () => {
const endTime = performance.now()
clearTimeout(timeout)
node.ping = Math.round(endTime - startTime)
node.pinging = false
ws.close()
}
ws.onerror = () => {
clearTimeout(timeout)
node.ping = null
node.pinging = false
}
} catch {
node.ping = null
node.pinging = false
}
}
// Измерение пинга для всех нод
const pingAllNodes = async () => {
const pingPromises = nodes.value.map(node => pingNode(node))
await Promise.allSettled(pingPromises)
}
// Обновление данных
const refreshData = async () => {
await fetchNodes()
// После загрузки данных измеряем пинг для онлайн нод
await pingAllNodes()
}
// Жизненный цикл
onMounted(() => { onMounted(() => {
refreshData() fetchHosts()
interval = setInterval(fetchHosts, 30000)
// Автообновление каждые 30 секунд
updateInterval = setInterval(() => {
if (!loading.value) {
refreshData()
}
}, 30000)
})
onUnmounted(() => {
if (updateInterval) {
clearInterval(updateInterval)
}
}) })
onUnmounted(() => clearInterval(interval))
</script> </script>
+9 -54
View File
@@ -1,14 +1,12 @@
<template> <template>
<div> <HeroSection />
<HeroSection /> <FeaturesSection />
<FeaturesSection /> <CompatibilitySection />
<CompatibilitySection /> <PricingSection />
<PricingSection /> <NodesStatus />
<NodesStatus /> <StepsSection />
<StepsSection /> <TestimonialsSection />
<TestimonialsSection /> <FaqSection />
<FaqSection />
</div>
</template> </template>
<script setup> <script setup>
@@ -16,56 +14,13 @@ import HeroSection from '../components/HeroSection.vue'
import FeaturesSection from '../components/FeaturesSection.vue' import FeaturesSection from '../components/FeaturesSection.vue'
import CompatibilitySection from '../components/CompatibilitySection.vue' import CompatibilitySection from '../components/CompatibilitySection.vue'
import PricingSection from '../components/PricingSection.vue' import PricingSection from '../components/PricingSection.vue'
import NodesStatus from '@/components/NodesStatus.vue' import NodesStatus from '../components/NodesStatus.vue'
import StepsSection from '../components/StepsSection.vue' import StepsSection from '../components/StepsSection.vue'
import TestimonialsSection from '../components/TestimonialsSection.vue' import TestimonialsSection from '../components/TestimonialsSection.vue'
import FaqSection from '../components/FaqSection.vue' import FaqSection from '../components/FaqSection.vue'
// import { useHead } from '@vueuse/head';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
const route = useRoute(); const route = useRoute();
// useHead({
// title: route.meta.title,
// meta: [
// {
// name: 'description',
// content: route.meta.description
// },
// {
// name: 'keywords',
// content: route.meta.keywords
// },
// // Open Graph теги для соцсетей
// {
// property: 'og:title',
// content: route.meta.title
// },
// {
// property: 'og:description',
// content: route.meta.description
// },
// {
// property: 'og:type',
// content: 'website'
// },
// {
// property: 'og:url',
// content: window.location.href // Здесь можно также задать каноничный URL
// },
// {
// property: 'og:site_name',
// content: route.meta.title
// },
// {
// property: 'telegram:channel',
// content: '@uvpn_shop'
// },
// {
// property: 'tg:site_verification',
// content: 'g7j8/rPFXfhyrq5q0QQV7EsYWv4='
// },
// ]
// });
</script> </script>