Compare commits
24
Commits
v0.7.3
..
6e841b12f5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e841b12f5 | ||
|
|
7f227fcf05 | ||
|
|
a34a646c71 | ||
|
|
4a0ce08338 | ||
|
|
43749647ca | ||
|
|
3dbacb4359 | ||
|
|
d8e20754c7 | ||
|
|
4e6e0d4d48 | ||
|
|
a22662f11b | ||
|
|
75531a9ec3 | ||
|
|
e6ab2667c9 | ||
|
|
3a38b3f7fa | ||
|
|
b69cc4bc4b | ||
|
|
4b7b2bc5c6 | ||
|
|
f6af141f56 | ||
|
|
c5c0a6614a | ||
|
|
acb11b43c7 | ||
|
|
b12c1a07c9 | ||
|
|
03fbbed39c | ||
|
|
0c825abad2 | ||
|
|
89ffe3c50e | ||
|
|
07229efac0 | ||
|
|
39023a66c2 | ||
|
|
20cd884718 |
@@ -0,0 +1,84 @@
|
||||
name: Build and Deploy Frontend via SSH
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Build project
|
||||
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
|
||||
run: |
|
||||
tar -czf frontend.tar.gz -C dist .
|
||||
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'
|
||||
mkdir -p /opt/uvpn.shop/frontend
|
||||
rm -rf /opt/uvpn.shop/frontend/*
|
||||
tar -xzf /tmp/frontend.tar.gz -C /opt/uvpn.shop/frontend
|
||||
rm /tmp/frontend.tar.gz
|
||||
EOF
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"recommendations": ["Vue.volar"]
|
||||
}
|
||||
@@ -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
-3
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "uvpn.shop",
|
||||
"version": "0.7.3",
|
||||
"name": "frontend",
|
||||
"version": "0.9.6",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"postbuild": "scp -r dist/* root@uvpn.shop:/opt/uvpn.shop/frontend"
|
||||
"postbuild": "scp -r dist/. root@uvpn.shop:/opt/uvpn.shop/frontend"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lucide/vue": "^1.16.0",
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<section class="px-6 py-20 md:px-12 max-w-7xl mx-auto">
|
||||
<div class="mb-10">
|
||||
<h2 class="text-3xl md:text-4xl font-bold text-center mb-14">
|
||||
Статус серверов
|
||||
</h2>
|
||||
<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">
|
||||
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
|
||||
</div>
|
||||
|
||||
<p v-else-if="error" class="text-center text-red-500 py-12">{{ error }}</p>
|
||||
|
||||
<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"
|
||||
: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`"
|
||||
class="h-5 w-auto rounded-sm"
|
||||
/>
|
||||
<span class="font-semibold text-gray-800 dark:text-white">{{ host.name }}</span>
|
||||
|
||||
<!-- Индикатор состояния (вместо 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>
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<span
|
||||
v-if="host.ping !== undefined && host.ping !== null"
|
||||
class="font-mono font-semibold flex items-center gap-1.5"
|
||||
:class="{
|
||||
'text-green-600': host.ping < 200,
|
||||
'text-yellow-600': host.ping >= 200 && host.ping < 500,
|
||||
'text-red-600': host.ping >= 500,
|
||||
}"
|
||||
>
|
||||
<Wifi :size="14" />
|
||||
{{ host.ping }} ms
|
||||
</span>
|
||||
<span v-else class="text-gray-300 font-mono">—</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<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
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
const fetchHosts = async () => {
|
||||
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,
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
error.value = 'Ошибка загрузки'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const refreshData = async () => {
|
||||
loading.value = true
|
||||
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 pings = await Promise.all(hosts.value.map(h => pingHost(h)))
|
||||
hosts.value.forEach((h, i) => {
|
||||
if (h.isOnline) h.ping = pings[i]
|
||||
})
|
||||
|
||||
} catch {
|
||||
error.value = 'Ошибка обновления'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// При первом открытии — загружаем и пингуем
|
||||
onMounted(async () => {
|
||||
await fetchHosts()
|
||||
// Автоматический пинг только при первом открытии
|
||||
await refreshData()
|
||||
})
|
||||
</script>
|
||||
+9
-52
@@ -1,13 +1,12 @@
|
||||
<template>
|
||||
<div>
|
||||
<HeroSection />
|
||||
<FeaturesSection />
|
||||
<CompatibilitySection />
|
||||
<PricingSection />
|
||||
<StepsSection />
|
||||
<TestimonialsSection />
|
||||
<FaqSection />
|
||||
</div>
|
||||
<HeroSection />
|
||||
<FeaturesSection />
|
||||
<CompatibilitySection />
|
||||
<PricingSection />
|
||||
<NodesStatus />
|
||||
<StepsSection />
|
||||
<TestimonialsSection />
|
||||
<FaqSection />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -15,55 +14,13 @@ import HeroSection from '../components/HeroSection.vue'
|
||||
import FeaturesSection from '../components/FeaturesSection.vue'
|
||||
import CompatibilitySection from '../components/CompatibilitySection.vue'
|
||||
import PricingSection from '../components/PricingSection.vue'
|
||||
import NodesStatus from '../components/NodesStatus.vue'
|
||||
import StepsSection from '../components/StepsSection.vue'
|
||||
import TestimonialsSection from '../components/TestimonialsSection.vue'
|
||||
import FaqSection from '../components/FaqSection.vue'
|
||||
|
||||
// import { useHead } from '@vueuse/head';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user