修改前端内容
This commit is contained in:
+29
-1
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { RouterLink, RouterView, useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { toggleLocale } from '@/i18n'
|
||||
import logo from '@/assets/logo.svg'
|
||||
@@ -9,6 +10,20 @@ const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const versionInfo = ref<{ commit: string; commitTime: string } | null>(null)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await fetch('/api/version')
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
versionInfo.value = { commit: data.commit, commitTime: data.commit_time }
|
||||
}
|
||||
} catch {
|
||||
// 版本信息获取失败时静默处理,footer 仅显示版权
|
||||
}
|
||||
})
|
||||
|
||||
function handleLogout() {
|
||||
authStore.logout()
|
||||
router.push('/')
|
||||
@@ -16,7 +31,6 @@ function handleLogout() {
|
||||
|
||||
const navLinks = [
|
||||
{ to: '/', label: 'nav.home' },
|
||||
{ to: '/about', label: 'nav.about' },
|
||||
]
|
||||
</script>
|
||||
|
||||
@@ -39,6 +53,17 @@ const navLinks = [
|
||||
>
|
||||
{{ t(link.label) }}
|
||||
</RouterLink>
|
||||
<a
|
||||
href="https://github.com/wuwenfengmi1998/lmvpn_server"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium transition-colors hover:bg-sky-500/40"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-4 h-4">
|
||||
<path d="M12 .5C5.37.5 0 5.78 0 12.292c0 5.211 3.438 9.63 8.205 11.188.6.111.82-.254.82-.567 0-.28-.01-1.022-.015-2.005-3.338.711-4.042-1.582-4.042-1.582-.546-1.361-1.335-1.725-1.335-1.725-1.087-.731.084-.716.084-.716 1.205.082 1.838 1.215 1.838 1.215 1.07 1.803 2.809 1.282 3.495.981.108-.763.417-1.282.76-1.577-2.665-.295-5.466-1.309-5.466-5.827 0-1.287.465-2.339 1.235-3.164-.135-.298-.54-1.497.105-3.121 0 0 1.005-.316 3.3 1.209.96-.262 1.98-.392 3-.398 1.02.006 2.04.136 3 .398 2.28-1.525 3.285-1.209 3.285-1.209.645 1.624.24 2.823.12 3.121.765.825 1.23 1.877 1.23 3.164 0 4.53-2.805 5.527-5.475 5.817.42.354.81 1.077.81 2.182 0 1.578-.015 2.846-.015 3.229 0 .315.21.687.825.57C20.565 21.917 24 17.495 24 12.292 24 5.78 18.627.5 12 .5z" />
|
||||
</svg>
|
||||
GitHub
|
||||
</a>
|
||||
<template v-if="authStore.isLoggedIn">
|
||||
<RouterLink
|
||||
to="/profile"
|
||||
@@ -95,6 +120,9 @@ const navLinks = [
|
||||
<footer class="bg-slate-800 text-slate-400 py-6 text-center text-sm">
|
||||
<div class="max-w-6xl mx-auto px-4">
|
||||
<p>© {{ new Date().getFullYear() }} LmVPN. All rights reserved.</p>
|
||||
<p v-if="versionInfo" class="mt-1 text-slate-500">
|
||||
{{ t('footer.lastCommit') }}: {{ versionInfo.commitTime }} · {{ versionInfo.commit }}
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@@ -149,6 +149,9 @@ export default {
|
||||
selectUserAndIp: 'Please select a user and fill in at least one IP address',
|
||||
confirmDeleteReservation: 'Delete this reservation?',
|
||||
},
|
||||
footer: {
|
||||
lastCommit: 'Last commit',
|
||||
},
|
||||
home: {
|
||||
tagline: 'Secure, fast, and reliable VPN tunnel management system',
|
||||
secureTunnel: 'Secure Tunnel',
|
||||
|
||||
@@ -148,6 +148,9 @@ export default {
|
||||
selectUserAndIp: '请选择用户并至少填写一个 IP 地址',
|
||||
confirmDeleteReservation: '确认删除该预留?',
|
||||
},
|
||||
footer: {
|
||||
lastCommit: '最后提交',
|
||||
},
|
||||
home: {
|
||||
tagline: '安全、快速、可靠的 VPN 隧道管理系统',
|
||||
secureTunnel: '安全隧道',
|
||||
|
||||
+5
-1
@@ -25,7 +25,11 @@ npm run build
|
||||
cd ..
|
||||
|
||||
echo ">>> 编译 Go 后端..."
|
||||
go build -o lmvpn .
|
||||
VERSION=$(git describe --tags --always 2>/dev/null || echo "dev")
|
||||
COMMIT=$(git rev-parse --short HEAD)
|
||||
COMMIT_TIME=$(git log -1 --format=%cI)
|
||||
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
go build -ldflags "-X lmvpn/internal/version.Version=$VERSION -X lmvpn/internal/version.Commit=$COMMIT -X lmvpn/internal/version.CommitTime=$COMMIT_TIME -X lmvpn/internal/version.BuildTime=$BUILD_TIME" -o lmvpn .
|
||||
|
||||
echo ">>> 创建 lmvpn 系统用户..."
|
||||
if ! id lmvpn &>/dev/null; then
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"lmvpn/internal/version"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type versionResponse struct {
|
||||
Version string `json:"version"`
|
||||
Commit string `json:"commit"`
|
||||
CommitTime string `json:"commit_time"`
|
||||
BuildTime string `json:"build_time"`
|
||||
}
|
||||
|
||||
func GetVersion(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, versionResponse{
|
||||
Version: version.Version,
|
||||
Commit: version.Commit,
|
||||
CommitTime: version.CommitTime,
|
||||
BuildTime: version.BuildTime,
|
||||
})
|
||||
}
|
||||
@@ -15,6 +15,7 @@ func Setup(r *gin.Engine) {
|
||||
r.GET("/ws", vpn.HandleWS)
|
||||
|
||||
r.POST("/api/login", middleware.LoginRateLimit(), handler.Login)
|
||||
r.GET("/api/version", handler.GetVersion)
|
||||
|
||||
auth := r.Group("/api")
|
||||
auth.Use(middleware.AuthMiddleware())
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package version
|
||||
|
||||
var (
|
||||
Version = "dev"
|
||||
Commit = "unknown"
|
||||
CommitTime = "unknown"
|
||||
BuildTime = "unknown"
|
||||
)
|
||||
Reference in New Issue
Block a user