16 Commits
Author SHA1 Message Date
austnv 3dbacb4359 feat: minify component NodesStatus
Build and Deploy Frontend via SSH / deploy (push) Successful in 44s
2026-06-21 22:50:30 +03:00
austnv d8e20754c7 dix: release author 2026-06-21 22:44:14 +03:00
austnv 4e6e0d4d48 fix deploy
Build and Deploy Frontend via SSH / deploy (push) Successful in 47s
2026-06-21 22:39:42 +03:00
austnv a22662f11b v0.9.2
Build and Deploy Frontend via SSH / deploy (push) Failing after 4s
2026-06-21 21:56:47 +03:00
austnv 75531a9ec3 update workflow: add auto release 2026-06-21 21:56:19 +03:00
austnv e6ab2667c9 fix: micropatch NodesStatus 2026-06-21 21:50:00 +03:00
austnv 3a38b3f7fa v0.9.1
Build and Deploy Frontend via SSH / deploy (push) Successful in 42s
2026-06-21 21:43:21 +03:00
austnv b69cc4bc4b update NodesStatus.vue 2026-06-21 21:38:23 +03:00
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 183 additions and 341 deletions
+49 -5
View File
@@ -4,6 +4,7 @@ on:
push: push:
tags: tags:
- '*' - '*'
workflow_dispatch:
jobs: jobs:
deploy: deploy:
@@ -23,15 +24,58 @@ jobs:
- name: Build project - name: Build project
run: npm run build run: npm run build
- name: Create Gitea Release via API
run: |
# Получаем описание из тега (если есть)
TAG_MESSAGE=$(git tag -l --format='%(contents)' "${{ gitea.ref_name }}" 2>/dev/null || echo "Автоматический релиз через CI/CD")
# Экранируем кавычки и переносы для JSON
TAG_MESSAGE_ESCAPED=$(echo "$TAG_MESSAGE" | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}')
# Формируем JSON
JSON_PAYLOAD=$(cat <<EOF
{
"tag_name": "${{ gitea.ref_name }}",
"name": "Release ${{ gitea.ref_name }}",
"body": "## Релиз ${{ gitea.ref_name }}\n\n📝 ${TAG_MESSAGE_ESCAPED}\n\n---\n\n**🏷️ Тег:** \`${{ gitea.ref_name }}\`\n**👤 Автор:** @${{ gitea.actor }}\n\n✅ Автоматически собрано и развёрнуто",
"draft": false,
"prerelease": false
}
EOF
)
# Отправляем запрос
RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.ACCESS_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"https://git.uvpn.shop/api/v1/repos/${{ gitea.repository }}/releases")
# Проверяем ответ
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -eq 201 ]; then
echo "✅ Релиз успешно создан!"
echo "$BODY" | jq '.'
elif [ "$HTTP_CODE" -eq 409 ]; then
echo "⚠️ Релиз с таким тегом уже существует, пропускаем"
else
echo "❌ Ошибка создания релиза (HTTP $HTTP_CODE)"
echo "$BODY"
exit 1
fi
- 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.4",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
+110 -267
View File
@@ -1,333 +1,176 @@
<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"> <div class="flex items-center justify-between mb-10 flex-wrap gap-4">
<div> <h2 class="text-3xl md:text-4xl font-bold">
<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 <button
@click="refreshData" @click="refreshData"
:disabled="loading" :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" 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"
> >
<span :class="{ 'animate-spin': loading }">🔄</span> <RefreshCw :size="16" :class="{ 'animate-spin': loading }" />
{{ loading ? 'Обновление...' : 'Обновить' }} {{ loading ? 'Обновление...' : 'Обновить пинг' }}
</button> </button>
</div> </div>
<!-- Состояние загрузки --> <div v-if="loading && !hosts.length" 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-2 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 sortedHosts"
: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-2.5 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">
<div class="flex items-center gap-2">
<!-- Флаг из CDN -->
<img <img
v-if="node.country_code" v-if="host.countryCode"
:src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${node.country_code.toLowerCase()}.svg`" :src="`https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/flags/4x3/${host.countryCode}.svg`"
:alt="node.country_code.toLowerCase()"
class="h-5 w-auto rounded-sm" class="h-5 w-auto rounded-sm"
/> />
<div> <span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
<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-3">
<div class="text-sm text-gray-500 dark:text-gray-400 mb-3 font-mono">
{{ node.ip }}:{{ node.port }}
</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 <span
class="font-semibold" v-if="host.ping !== undefined && host.ping !== null"
class="font-mono font-semibold flex items-center gap-1.5"
:class="{ :class="{
'text-green-600 dark:text-green-400': node.ping < 50, 'text-green-600': host.ping < 200,
'text-yellow-600 dark:text-yellow-400': node.ping >= 50 && node.ping < 150, 'text-yellow-600': host.ping >= 200 && host.ping < 500,
'text-orange-600 dark:text-orange-400': node.ping >= 150 && node.ping < 300, 'text-red-600': host.ping >= 500,
'text-red-600 dark:text-red-400': node.ping >= 300
}" }"
> >
{{ node.ping }}ms <Wifi :size="14" />
{{ host.ping }}ms
</span> </span>
<span v-else class="text-gray-300 font-mono"></span>
</div> </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, computed, onMounted } from 'vue'
import { Wifi, RefreshCw } 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
// Вычисляемые свойства 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(() => { const findCountryByFirstWord = (name) => {
return nodes.value.filter(n => n.isOnline).length if (!name) return null
}) const firstWord = name.split(' ')[0]
if (!firstWord) return null
const offlineCount = computed(() => { const exact = countriesList.find(c =>
return nodes.value.filter(n => !n.isOnline).length c.label.toLowerCase() === firstWord.toLowerCase()
}) )
if (exact) return exact
const totalUsers = computed(() => { const partial = countriesList.find(c =>
return nodes.value.reduce((sum, n) => sum + (n.users_online || 0), 0) firstWord.toLowerCase().includes(c.label.toLowerCase()) ||
}) c.label.toLowerCase().includes(firstWord.toLowerCase())
)
const averagePing = computed(() => { return partial || null
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 sortedHosts = computed(() => {
const fetchNodes = async () => { return [...hosts.value].sort((a, b) => {
loading.value = true if (a.ping === null && b.ping === null) return 0
error.value = null if (a.ping === null) return 1
if (b.ping === null) return -1
return a.ping - b.ping
})
})
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',
if (!response.ok) { mode: 'no-cors',
throw new Error(`Ошибка: ${response.status}`) cache: 'no-cache',
signal: AbortSignal.timeout(5000),
})
return Math.round(performance.now() - start)
} catch {
return Math.round(performance.now() - start)
}
} }
const data = await response.json() const fetchHosts = async () => {
try {
const res = await fetch('/api/v1/hosts')
if (!res.ok) throw new Error()
const data = await res.json()
// Добавляем поле isOnline и инициализируем пинг hosts.value = data.map((h) => {
nodes.value = data.map(node => ({ const country = findCountryByFirstWord(h.name)
...node, return {
isOnline: true, // Все ноды из бэкенда считаем онлайн ...h,
ping: undefined, countryCode: country?.code?.toLowerCase() || null,
pinging: false isOnline: true,
})) ping: null,
}
} catch (err) { })
console.error('Failed to load nodes:', err) } catch {
error.value = 'Не удалось загрузить статус серверов' error.value = 'Ошибка загрузки'
} finally { } finally {
loading.value = false loading.value = false
} }
} }
// Измерение пинга через WebSocket const refreshData = async () => {
const pingNode = async (node) => { loading.value = true
if (!node.isOnline || node.pinging) return error.value = null
node.pinging = true
node.ping = undefined
const startTime = performance.now()
const wsUrl = `wss://${node.ip}:${node.port}`
try { try {
const ws = new WebSocket(wsUrl) const res = await fetch('/api/v1/hosts')
if (!res.ok) throw new Error()
const data = await res.json()
const timeout = setTimeout(() => { hosts.value = data.map((h) => {
ws.close() const country = findCountryByFirstWord(h.name)
node.ping = null return {
node.pinging = false ...h,
}, 5000) countryCode: country?.code?.toLowerCase() || null,
isOnline: true,
ws.onopen = () => { ping: null,
const endTime = performance.now()
clearTimeout(timeout)
node.ping = Math.round(endTime - startTime)
node.pinging = false
ws.close()
} }
})
ws.onerror = () => { // Пингуем все хосты параллельно
clearTimeout(timeout) const pings = await Promise.all(hosts.value.map(h => pingHost(h)))
node.ping = null hosts.value.forEach((h, i) => {
node.pinging = false if (h.isOnline) h.ping = pings[i]
} })
} catch { } catch {
node.ping = null error.value = 'Ошибка обновления'
node.pinging = false } finally {
loading.value = 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()
// Автообновление каждые 30 секунд
updateInterval = setInterval(() => {
if (!loading.value) {
refreshData()
}
}, 30000)
})
onUnmounted(() => {
if (updateInterval) {
clearInterval(updateInterval)
}
}) })
</script> </script>
+1 -46
View File
@@ -1,5 +1,4 @@
<template> <template>
<div>
<HeroSection /> <HeroSection />
<FeaturesSection /> <FeaturesSection />
<CompatibilitySection /> <CompatibilitySection />
@@ -8,7 +7,6 @@
<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>