12 Commits

Author SHA1 Message Date
e0d88e9ad7 feat: Implement core tunnel server with client management, authentication, and SOCKS5/HTTP proxy capabilities.
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
2026-02-03 21:59:55 +08:00
Flik
ba9edd3c02 feat(client): enhance data directory handling and update permissions check for self-update
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 30s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m32s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m35s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m30s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m52s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m17s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m39s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 1m43s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m58s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m16s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m48s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m22s
2026-01-29 16:29:40 +08:00
Flik
e40d079f7a feat(server): add traffic storage and statistics tracking for improved traffic management
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
2026-01-29 15:38:27 +08:00
Flik
8ce5b149f7 fix(server): update client nickname handling to prevent overwriting manual names
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 29s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m35s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m42s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m25s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m50s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m15s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m40s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 1m44s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 2m4s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m16s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m46s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m19s
2026-01-29 15:08:04 +08:00
Flik
0a41e10793 feat(client, server): add client name handling and machine ID retrieval
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
2026-01-27 08:56:05 +08:00
Flik
3386b0fcb6 fix(client): 移除日志前缀并改进代理配置处理
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
- 移除了所有客户端日志消息中的 [Client] 前缀
- 修改 handleProxyConfig 函数以接收 stream 参数并添加延迟关闭
- 更新 sendProxyConfig 函数以等待客户端配置确认
- 改进了代理配置同步的可靠性
2026-01-23 18:10:51 +08:00
Flik
98a5525e6d feat(client): 添加服务端版本检查和客户端更新逻辑
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Successful in 27s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m24s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m33s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m18s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m40s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m16s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m40s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Failing after 1m39s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 1m49s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m26s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m53s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m16s
- 引入 getVersionInfo API 和服务端版本获取功能
- 实现版本比较算法用于判断更新需求
- 添加服务端版本加载和目标版本计算逻辑
- 更新客户端版本显示为可更新目标版本
- 优化样式表移除不透明背景设置
- 调整进度条外观样式增强视觉效果
2026-01-23 08:40:54 +08:00
Flik
5c8020d5fb feat(client): 添加服务端版本检查和客户端更新逻辑
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
- 引入 getVersionInfo API 和服务端版本获取功能
- 实现版本比较算法用于判断更新需求
- 添加服务端版本加载和目标版本计算逻辑
- 更新客户端版本显示为可更新目标版本
- 优化样式表移除不透明背景设置
- 调整进度条外观样式增强视觉效果
2026-01-22 23:55:34 +08:00
Flik
a2773aa1a7 feat(workflow): 更新发布工作流以改进发布说明生成
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
- 当用户提供发布说明时直接使用用户输入的内容
- 当未提供发布说明时自动获取最近一次提交的完整消息作为变更内容
- 格式化发布说明结构,添加版本标题和变更部分
- 在发布说明中插入分隔线以区分变更内容和资源文件
- 添加控制台输出以显示发布的说明内容
2026-01-22 23:13:48 +08:00
Flik
9cc2fa8076 style(ui): 实现毛玻璃设计系统并优化界面视觉效果
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
- 全面实现毛玻璃(glassmorphism)设计效果,提升整体视觉质感
- 更新深色主题配色方案,采用深邃渐变背景和半透明元素
- 在头部、底部、模态框等组件添加毛玻璃效果和模糊滤镜
- 重构导航栏样式,增加高度和圆角,优化悬停状态效果
- 实现动态背景粒子动画系统,增强页面视觉层次感
- 更新卡片组件样式,添加高光边框和阴影效果
- 优化按钮交互效果,添加光泽和悬停动效
- 调整输入框、下拉菜单等表单元素的毛玻璃样式
- 更新主题切换菜单和用户下拉菜单的视觉效果
- 为在线状态指示器添加发光脉冲动画效果
2026-01-22 23:08:47 +08:00
Flik
1890cad8d9 feat(theme): 添加主题切换功能并优化UI样式
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled
- 集成主题切换功能,支持浅色、深色和自动模式
- 添加SunnyOutline、MoonOutline、ContrastOutline图标用于主题选择
- 创建主题下拉菜单组件,允许用户切换不同主题模式
- 重构CSS样式使用CSS变量替代硬编码颜色值
- 优化导航栏、用户菜单、客户端卡片等组件的视觉效果
- 调整头部高度从60px到56px,修改品牌文字样式
- 更新按钮、下拉菜单、模态框等交互元素的样式
- 在客户端视图中添加心跳指示器显示连接状态
- 实现客户端页面数据自动轮询刷新功能
- 优化版本号显示逻辑,确保始终以v开头显示
- 修复更新检查按钮只在有可用更新时才显示的问题
2026-01-22 22:43:19 +08:00
Flik
11572f132c feat(theme): 添加主题切换功能并优化UI样式
Some checks failed
Build Multi-Platform Binaries / build-frontend (push) Failing after 16s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been skipped
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been skipped
- 集成主题切换功能,支持浅色、深色和自动模式
- 添加SunnyOutline、MoonOutline、ContrastOutline图标用于主题选择
- 创建主题下拉菜单组件,允许用户切换不同主题模式
- 重构CSS样式使用CSS变量替代硬编码颜色值
- 优化导航栏、用户菜单、客户端卡片等组件的视觉效果
- 调整头部高度从60px到56px,修改品牌文字样式
- 更新按钮、下拉菜单、模态框等交互元素的样式
- 在客户端视图中添加心跳指示器显示连接状态
- 实现客户端页面数据自动轮询刷新功能
- 优化版本号显示逻辑,确保始终以v开头显示
- 修复更新检查按钮只在有可用更新时才显示的问题
2026-01-22 22:37:42 +08:00
33 changed files with 1915 additions and 1598 deletions

View File

@@ -163,13 +163,21 @@ jobs:
id: release_notes id: release_notes
run: | run: |
if [ -n "${{ inputs.release_notes }}" ]; then if [ -n "${{ inputs.release_notes }}" ]; then
# 使用用户输入的 release notes
echo "${{ inputs.release_notes }}" > release_notes.md echo "${{ inputs.release_notes }}" > release_notes.md
else else
echo "Release ${{ inputs.version }}" > release_notes.md # 使用最近一次 commit message 作为 release notes
echo "## Release ${{ inputs.version }}" > release_notes.md
echo "" >> release_notes.md echo "" >> release_notes.md
echo "## Assets" >> release_notes.md echo "### Changes" >> release_notes.md
echo "" >> release_notes.md echo "" >> release_notes.md
echo "Download the appropriate binary for your platform:" >> release_notes.md # 获取最近一次 commit 的完整 message
git log -1 --pretty=format:"%B" >> release_notes.md
echo "" >> release_notes.md
echo "" >> release_notes.md
echo "---" >> release_notes.md
echo "" >> release_notes.md
echo "### Assets" >> release_notes.md
echo "" >> release_notes.md echo "" >> release_notes.md
echo "- **Linux (amd64/arm64)**: \`.tar.gz\` files" >> release_notes.md echo "- **Linux (amd64/arm64)**: \`.tar.gz\` files" >> release_notes.md
echo "- **macOS (amd64/arm64)**: \`.tar.gz\` files" >> release_notes.md echo "- **macOS (amd64/arm64)**: \`.tar.gz\` files" >> release_notes.md
@@ -177,6 +185,7 @@ jobs:
echo "" >> release_notes.md echo "" >> release_notes.md
echo "Verify downloads with \`SHA256SUMS\`" >> release_notes.md echo "Verify downloads with \`SHA256SUMS\`" >> release_notes.md
fi fi
echo "=== Release Notes ==="
cat release_notes.md cat release_notes.md
- name: Create Release - name: Create Release

View File

@@ -13,9 +13,12 @@ import (
// 版本信息(通过 ldflags 注入) // 版本信息(通过 ldflags 注入)
var Version string var Version string
var BuildTime string
var GitCommit string
func init() { func init() {
version.SetVersion(Version) version.SetVersion(Version)
version.SetBuildInfo(GitCommit, BuildTime)
} }
func main() { func main() {

View File

@@ -32,9 +32,12 @@ import (
// 版本信息(通过 ldflags 注入) // 版本信息(通过 ldflags 注入)
var Version string var Version string
var BuildTime string
var GitCommit string
func init() { func init() {
version.SetVersion(Version) version.SetVersion(Version)
version.SetBuildInfo(GitCommit, BuildTime)
} }
func main() { func main() {
@@ -81,6 +84,7 @@ func main() {
registry := plugin.NewRegistry() registry := plugin.NewRegistry()
server.SetPluginRegistry(registry) server.SetPluginRegistry(registry)
server.SetJSPluginStore(clientStore) // 设置 JS 插件存储,用于客户端重连时恢复插件 server.SetJSPluginStore(clientStore) // 设置 JS 插件存储,用于客户端重连时恢复插件
server.SetTrafficStore(clientStore) // 设置流量存储,用于记录流量统计
// 启动 Web 控制台 // 启动 Web 控制台
if cfg.Server.Web.Enabled { if cfg.Server.Web.Enabled {

2
go.mod
View File

@@ -59,7 +59,7 @@ require (
github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.58.0 // indirect github.com/quic-go/quic-go v0.58.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/shoenig/go-m1cpu v0.1.7 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect github.com/tklauser/numcpus v0.6.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect

8
go.sum
View File

@@ -122,10 +122,10 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.7 h1:C76Yd0ObKR82W4vhfjZiCp0HxcSZ8Nqd84v+HZ0qyI0=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/go-m1cpu v0.1.7/go.mod h1:KkDOw6m3ZJQAPHbrzkZki4hnx+pDRR1Lo+ldA56wD5w=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v1.7.0 h1:eWcHtTXa6QLnBvm0jgEabMRN/uJ4DMV3M8xUGgRkZmk=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shoenig/test v1.7.0/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=

View File

@@ -32,7 +32,6 @@ const (
reconnectDelay = 5 * time.Second reconnectDelay = 5 * time.Second
disconnectDelay = 3 * time.Second disconnectDelay = 3 * time.Second
udpBufferSize = 65535 udpBufferSize = 65535
idFileName = "id"
) )
// Client 隧道客户端 // Client 隧道客户端
@@ -40,6 +39,7 @@ type Client struct {
ServerAddr string ServerAddr string
Token string Token string
ID string ID string
Name string // 客户端名称(主机名)
TLSEnabled bool TLSEnabled bool
TLSConfig *tls.Config TLSConfig *tls.Config
DataDir string // 数据目录 DataDir string // 数据目录
@@ -55,29 +55,46 @@ type Client struct {
// NewClient 创建客户端 // NewClient 创建客户端
func NewClient(serverAddr, token, id string) *Client { func NewClient(serverAddr, token, id string) *Client {
// 默认数据目录 // 默认数据目录:优先使用用户主目录,失败时回退到当前工作目录
home, _ := os.UserHomeDir() var dataDir string
dataDir := filepath.Join(home, ".gotunnel") if home, err := os.UserHomeDir(); err == nil && home != "" {
dataDir = filepath.Join(home, ".gotunnel")
} else {
// UserHomeDir 失败(如 Android adb shell 环境),使用当前工作目录
if cwd, err := os.Getwd(); err == nil {
dataDir = filepath.Join(cwd, ".gotunnel")
log.Printf("[Client] UserHomeDir unavailable, using current directory: %s", dataDir)
} else {
// 最后回退到相对路径
dataDir = ".gotunnel"
log.Printf("[Client] Warning: using relative path for data directory")
}
}
// 确保数据目录存在 // 确保数据目录存在
if err := os.MkdirAll(dataDir, 0755); err != nil { if err := os.MkdirAll(dataDir, 0755); err != nil {
log.Printf("[Client] Failed to create data dir: %v", err) log.Printf("Failed to create data dir: %v", err)
} }
// ID 优先级:命令行参数 > 机器ID
if id == "" { if id == "" {
id = loadClientID(dataDir) id = getMachineID()
} }
// 获取主机名作为客户端名称
hostname, _ := os.Hostname()
// 初始化日志收集器 // 初始化日志收集器
logger, err := NewLogger(dataDir) logger, err := NewLogger(dataDir)
if err != nil { if err != nil {
log.Printf("[Client] Failed to initialize logger: %v", err) log.Printf("Failed to initialize logger: %v", err)
} }
return &Client{ return &Client{
ServerAddr: serverAddr, ServerAddr: serverAddr,
Token: token, Token: token,
ID: id, ID: id,
Name: hostname,
DataDir: dataDir, DataDir: dataDir,
runningPlugins: make(map[string]plugin.ClientPlugin), runningPlugins: make(map[string]plugin.ClientPlugin),
logger: logger, logger: logger,
@@ -94,27 +111,6 @@ func (c *Client) InitVersionStore() error {
return nil return nil
} }
// getIDFilePath 获取 ID 文件路径
func getIDFilePath(dataDir string) string {
return filepath.Join(dataDir, idFileName)
}
// loadClientID 从本地文件加载客户端 ID
func loadClientID(dataDir string) string {
data, err := os.ReadFile(getIDFilePath(dataDir))
if err != nil {
return ""
}
return string(data)
}
// saveClientID 保存客户端 ID 到本地文件
func saveClientID(dataDir, id string) {
if err := os.WriteFile(getIDFilePath(dataDir), []byte(id), 0600); err != nil {
log.Printf("[Client] Failed to save client ID: %v", err)
}
}
// SetPluginRegistry 设置插件注册表 // SetPluginRegistry 设置插件注册表
func (c *Client) SetPluginRegistry(registry *plugin.Registry) { func (c *Client) SetPluginRegistry(registry *plugin.Registry) {
c.pluginRegistry = registry c.pluginRegistry = registry
@@ -151,14 +147,14 @@ func (c *Client) logWarnf(format string, args ...interface{}) {
func (c *Client) Run() error { func (c *Client) Run() error {
for { for {
if err := c.connect(); err != nil { if err := c.connect(); err != nil {
c.logErrorf("[Client] Connect error: %v", err) c.logErrorf("Connect error: %v", err)
c.logf("[Client] Reconnecting in %v...", reconnectDelay) c.logf("Reconnecting in %v...", reconnectDelay)
time.Sleep(reconnectDelay) time.Sleep(reconnectDelay)
continue continue
} }
c.handleSession() c.handleSession()
c.logWarnf("[Client] Disconnected, reconnecting...") c.logWarnf("Disconnected, reconnecting...")
time.Sleep(disconnectDelay) time.Sleep(disconnectDelay)
} }
} }
@@ -181,6 +177,7 @@ func (c *Client) connect() error {
authReq := protocol.AuthRequest{ authReq := protocol.AuthRequest{
ClientID: c.ID, ClientID: c.ID,
Token: c.Token, Token: c.Token,
Name: c.Name,
OS: runtime.GOOS, OS: runtime.GOOS,
Arch: runtime.GOARCH, Arch: runtime.GOARCH,
Version: version.Version, Version: version.Version,
@@ -207,14 +204,13 @@ func (c *Client) connect() error {
return fmt.Errorf("auth failed: %s", authResp.Message) return fmt.Errorf("auth failed: %s", authResp.Message)
} }
// 如果服务端分配了新 ID则更新并保存 // 如果服务端分配了新 ID则更新
if authResp.ClientID != "" && authResp.ClientID != c.ID { if authResp.ClientID != "" && authResp.ClientID != c.ID {
c.ID = authResp.ClientID c.ID = authResp.ClientID
saveClientID(c.DataDir, c.ID) c.logf("ID updated to: %s", c.ID)
c.logf("[Client] New ID assigned and saved: %s", c.ID)
} }
c.logf("[Client] Authenticated as %s", c.ID) c.logf("Authenticated as %s", c.ID)
session, err := yamux.Client(conn, nil) session, err := yamux.Client(conn, nil)
if err != nil { if err != nil {
@@ -252,8 +248,7 @@ func (c *Client) handleStream(stream net.Conn) {
switch msg.Type { switch msg.Type {
case protocol.MsgTypeProxyConfig: case protocol.MsgTypeProxyConfig:
defer stream.Close() c.handleProxyConfig(stream, msg)
c.handleProxyConfig(msg)
case protocol.MsgTypeNewProxy: case protocol.MsgTypeNewProxy:
defer stream.Close() defer stream.Close()
c.handleNewProxy(stream, msg) c.handleNewProxy(stream, msg)
@@ -295,10 +290,12 @@ func (c *Client) handleStream(stream net.Conn) {
} }
// handleProxyConfig 处理代理配置 // handleProxyConfig 处理代理配置
func (c *Client) handleProxyConfig(msg *protocol.Message) { func (c *Client) handleProxyConfig(stream net.Conn, msg *protocol.Message) {
defer stream.Close()
var cfg protocol.ProxyConfig var cfg protocol.ProxyConfig
if err := msg.ParsePayload(&cfg); err != nil { if err := msg.ParsePayload(&cfg); err != nil {
c.logErrorf("[Client] Parse proxy config error: %v", err) c.logErrorf("Parse proxy config error: %v", err)
return return
} }
@@ -306,17 +303,21 @@ func (c *Client) handleProxyConfig(msg *protocol.Message) {
c.rules = cfg.Rules c.rules = cfg.Rules
c.mu.Unlock() c.mu.Unlock()
c.logf("[Client] Received %d proxy rules", len(cfg.Rules)) c.logf("Received %d proxy rules", len(cfg.Rules))
for _, r := range cfg.Rules { for _, r := range cfg.Rules {
c.logf("[Client] %s: %s:%d", r.Name, r.LocalIP, r.LocalPort) c.logf(" %s: %s:%d", r.Name, r.LocalIP, r.LocalPort)
} }
// 发送配置确认
ack := &protocol.Message{Type: protocol.MsgTypeProxyReady}
protocol.WriteMessage(stream, ack)
} }
// handleNewProxy 处理新代理请求 // handleNewProxy 处理新代理请求
func (c *Client) handleNewProxy(stream net.Conn, msg *protocol.Message) { func (c *Client) handleNewProxy(stream net.Conn, msg *protocol.Message) {
var req protocol.NewProxyRequest var req protocol.NewProxyRequest
if err := msg.ParsePayload(&req); err != nil { if err := msg.ParsePayload(&req); err != nil {
c.logErrorf("[Client] Parse new proxy request error: %v", err) c.logErrorf("Parse new proxy request error: %v", err)
return return
} }
@@ -331,14 +332,14 @@ func (c *Client) handleNewProxy(stream net.Conn, msg *protocol.Message) {
c.mu.RUnlock() c.mu.RUnlock()
if rule == nil { if rule == nil {
c.logWarnf("[Client] Unknown port %d", req.RemotePort) c.logWarnf("Unknown port %d", req.RemotePort)
return return
} }
localAddr := fmt.Sprintf("%s:%d", rule.LocalIP, rule.LocalPort) localAddr := fmt.Sprintf("%s:%d", rule.LocalIP, rule.LocalPort)
localConn, err := net.DialTimeout("tcp", localAddr, localDialTimeout) localConn, err := net.DialTimeout("tcp", localAddr, localDialTimeout)
if err != nil { if err != nil {
c.logErrorf("[Client] Connect %s error: %v", localAddr, err) c.logErrorf("Connect %s error: %v", localAddr, err)
return return
} }
@@ -448,24 +449,24 @@ func (c *Client) findRuleByPort(port int) *protocol.ProxyRule {
func (c *Client) handlePluginConfig(msg *protocol.Message) { func (c *Client) handlePluginConfig(msg *protocol.Message) {
var cfg protocol.PluginConfigSync var cfg protocol.PluginConfigSync
if err := msg.ParsePayload(&cfg); err != nil { if err := msg.ParsePayload(&cfg); err != nil {
c.logErrorf("[Client] Parse plugin config error: %v", err) c.logErrorf("Parse plugin config error: %v", err)
return return
} }
c.logf("[Client] Received config for plugin: %s", cfg.PluginName) c.logf("Received config for plugin: %s", cfg.PluginName)
// 应用配置到插件 // 应用配置到插件
if c.pluginRegistry != nil { if c.pluginRegistry != nil {
handler, err := c.pluginRegistry.GetClient(cfg.PluginName) handler, err := c.pluginRegistry.GetClient(cfg.PluginName)
if err != nil { if err != nil {
c.logWarnf("[Client] Plugin %s not found: %v", cfg.PluginName, err) c.logWarnf("Plugin %s not found: %v", cfg.PluginName, err)
return return
} }
if err := handler.Init(cfg.Config); err != nil { if err := handler.Init(cfg.Config); err != nil {
c.logErrorf("[Client] Plugin %s init error: %v", cfg.PluginName, err) c.logErrorf("Plugin %s init error: %v", cfg.PluginName, err)
return return
} }
c.logf("[Client] Plugin %s config applied", cfg.PluginName) c.logf("Plugin %s config applied", cfg.PluginName)
} }
} }
@@ -479,7 +480,7 @@ func (c *Client) handleClientPluginStart(stream net.Conn, msg *protocol.Message)
return return
} }
c.logf("[Client] Starting plugin %s for rule %s", req.PluginName, req.RuleName) c.logf("Starting plugin %s for rule %s", req.PluginName, req.RuleName)
// 获取插件 // 获取插件
if c.pluginRegistry == nil { if c.pluginRegistry == nil {
@@ -511,7 +512,7 @@ func (c *Client) handleClientPluginStart(stream net.Conn, msg *protocol.Message)
c.runningPlugins[key] = handler c.runningPlugins[key] = handler
c.pluginMu.Unlock() c.pluginMu.Unlock()
c.logf("[Client] Plugin %s started at %s", req.PluginName, localAddr) c.logf("Plugin %s started at %s", req.PluginName, localAddr)
c.sendPluginStatus(stream, req.PluginName, req.RuleName, true, localAddr, "") c.sendPluginStatus(stream, req.PluginName, req.RuleName, true, localAddr, "")
} }
@@ -553,7 +554,7 @@ func (c *Client) handleClientPluginConn(stream net.Conn, msg *protocol.Message)
c.pluginMu.RUnlock() c.pluginMu.RUnlock()
if !ok { if !ok {
c.logWarnf("[Client] Plugin %s (ID: %s) not running", req.PluginName, req.PluginID) c.logWarnf("Plugin %s (ID: %s) not running", req.PluginName, req.PluginID)
stream.Close() stream.Close()
return return
} }
@@ -572,7 +573,7 @@ func (c *Client) handleJSPluginInstall(stream net.Conn, msg *protocol.Message) {
return return
} }
c.logf("[Client] Installing JS plugin: %s (ID: %s)", req.PluginName, req.PluginID) c.logf("Installing JS plugin: %s (ID: %s)", req.PluginName, req.PluginID)
// 使用 PluginID 作为 key如果有否则回退到 pluginName:ruleName // 使用 PluginID 作为 key如果有否则回退到 pluginName:ruleName
key := req.PluginID key := req.PluginID
@@ -583,9 +584,9 @@ func (c *Client) handleJSPluginInstall(stream net.Conn, msg *protocol.Message) {
// 如果插件已经在运行,先停止它 // 如果插件已经在运行,先停止它
c.pluginMu.Lock() c.pluginMu.Lock()
if existingHandler, ok := c.runningPlugins[key]; ok { if existingHandler, ok := c.runningPlugins[key]; ok {
c.logf("[Client] Stopping existing plugin %s before reinstall", key) c.logf("Stopping existing plugin %s before reinstall", key)
if err := existingHandler.Stop(); err != nil { if err := existingHandler.Stop(); err != nil {
c.logErrorf("[Client] Stop existing plugin error: %v", err) c.logErrorf("Stop existing plugin error: %v", err)
} }
delete(c.runningPlugins, key) delete(c.runningPlugins, key)
} }
@@ -593,11 +594,11 @@ func (c *Client) handleJSPluginInstall(stream net.Conn, msg *protocol.Message) {
// 验证官方签名 // 验证官方签名
if err := c.verifyJSPluginSignature(req.PluginName, req.Source, req.Signature); err != nil { if err := c.verifyJSPluginSignature(req.PluginName, req.Source, req.Signature); err != nil {
c.logErrorf("[Client] JS plugin %s signature verification failed: %v", req.PluginName, err) c.logErrorf("JS plugin %s signature verification failed: %v", req.PluginName, err)
c.sendJSPluginResult(stream, req.PluginName, false, "signature verification failed: "+err.Error()) c.sendJSPluginResult(stream, req.PluginName, false, "signature verification failed: "+err.Error())
return return
} }
c.logf("[Client] JS plugin %s signature verified", req.PluginName) c.logf("JS plugin %s signature verified", req.PluginName)
// 创建 JS 插件 // 创建 JS 插件
jsPlugin, err := script.NewJSPlugin(req.PluginName, req.Source) jsPlugin, err := script.NewJSPlugin(req.PluginName, req.Source)
@@ -611,7 +612,7 @@ func (c *Client) handleJSPluginInstall(stream net.Conn, msg *protocol.Message) {
c.pluginRegistry.RegisterClient(jsPlugin) c.pluginRegistry.RegisterClient(jsPlugin)
} }
c.logf("[Client] JS plugin %s installed", req.PluginName) c.logf("JS plugin %s installed", req.PluginName)
// 保存版本信息(防止降级攻击) // 保存版本信息(防止降级攻击)
if c.versionStore != nil { if c.versionStore != nil {
@@ -644,13 +645,13 @@ func (c *Client) sendJSPluginResult(stream net.Conn, name string, success bool,
// startJSPlugin 启动 JS 插件 // startJSPlugin 启动 JS 插件
func (c *Client) startJSPlugin(handler plugin.ClientPlugin, req protocol.JSPluginInstallRequest) { func (c *Client) startJSPlugin(handler plugin.ClientPlugin, req protocol.JSPluginInstallRequest) {
if err := handler.Init(req.Config); err != nil { if err := handler.Init(req.Config); err != nil {
c.logErrorf("[Client] JS plugin %s init error: %v", req.PluginName, err) c.logErrorf("JS plugin %s init error: %v", req.PluginName, err)
return return
} }
localAddr, err := handler.Start() localAddr, err := handler.Start()
if err != nil { if err != nil {
c.logErrorf("[Client] JS plugin %s start error: %v", req.PluginName, err) c.logErrorf("JS plugin %s start error: %v", req.PluginName, err)
return return
} }
@@ -663,7 +664,7 @@ func (c *Client) startJSPlugin(handler plugin.ClientPlugin, req protocol.JSPlugi
c.runningPlugins[key] = handler c.runningPlugins[key] = handler
c.pluginMu.Unlock() c.pluginMu.Unlock()
c.logf("[Client] JS plugin %s (ID: %s) started at %s", req.PluginName, req.PluginID, localAddr) c.logf("JS plugin %s (ID: %s) started at %s", req.PluginName, req.PluginID, localAddr)
} }
// verifyJSPluginSignature 验证 JS 插件签名 // verifyJSPluginSignature 验证 JS 插件签名
@@ -741,13 +742,13 @@ func (c *Client) handleClientPluginStop(stream net.Conn, msg *protocol.Message)
if ok { if ok {
if err := handler.Stop(); err != nil { if err := handler.Stop(); err != nil {
c.logErrorf("[Client] Plugin %s stop error: %v", key, err) c.logErrorf("Plugin %s stop error: %v", key, err)
} }
delete(c.runningPlugins, key) delete(c.runningPlugins, key)
} }
c.pluginMu.Unlock() c.pluginMu.Unlock()
c.logf("[Client] Plugin %s stopped", key) c.logf("Plugin %s stopped", key)
c.sendPluginStatus(stream, req.PluginName, req.RuleName, false, "", "") c.sendPluginStatus(stream, req.PluginName, req.RuleName, false, "", "")
} }
@@ -758,7 +759,7 @@ func (c *Client) handleClientRestart(stream net.Conn, msg *protocol.Message) {
var req protocol.ClientRestartRequest var req protocol.ClientRestartRequest
msg.ParsePayload(&req) msg.ParsePayload(&req)
c.logf("[Client] Restart requested: %s", req.Reason) c.logf("Restart requested: %s", req.Reason)
// 发送响应 // 发送响应
resp := protocol.ClientRestartResponse{ resp := protocol.ClientRestartResponse{
@@ -771,7 +772,7 @@ func (c *Client) handleClientRestart(stream net.Conn, msg *protocol.Message) {
// 停止所有运行中的插件 // 停止所有运行中的插件
c.pluginMu.Lock() c.pluginMu.Lock()
for key, handler := range c.runningPlugins { for key, handler := range c.runningPlugins {
c.logf("[Client] Stopping plugin %s for restart", key) c.logf("Stopping plugin %s for restart", key)
handler.Stop() handler.Stop()
} }
c.runningPlugins = make(map[string]plugin.ClientPlugin) c.runningPlugins = make(map[string]plugin.ClientPlugin)
@@ -813,7 +814,7 @@ func (c *Client) handlePluginConfigUpdate(stream net.Conn, msg *protocol.Message
} }
c.pluginMu.RUnlock() c.pluginMu.RUnlock()
c.logf("[Client] Config update for plugin %s", key) c.logf("Config update for plugin %s", key)
if !ok { if !ok {
c.sendPluginConfigUpdateResult(stream, req.PluginName, req.RuleName, false, "plugin not running") c.sendPluginConfigUpdateResult(stream, req.PluginName, req.RuleName, false, "plugin not running")
@@ -824,7 +825,7 @@ func (c *Client) handlePluginConfigUpdate(stream net.Conn, msg *protocol.Message
// 停止并重启插件 // 停止并重启插件
c.pluginMu.Lock() c.pluginMu.Lock()
if err := handler.Stop(); err != nil { if err := handler.Stop(); err != nil {
c.logErrorf("[Client] Plugin %s stop error: %v", key, err) c.logErrorf("Plugin %s stop error: %v", key, err)
} }
delete(c.runningPlugins, key) delete(c.runningPlugins, key)
c.pluginMu.Unlock() c.pluginMu.Unlock()
@@ -845,7 +846,7 @@ func (c *Client) handlePluginConfigUpdate(stream net.Conn, msg *protocol.Message
c.runningPlugins[key] = handler c.runningPlugins[key] = handler
c.pluginMu.Unlock() c.pluginMu.Unlock()
c.logf("[Client] Plugin %s restarted at %s with new config", key, localAddr) c.logf("Plugin %s restarted at %s with new config", key, localAddr)
} }
c.sendPluginConfigUpdateResult(stream, req.PluginName, req.RuleName, true, "") c.sendPluginConfigUpdateResult(stream, req.PluginName, req.RuleName, true, "")
@@ -869,17 +870,17 @@ func (c *Client) handleUpdateDownload(stream net.Conn, msg *protocol.Message) {
var req protocol.UpdateDownloadRequest var req protocol.UpdateDownloadRequest
if err := msg.ParsePayload(&req); err != nil { if err := msg.ParsePayload(&req); err != nil {
c.logErrorf("[Client] Parse update request error: %v", err) c.logErrorf("Parse update request error: %v", err)
c.sendUpdateResult(stream, false, "invalid request") c.sendUpdateResult(stream, false, "invalid request")
return return
} }
c.logf("[Client] Update download requested: %s", req.DownloadURL) c.logf("Update download requested: %s", req.DownloadURL)
// 异步执行更新 // 异步执行更新
go func() { go func() {
if err := c.performSelfUpdate(req.DownloadURL); err != nil { if err := c.performSelfUpdate(req.DownloadURL); err != nil {
c.logErrorf("[Client] Update failed: %v", err) c.logErrorf("Update failed: %v", err)
} }
}() }()
@@ -898,65 +899,106 @@ func (c *Client) sendUpdateResult(stream net.Conn, success bool, message string)
// performSelfUpdate 执行自更新 // performSelfUpdate 执行自更新
func (c *Client) performSelfUpdate(downloadURL string) error { func (c *Client) performSelfUpdate(downloadURL string) error {
c.logf("[Client] Starting self-update from: %s", downloadURL) c.logf("Starting self-update from: %s", downloadURL)
// 使用共享的下载和解压逻辑
binaryPath, cleanup, err := update.DownloadAndExtract(downloadURL, "client")
if err != nil {
return err
}
defer cleanup()
// 获取当前可执行文件路径 // 获取当前可执行文件路径
currentPath, err := os.Executable() currentPath, err := os.Executable()
if err != nil { if err != nil {
return fmt.Errorf("get executable: %w", err) c.logErrorf("Update failed: cannot get executable path: %v", err)
return err
} }
currentPath, _ = filepath.EvalSymlinks(currentPath) currentPath, _ = filepath.EvalSymlinks(currentPath)
// 预检查:验证是否有写权限(在下载前检查,避免浪费带宽)
if err := c.checkUpdatePermissions(currentPath); err != nil {
c.logErrorf("Update failed: %v", err)
c.logErrorf("Self-update is not supported in this environment. Please update manually.")
return err
}
// 使用共享的下载和解压逻辑
c.logf("Downloading update package...")
binaryPath, cleanup, err := update.DownloadAndExtract(downloadURL, "client")
if err != nil {
c.logErrorf("Update failed: download/extract error: %v", err)
return err
}
defer cleanup()
// Windows 需要特殊处理 // Windows 需要特殊处理
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
return performWindowsClientUpdate(binaryPath, currentPath, c.ServerAddr, c.Token, c.ID) return performWindowsClientUpdate(binaryPath, currentPath, c.ServerAddr, c.Token, c.ID)
} }
// Linux/Mac: 直接替换 // Linux/Mac/Android: 直接替换
backupPath := currentPath + ".bak" backupPath := currentPath + ".bak"
// 停止所有插件 // 停止所有插件
c.stopAllPlugins() c.stopAllPlugins()
// 备份当前文件 // 备份当前文件
c.logf("Backing up current binary...")
if err := os.Rename(currentPath, backupPath); err != nil { if err := os.Rename(currentPath, backupPath); err != nil {
return fmt.Errorf("backup current: %w", err) c.logErrorf("Update failed: cannot backup current binary: %v", err)
c.logErrorf("This may be due to insufficient permissions or read-only filesystem.")
return err
} }
// 复制新文件(不能用 rename可能跨文件系统 // 复制新文件(不能用 rename可能跨文件系统
c.logf("Installing new binary...")
if err := update.CopyFile(binaryPath, currentPath); err != nil { if err := update.CopyFile(binaryPath, currentPath); err != nil {
os.Rename(backupPath, currentPath) os.Rename(backupPath, currentPath)
return fmt.Errorf("replace binary: %w", err) c.logErrorf("Update failed: cannot install new binary: %v", err)
return err
} }
// 设置执行权限 // 设置执行权限
if err := os.Chmod(currentPath, 0755); err != nil { if err := os.Chmod(currentPath, 0755); err != nil {
os.Rename(backupPath, currentPath) os.Rename(backupPath, currentPath)
return fmt.Errorf("chmod: %w", err) c.logErrorf("Update failed: cannot set execute permission: %v", err)
return err
} }
// 删除备份 // 删除备份
os.Remove(backupPath) os.Remove(backupPath)
c.logf("[Client] Update completed, restarting...") c.logf("Update completed successfully, restarting...")
// 重启进程 // 重启进程
restartClientProcess(currentPath, c.ServerAddr, c.Token, c.ID) restartClientProcess(currentPath, c.ServerAddr, c.Token, c.ID)
return nil return nil
} }
// checkUpdatePermissions 检查是否有更新权限
func (c *Client) checkUpdatePermissions(execPath string) error {
// 检查可执行文件所在目录是否可写
dir := filepath.Dir(execPath)
testFile := filepath.Join(dir, ".gotunnel_update_test")
f, err := os.Create(testFile)
if err != nil {
c.logErrorf("No write permission to directory: %s", dir)
return err
}
f.Close()
os.Remove(testFile)
// 检查可执行文件本身是否可写
f, err = os.OpenFile(execPath, os.O_WRONLY, 0)
if err != nil {
c.logErrorf("No write permission to executable: %s", execPath)
return err
}
f.Close()
return nil
}
// stopAllPlugins 停止所有运行中的插件 // stopAllPlugins 停止所有运行中的插件
func (c *Client) stopAllPlugins() { func (c *Client) stopAllPlugins() {
c.pluginMu.Lock() c.pluginMu.Lock()
for key, handler := range c.runningPlugins { for key, handler := range c.runningPlugins {
c.logf("[Client] Stopping plugin %s for update", key) c.logf("Stopping plugin %s for update", key)
handler.Stop() handler.Stop()
} }
c.runningPlugins = make(map[string]plugin.ClientPlugin) c.runningPlugins = make(map[string]plugin.ClientPlugin)
@@ -1122,7 +1164,7 @@ func (c *Client) handlePluginAPIRequest(stream net.Conn, msg *protocol.Message)
return return
} }
c.logf("[Client] Plugin API request: %s %s for plugin %s (ID: %s)", req.Method, req.Path, req.PluginName, req.PluginID) c.logf("Plugin API request: %s %s for plugin %s (ID: %s)", req.Method, req.Path, req.PluginName, req.PluginID)
// 查找运行中的插件 // 查找运行中的插件
c.pluginMu.RLock() c.pluginMu.RLock()
@@ -1185,7 +1227,7 @@ func (c *Client) handleSystemStatsRequest(stream net.Conn, msg *protocol.Message
stats, err := utils.GetSystemStats() stats, err := utils.GetSystemStats()
if err != nil { if err != nil {
log.Printf("[Client] Failed to get system stats: %v", err) log.Printf("Failed to get system stats: %v", err)
return return
} }

View File

@@ -0,0 +1,133 @@
package tunnel
import (
"crypto/sha256"
"encoding/hex"
"net"
"os"
"os/exec"
"runtime"
"strings"
)
// getMachineID 获取机器唯一标识
// 优先级系统机器ID > MAC地址哈希
func getMachineID() string {
// 尝试获取系统机器 ID
if id := getSystemMachineID(); id != "" {
return hashID(id)
}
// 备选:使用主网卡 MAC 地址
if id := getMACAddress(); id != "" {
return hashID(id)
}
// 都失败则返回空,让服务端生成
return ""
}
// getSystemMachineID 获取系统机器 ID
func getSystemMachineID() string {
switch runtime.GOOS {
case "linux":
return getLinuxMachineID()
case "darwin":
return getDarwinMachineID()
case "windows":
return getWindowsMachineID()
default:
return ""
}
}
// getLinuxMachineID 获取 Linux 机器 ID
func getLinuxMachineID() string {
// 优先读取 /etc/machine-id
if data, err := os.ReadFile("/etc/machine-id"); err == nil {
return strings.TrimSpace(string(data))
}
// 备选 /var/lib/dbus/machine-id
if data, err := os.ReadFile("/var/lib/dbus/machine-id"); err == nil {
return strings.TrimSpace(string(data))
}
return ""
}
// getDarwinMachineID 获取 macOS 机器 ID (IOPlatformUUID)
func getDarwinMachineID() string {
cmd := exec.Command("ioreg", "-rd1", "-c", "IOPlatformExpertDevice")
output, err := cmd.Output()
if err != nil {
return ""
}
// 解析 IOPlatformUUID
lines := strings.Split(string(output), "\n")
for _, line := range lines {
if strings.Contains(line, "IOPlatformUUID") {
parts := strings.Split(line, "=")
if len(parts) == 2 {
uuid := strings.TrimSpace(parts[1])
uuid = strings.Trim(uuid, "\"")
return uuid
}
}
}
return ""
}
// getWindowsMachineID 获取 Windows 机器 ID
func getWindowsMachineID() string {
cmd := exec.Command("reg", "query",
`HKLM\SOFTWARE\Microsoft\Cryptography`,
"/v", "MachineGuid")
output, err := cmd.Output()
if err != nil {
return ""
}
// 解析注册表输出
lines := strings.Split(string(output), "\n")
for _, line := range lines {
if strings.Contains(line, "MachineGuid") {
fields := strings.Fields(line)
if len(fields) >= 3 {
return fields[len(fields)-1]
}
}
}
return ""
}
// getMACAddress 获取主网卡 MAC 地址
func getMACAddress() string {
interfaces, err := net.Interfaces()
if err != nil {
return ""
}
for _, iface := range interfaces {
// 跳过回环和无效接口
if iface.Flags&net.FlagLoopback != 0 {
continue
}
if iface.Flags&net.FlagUp == 0 {
continue
}
if len(iface.HardwareAddr) == 0 {
continue
}
// 返回第一个有效的 MAC 地址
return iface.HardwareAddr.String()
}
return ""
}
// hashID 对 ID 进行哈希处理,生成固定长度的客户端 ID
func hashID(id string) string {
hash := sha256.Sum256([]byte(id))
// 取前 16 个字符作为客户端 ID
return hex.EncodeToString(hash[:])[:16]
}

View File

@@ -397,14 +397,19 @@ func (s *SQLiteStore) Get24HourTraffic() (inbound, outbound int64, err error) {
return return
} }
// GetHourlyTraffic 获取每小时流量记录 // GetHourlyTraffic 获取每小时流量记录(始终返回完整的 hours 小时数据)
func (s *SQLiteStore) GetHourlyTraffic(hours int) ([]TrafficRecord, error) { func (s *SQLiteStore) GetHourlyTraffic(hours int) ([]TrafficRecord, error) {
s.mu.RLock() s.mu.RLock()
defer s.mu.RUnlock() defer s.mu.RUnlock()
cutoff := time.Now().Add(-time.Duration(hours) * time.Hour).Unix() // 计算当前小时的起始时间戳
now := time.Now()
currentHour := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location())
// 查询数据库中的记录
cutoff := currentHour.Add(-time.Duration(hours-1) * time.Hour).Unix()
rows, err := s.db.Query(` rows, err := s.db.Query(`
SELECT hour_ts, inbound, outbound FROM traffic_stats SELECT hour_ts, inbound, outbound FROM traffic_stats
WHERE hour_ts >= ? ORDER BY hour_ts ASC WHERE hour_ts >= ? ORDER BY hour_ts ASC
`, cutoff) `, cutoff)
if err != nil { if err != nil {
@@ -412,13 +417,26 @@ func (s *SQLiteStore) GetHourlyTraffic(hours int) ([]TrafficRecord, error) {
} }
defer rows.Close() defer rows.Close()
var records []TrafficRecord // 将数据库记录放入 map 以便快速查找
dbRecords := make(map[int64]TrafficRecord)
for rows.Next() { for rows.Next() {
var r TrafficRecord var r TrafficRecord
if err := rows.Scan(&r.Timestamp, &r.Inbound, &r.Outbound); err != nil { if err := rows.Scan(&r.Timestamp, &r.Inbound, &r.Outbound); err != nil {
return nil, err return nil, err
} }
records = append(records, r) dbRecords[r.Timestamp] = r
} }
// 生成完整的 hours 小时数据
records := make([]TrafficRecord, hours)
for i := 0; i < hours; i++ {
ts := currentHour.Add(-time.Duration(hours-1-i) * time.Hour).Unix()
if r, ok := dbRecords[ts]; ok {
records[i] = r
} else {
records[i] = TrafficRecord{Timestamp: ts, Inbound: 0, Outbound: 0}
}
}
return records, nil return records, nil
} }

View File

@@ -115,7 +115,7 @@ func (h *ClientHandler) Get(c *gin.Context) {
return return
} }
online, lastPing, remoteAddr, clientOS, clientArch, clientVersion := h.app.GetServer().GetClientStatus(clientID) online, lastPing, remoteAddr, clientName, clientOS, clientArch, clientVersion := h.app.GetServer().GetClientStatus(clientID)
// 复制插件列表 // 复制插件列表
plugins := make([]db.ClientPlugin, len(client.Plugins)) plugins := make([]db.ClientPlugin, len(client.Plugins))
@@ -145,9 +145,15 @@ func (h *ClientHandler) Get(c *gin.Context) {
} }
} }
// 如果客户端在线且有名称,优先使用在线名称
nickname := client.Nickname
if online && clientName != "" && nickname == "" {
nickname = clientName
}
resp := dto.ClientResponse{ resp := dto.ClientResponse{
ID: client.ID, ID: client.ID,
Nickname: client.Nickname, Nickname: nickname,
Rules: client.Rules, Rules: client.Rules,
Plugins: plugins, Plugins: plugins,
Online: online, Online: online,
@@ -242,8 +248,7 @@ func (h *ClientHandler) Delete(c *gin.Context) {
func (h *ClientHandler) PushConfig(c *gin.Context) { func (h *ClientHandler) PushConfig(c *gin.Context) {
clientID := c.Param("id") clientID := c.Param("id")
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID) if !h.app.GetServer().IsClientOnline(clientID) {
if !online {
ClientNotOnline(c) ClientNotOnline(c)
return return
} }
@@ -311,8 +316,7 @@ func (h *ClientHandler) Restart(c *gin.Context) {
func (h *ClientHandler) InstallPlugins(c *gin.Context) { func (h *ClientHandler) InstallPlugins(c *gin.Context) {
clientID := c.Param("id") clientID := c.Param("id")
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID) if !h.app.GetServer().IsClientOnline(clientID) {
if !online {
ClientNotOnline(c) ClientNotOnline(c)
return return
} }

View File

@@ -19,11 +19,13 @@ type AppInterface interface {
// ServerInterface 服务端接口 // ServerInterface 服务端接口
type ServerInterface interface { type ServerInterface interface {
GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientOS, clientArch, clientVersion string) IsClientOnline(clientID string) bool
GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientName, clientOS, clientArch, clientVersion string)
GetAllClientStatus() map[string]struct { GetAllClientStatus() map[string]struct {
Online bool Online bool
LastPing string LastPing string
RemoteAddr string RemoteAddr string
Name string
OS string OS string
Arch string Arch string
Version string Version string

View File

@@ -177,8 +177,7 @@ func (h *JSPluginHandler) PushToClient(c *gin.Context) {
c.ShouldBindJSON(&pushReq) // 忽略错误,允许空请求体 c.ShouldBindJSON(&pushReq) // 忽略错误,允许空请求体
// 检查客户端是否在线 // 检查客户端是否在线
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID) if !h.app.GetServer().IsClientOnline(clientID) {
if !online {
ClientNotOnline(c) ClientNotOnline(c)
return return
} }

View File

@@ -35,8 +35,7 @@ func (h *LogHandler) StreamLogs(c *gin.Context) {
clientID := c.Param("id") clientID := c.Param("id")
// 检查客户端是否在线 // 检查客户端是否在线
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID) if !h.app.GetServer().IsClientOnline(clientID) {
if !online {
c.JSON(400, gin.H{"code": 400, "message": "client not online"}) c.JSON(400, gin.H{"code": 400, "message": "client not online"})
return return
} }

View File

@@ -371,8 +371,7 @@ func (h *PluginHandler) UpdateClientConfig(c *gin.Context) {
} }
// 如果客户端在线,同步配置 // 如果客户端在线,同步配置
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID) if h.app.GetServer().IsClientOnline(clientID) {
if online {
if err := h.app.GetServer().SyncPluginConfigToClient(clientID, pluginName, req.Config); err != nil { if err := h.app.GetServer().SyncPluginConfigToClient(clientID, pluginName, req.Config); err != nil {
PartialSuccess(c, gin.H{"status": "partial", "port_changed": portChanged}, "config saved but sync failed: "+err.Error()) PartialSuccess(c, gin.H{"status": "partial", "port_changed": portChanged}, "config saved but sync failed: "+err.Error())
return return

View File

@@ -45,8 +45,7 @@ func (h *PluginAPIHandler) ProxyRequest(c *gin.Context) {
} }
// 检查客户端是否在线 // 检查客户端是否在线
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID) if !h.app.GetServer().IsClientOnline(clientID) {
if !online {
ClientNotOnline(c) ClientNotOnline(c)
return return
} }

View File

@@ -82,8 +82,7 @@ func (h *StoreHandler) Install(c *gin.Context) {
} }
// 检查客户端是否在线 // 检查客户端是否在线
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(req.ClientID) if !h.app.GetServer().IsClientOnline(req.ClientID) {
if !online {
ClientNotOnline(c) ClientNotOnline(c)
return return
} }

View File

@@ -51,6 +51,7 @@ func generateClientID() string {
type Server struct { type Server struct {
clientStore db.ClientStore clientStore db.ClientStore
jsPluginStore db.JSPluginStore // JS 插件存储 jsPluginStore db.JSPluginStore // JS 插件存储
trafficStore db.TrafficStore // 流量存储
bindAddr string bindAddr string
bindPort int bindPort int
token string token string
@@ -83,6 +84,7 @@ type JSPluginEntry struct {
// ClientSession 客户端会话 // ClientSession 客户端会话
type ClientSession struct { type ClientSession struct {
ID string ID string
Name string // 客户端名称(主机名)
RemoteAddr string // 客户端 IP 地址 RemoteAddr string // 客户端 IP 地址
OS string // 客户端操作系统 OS string // 客户端操作系统
Arch string // 客户端架构 Arch string // 客户端架构
@@ -160,6 +162,11 @@ func (s *Server) SetJSPluginStore(store db.JSPluginStore) {
s.jsPluginStore = store s.jsPluginStore = store
} }
// SetTrafficStore 设置流量存储
func (s *Server) SetTrafficStore(store db.TrafficStore) {
s.trafficStore = store
}
// LoadJSPlugins 加载 JS 插件配置 // LoadJSPlugins 加载 JS 插件配置
func (s *Server) LoadJSPlugins(plugins []JSPluginEntry) { func (s *Server) LoadJSPlugins(plugins []JSPluginEntry) {
s.jsPlugins = plugins s.jsPlugins = plugins
@@ -269,13 +276,22 @@ func (s *Server) handleConnection(conn net.Conn) {
// 检查客户端是否存在,不存在则自动创建 // 检查客户端是否存在,不存在则自动创建
exists, err := s.clientStore.ClientExists(clientID) exists, err := s.clientStore.ClientExists(clientID)
if err != nil || !exists { if err != nil || !exists {
newClient := &db.Client{ID: clientID, Rules: []protocol.ProxyRule{}} newClient := &db.Client{ID: clientID, Nickname: authReq.Name, Rules: []protocol.ProxyRule{}}
if err := s.clientStore.CreateClient(newClient); err != nil { if err := s.clientStore.CreateClient(newClient); err != nil {
log.Printf("[Server] Create client error: %v", err) log.Printf("[Server] Create client error: %v", err)
s.sendAuthResponse(conn, false, "failed to create client", "") s.sendAuthResponse(conn, false, "failed to create client", "")
return return
} }
log.Printf("[Server] New client registered: %s", clientID) log.Printf("[Server] New client registered: %s (%s)", clientID, authReq.Name)
} else if authReq.Name != "" {
// 客户端已存在,仅当 Nickname 为空时才用客户端名称更新
// 这样服务端手动设置的名称不会被客户端覆盖
if client, err := s.clientStore.GetClient(clientID); err == nil {
if client.Nickname == "" {
client.Nickname = authReq.Name
s.clientStore.UpdateClient(client)
}
}
} }
rules, _ := s.clientStore.GetClientRules(clientID) rules, _ := s.clientStore.GetClientRules(clientID)
@@ -290,11 +306,11 @@ func (s *Server) handleConnection(conn net.Conn) {
} }
security.LogAuthSuccess(clientIP, clientID) security.LogAuthSuccess(clientIP, clientID)
s.setupClientSession(conn, clientID, authReq.OS, authReq.Arch, authReq.Version, rules) s.setupClientSession(conn, clientID, authReq.Name, authReq.OS, authReq.Arch, authReq.Version, rules)
} }
// setupClientSession 建立客户端会话 // setupClientSession 建立客户端会话
func (s *Server) setupClientSession(conn net.Conn, clientID, clientOS, clientArch, clientVersion string, rules []protocol.ProxyRule) { func (s *Server) setupClientSession(conn net.Conn, clientID, clientName, clientOS, clientArch, clientVersion string, rules []protocol.ProxyRule) {
session, err := yamux.Server(conn, nil) session, err := yamux.Server(conn, nil)
if err != nil { if err != nil {
log.Printf("[Server] Yamux error: %v", err) log.Printf("[Server] Yamux error: %v", err)
@@ -309,6 +325,7 @@ func (s *Server) setupClientSession(conn net.Conn, clientID, clientOS, clientArc
cs := &ClientSession{ cs := &ClientSession{
ID: clientID, ID: clientID,
Name: clientName,
RemoteAddr: remoteAddr, RemoteAddr: remoteAddr,
OS: clientOS, OS: clientOS,
Arch: clientArch, Arch: clientArch,
@@ -348,7 +365,7 @@ func (s *Server) sendAuthResponse(conn net.Conn, success bool, message, clientID
return protocol.WriteMessage(conn, msg) return protocol.WriteMessage(conn, msg)
} }
// sendProxyConfig 发送代理配置 // sendProxyConfig 发送代理配置并等待客户端确认
func (s *Server) sendProxyConfig(session *yamux.Session, rules []protocol.ProxyRule) error { func (s *Server) sendProxyConfig(session *yamux.Session, rules []protocol.ProxyRule) error {
stream, err := session.Open() stream, err := session.Open()
if err != nil { if err != nil {
@@ -361,7 +378,20 @@ func (s *Server) sendProxyConfig(session *yamux.Session, rules []protocol.ProxyR
if err != nil { if err != nil {
return err return err
} }
return protocol.WriteMessage(stream, msg) if err := protocol.WriteMessage(stream, msg); err != nil {
return err
}
// 等待客户端确认
ack, err := protocol.ReadMessage(stream)
if err != nil {
return fmt.Errorf("wait config ack: %w", err)
}
if ack.Type != protocol.MsgTypeProxyReady {
return fmt.Errorf("unexpected ack type: %d", ack.Type)
}
return nil
} }
// registerClient 注册客户端 // registerClient 注册客户端
@@ -484,8 +514,8 @@ func (s *Server) acceptProxyConns(cs *ClientSession, ln net.Listener, rule proto
func (s *Server) acceptProxyServerConns(cs *ClientSession, ln net.Listener, rule protocol.ProxyRule) { func (s *Server) acceptProxyServerConns(cs *ClientSession, ln net.Listener, rule protocol.ProxyRule) {
dialer := proxy.NewTunnelDialer(cs.Session) dialer := proxy.NewTunnelDialer(cs.Session)
// 使用内置 proxy 实现 // 使用内置 proxy 实现 (带流量统计)
proxyServer := proxy.NewServer(rule.Type, dialer) proxyServer := proxy.NewServer(rule.Type, dialer, s.recordTraffic)
for { for {
conn, err := ln.Accept() conn, err := ln.Accept()
if err != nil { if err != nil {
@@ -512,7 +542,7 @@ func (s *Server) handleProxyConn(cs *ClientSession, conn net.Conn, rule protocol
return return
} }
relay.Relay(conn, stream) relay.RelayWithStats(conn, stream, s.recordTraffic)
} }
// heartbeatLoop 心跳检测循环 // heartbeatLoop 心跳检测循环
@@ -573,16 +603,24 @@ func (s *Server) sendHeartbeat(cs *ClientSession) bool {
} }
// GetClientStatus 获取客户端状态 // GetClientStatus 获取客户端状态
func (s *Server) GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientOS, clientArch, clientVersion string) { func (s *Server) GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientName, clientOS, clientArch, clientVersion string) {
s.mu.RLock() s.mu.RLock()
defer s.mu.RUnlock() defer s.mu.RUnlock()
if cs, ok := s.clients[clientID]; ok { if cs, ok := s.clients[clientID]; ok {
cs.mu.Lock() cs.mu.Lock()
defer cs.mu.Unlock() defer cs.mu.Unlock()
return true, cs.LastPing.Format(time.RFC3339), cs.RemoteAddr, cs.OS, cs.Arch, cs.Version return true, cs.LastPing.Format(time.RFC3339), cs.RemoteAddr, cs.Name, cs.OS, cs.Arch, cs.Version
} }
return false, "", "", "", "", "" return false, "", "", "", "", "", ""
}
// IsClientOnline 检查客户端是否在线
func (s *Server) IsClientOnline(clientID string) bool {
s.mu.RLock()
defer s.mu.RUnlock()
_, ok := s.clients[clientID]
return ok
} }
// GetClientPluginStatus 获取客户端插件运行状态 // GetClientPluginStatus 获取客户端插件运行状态
@@ -633,6 +671,7 @@ func (s *Server) GetAllClientStatus() map[string]struct {
Online bool Online bool
LastPing string LastPing string
RemoteAddr string RemoteAddr string
Name string
OS string OS string
Arch string Arch string
Version string Version string
@@ -649,6 +688,7 @@ func (s *Server) GetAllClientStatus() map[string]struct {
Online bool Online bool
LastPing string LastPing string
RemoteAddr string RemoteAddr string
Name string
OS string OS string
Arch string Arch string
Version string Version string
@@ -660,6 +700,7 @@ func (s *Server) GetAllClientStatus() map[string]struct {
Online bool Online bool
LastPing string LastPing string
RemoteAddr string RemoteAddr string
Name string
OS string OS string
Arch string Arch string
Version string Version string
@@ -667,6 +708,7 @@ func (s *Server) GetAllClientStatus() map[string]struct {
Online: true, Online: true,
LastPing: cs.LastPing.Format(time.RFC3339), LastPing: cs.LastPing.Format(time.RFC3339),
RemoteAddr: cs.RemoteAddr, RemoteAddr: cs.RemoteAddr,
Name: cs.Name,
OS: cs.OS, OS: cs.OS,
Arch: cs.Arch, Arch: cs.Arch,
Version: cs.Version, Version: cs.Version,
@@ -921,6 +963,9 @@ func (s *Server) sendUDPPacket(cs *ClientSession, conn *net.UDPConn, clientAddr
return return
} }
// 记录入站流量 (从外部接收的数据)
s.recordTraffic(int64(len(packet.Data)), 0)
// 等待客户端响应 // 等待客户端响应
respMsg, err := protocol.ReadMessage(stream) respMsg, err := protocol.ReadMessage(stream)
if err != nil { if err != nil {
@@ -933,6 +978,8 @@ func (s *Server) sendUDPPacket(cs *ClientSession, conn *net.UDPConn, clientAddr
return return
} }
conn.WriteToUDP(respPacket.Data, clientAddr) conn.WriteToUDP(respPacket.Data, clientAddr)
// 记录出站流量 (发送回外部的数据)
s.recordTraffic(0, int64(len(respPacket.Data)))
} }
} }
@@ -1188,7 +1235,7 @@ func (s *Server) handleClientPluginConn(cs *ClientSession, conn net.Conn, rule p
} }
} }
relay.Relay(conn, stream) relay.RelayWithStats(conn, stream, s.recordTraffic)
} }
// checkHTTPBasicAuth 检查 HTTP Basic Auth // checkHTTPBasicAuth 检查 HTTP Basic Auth
@@ -1871,6 +1918,16 @@ func (s *Server) StopClientLogStream(sessionID string) {
s.logSessions.RemoveSession(sessionID) s.logSessions.RemoveSession(sessionID)
} }
// recordTraffic 记录流量统计
func (s *Server) recordTraffic(inbound, outbound int64) {
if s.trafficStore == nil {
return
}
if err := s.trafficStore.AddTraffic(inbound, outbound); err != nil {
log.Printf("[Server] Record traffic error: %v", err)
}
}
// boolPtr 返回 bool 值的指针 // boolPtr 返回 bool 值的指针
func boolPtr(b bool) *bool { func boolPtr(b bool) *bool {
return &b return &b

View File

@@ -142,5 +142,5 @@ func (s *Server) handleWebsocketProxyConn(cs *ClientSession, conn net.Conn, rule
return return
} }
relay.Relay(conn, stream) relay.RelayWithStats(conn, stream, s.recordTraffic)
} }

View File

@@ -87,6 +87,7 @@ type Message struct {
type AuthRequest struct { type AuthRequest struct {
ClientID string `json:"client_id"` ClientID string `json:"client_id"`
Token string `json:"token"` Token string `json:"token"`
Name string `json:"name,omitempty"` // 客户端名称(主机名)
OS string `json:"os,omitempty"` // 客户端操作系统 OS string `json:"os,omitempty"` // 客户端操作系统
Arch string `json:"arch,omitempty"` // 客户端架构 Arch string `json:"arch,omitempty"` // 客户端架构
Version string `json:"version,omitempty"` // 客户端版本 Version string `json:"version,omitempty"` // 客户端版本

View File

@@ -6,16 +6,19 @@ import (
"net" "net"
"net/http" "net/http"
"strings" "strings"
"github.com/gotunnel/pkg/relay"
) )
// HTTPServer HTTP 代理服务 // HTTPServer HTTP 代理服务
type HTTPServer struct { type HTTPServer struct {
dialer Dialer dialer Dialer
onStats func(in, out int64) // 流量统计回调
} }
// NewHTTPServer 创建 HTTP 代理服务 // NewHTTPServer 创建 HTTP 代理服务
func NewHTTPServer(dialer Dialer) *HTTPServer { func NewHTTPServer(dialer Dialer, onStats func(in, out int64)) *HTTPServer {
return &HTTPServer{dialer: dialer} return &HTTPServer{dialer: dialer, onStats: onStats}
} }
// HandleConn 处理 HTTP 代理连接 // HandleConn 处理 HTTP 代理连接
@@ -50,8 +53,8 @@ func (h *HTTPServer) handleConnect(conn net.Conn, req *http.Request) error {
conn.Write([]byte("HTTP/1.1 200 Connection Established\r\n\r\n")) conn.Write([]byte("HTTP/1.1 200 Connection Established\r\n\r\n"))
go io.Copy(remote, conn) // 双向转发 (带流量统计)
io.Copy(conn, remote) relay.RelayWithStats(conn, remote, h.onStats)
return nil return nil
} }
@@ -82,7 +85,10 @@ func (h *HTTPServer) handleHTTP(conn net.Conn, req *http.Request, reader *bufio.
return err return err
} }
// 转发响应 // 转发响应 (带流量统计)
_, err = io.Copy(conn, remote) n, err := io.Copy(conn, remote)
if h.onStats != nil && n > 0 {
h.onStats(0, n) // 响应数据为出站流量
}
return err return err
} }

View File

@@ -14,10 +14,10 @@ type Server struct {
} }
// NewServer 创建代理服务器 // NewServer 创建代理服务器
func NewServer(typ string, dialer Dialer) *Server { func NewServer(typ string, dialer Dialer, onStats func(in, out int64)) *Server {
return &Server{ return &Server{
socks5: NewSOCKS5Server(dialer), socks5: NewSOCKS5Server(dialer, onStats),
http: NewHTTPServer(dialer), http: NewHTTPServer(dialer, onStats),
typ: typ, typ: typ,
} }
} }

View File

@@ -6,6 +6,8 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"github.com/gotunnel/pkg/relay"
) )
const ( const (
@@ -19,7 +21,8 @@ const (
// SOCKS5Server SOCKS5 代理服务 // SOCKS5Server SOCKS5 代理服务
type SOCKS5Server struct { type SOCKS5Server struct {
dialer Dialer dialer Dialer
onStats func(in, out int64) // 流量统计回调
} }
// Dialer 连接拨号器接口 // Dialer 连接拨号器接口
@@ -28,8 +31,8 @@ type Dialer interface {
} }
// NewSOCKS5Server 创建 SOCKS5 服务 // NewSOCKS5Server 创建 SOCKS5 服务
func NewSOCKS5Server(dialer Dialer) *SOCKS5Server { func NewSOCKS5Server(dialer Dialer, onStats func(in, out int64)) *SOCKS5Server {
return &SOCKS5Server{dialer: dialer} return &SOCKS5Server{dialer: dialer, onStats: onStats}
} }
// HandleConn 处理 SOCKS5 连接 // HandleConn 处理 SOCKS5 连接
@@ -60,9 +63,8 @@ func (s *SOCKS5Server) HandleConn(conn net.Conn) error {
return err return err
} }
// 双向转发 // 双向转发 (带流量统计)
go io.Copy(remote, conn) relay.RelayWithStats(conn, remote, s.onStats)
io.Copy(conn, remote)
return nil return nil
} }

View File

@@ -13,6 +13,8 @@ import (
// 版本信息 // 版本信息
var Version = "1.0.0" var Version = "1.0.0"
var GitCommit = ""
var BuildTime = ""
// SetVersion 设置版本号(由 main 包在初始化时调用) // SetVersion 设置版本号(由 main 包在初始化时调用)
func SetVersion(v string) { func SetVersion(v string) {
@@ -21,6 +23,16 @@ func SetVersion(v string) {
} }
} }
// SetBuildInfo 设置构建信息(由 main 包在初始化时调用)
func SetBuildInfo(gitCommit, buildTime string) {
if gitCommit != "" {
GitCommit = gitCommit
}
if buildTime != "" {
BuildTime = buildTime
}
}
// 仓库信息 // 仓库信息
const ( const (
RepoURL = "https://git.92coco.cn/flik/GoTunnel" RepoURL = "https://git.92coco.cn/flik/GoTunnel"
@@ -43,8 +55,8 @@ type Info struct {
func GetInfo() Info { func GetInfo() Info {
return Info{ return Info{
Version: Version, Version: Version,
GitCommit: "", GitCommit: GitCommit,
BuildTime: "", BuildTime: BuildTime,
GoVersion: runtime.Version(), GoVersion: runtime.Version(),
OS: runtime.GOOS, OS: runtime.GOOS,
Arch: runtime.GOARCH, Arch: runtime.GOARCH,

View File

@@ -3,16 +3,20 @@ import { ref, onMounted, computed, watch } from 'vue'
import { RouterView, useRouter, useRoute } from 'vue-router' import { RouterView, useRouter, useRoute } from 'vue-router'
import { import {
HomeOutline, DesktopOutline, SettingsOutline, HomeOutline, DesktopOutline, SettingsOutline,
PersonCircleOutline, LogOutOutline, LogoGithub, ServerOutline, CheckmarkCircleOutline, ArrowUpCircleOutline, CloseOutline PersonCircleOutline, LogOutOutline, LogoGithub, ServerOutline, CheckmarkCircleOutline, ArrowUpCircleOutline, CloseOutline,
SunnyOutline, MoonOutline, ContrastOutline
} from '@vicons/ionicons5' } from '@vicons/ionicons5'
import { getServerStatus, getVersionInfo, checkServerUpdate, applyServerUpdate, removeToken, getToken, type UpdateInfo } from './api' import { getServerStatus, getVersionInfo, checkServerUpdate, applyServerUpdate, removeToken, getToken, type UpdateInfo } from './api'
import { useToast } from './composables/useToast' import { useToast } from './composables/useToast'
import { useConfirm } from './composables/useConfirm' import { useConfirm } from './composables/useConfirm'
import { useTheme, type ThemeMode } from './composables/useTheme'
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const message = useToast() const message = useToast()
const dialog = useConfirm() const dialog = useConfirm()
const { themeMode, setTheme } = useTheme()
const showThemeMenu = ref(false)
const serverInfo = ref({ bind_addr: '', bind_port: 0 }) const serverInfo = ref({ bind_addr: '', bind_port: 0 })
const clientCount = ref(0) const clientCount = ref(0)
const version = ref('') const version = ref('')
@@ -91,8 +95,23 @@ const toggleUserMenu = () => {
showUserMenu.value = !showUserMenu.value showUserMenu.value = !showUserMenu.value
} }
const toggleThemeMenu = () => {
showThemeMenu.value = !showThemeMenu.value
}
const selectTheme = (mode: ThemeMode) => {
setTheme(mode)
showThemeMenu.value = false
}
const themeIcon = computed(() => {
if (themeMode.value === 'light') return SunnyOutline
if (themeMode.value === 'dark') return MoonOutline
return ContrastOutline
})
const openUpdateModal = () => { const openUpdateModal = () => {
if (updateInfo.value) { if (updateInfo.value && updateInfo.value.available) {
showUpdateModal.value = true showUpdateModal.value = true
} }
} }
@@ -154,6 +173,25 @@ const handleApplyServerUpdate = () => {
</router-link> </router-link>
</nav> </nav>
<div class="header-right"> <div class="header-right">
<!-- Theme Switcher -->
<div class="theme-menu" @click="toggleThemeMenu">
<component :is="themeIcon" class="theme-icon" />
<div v-if="showThemeMenu" class="theme-dropdown" @click.stop>
<button class="dropdown-item" :class="{ active: themeMode === 'light' }" @click="selectTheme('light')">
<SunnyOutline class="dropdown-icon" />
<span>浅色</span>
</button>
<button class="dropdown-item" :class="{ active: themeMode === 'dark' }" @click="selectTheme('dark')">
<MoonOutline class="dropdown-icon" />
<span>深色</span>
</button>
<button class="dropdown-item" :class="{ active: themeMode === 'auto' }" @click="selectTheme('auto')">
<ContrastOutline class="dropdown-icon" />
<span>自动</span>
</button>
</div>
</div>
<!-- User Menu -->
<div class="user-menu" @click="toggleUserMenu"> <div class="user-menu" @click="toggleUserMenu">
<PersonCircleOutline class="user-icon" /> <PersonCircleOutline class="user-icon" />
<div v-if="showUserMenu" class="user-dropdown" @click.stop> <div v-if="showUserMenu" class="user-dropdown" @click.stop>
@@ -177,7 +215,7 @@ const handleApplyServerUpdate = () => {
<span class="brand">GoTunnel</span> <span class="brand">GoTunnel</span>
<div v-if="version" class="version-info"> <div v-if="version" class="version-info">
<ServerOutline class="version-icon" /> <ServerOutline class="version-icon" />
<span class="version">v{{ version }}</span> <span class="version">{{ version.startsWith('v') ? version : 'v' + version }}</span>
<span v-if="updateInfo" class="update-status" :class="{ latest: !updateInfo.available, 'has-update': updateInfo.available }" @click="openUpdateModal"> <span v-if="updateInfo" class="update-status" :class="{ latest: !updateInfo.available, 'has-update': updateInfo.available }" @click="openUpdateModal">
<template v-if="updateInfo.available"> <template v-if="updateInfo.available">
<ArrowUpCircleOutline class="status-icon" /> <ArrowUpCircleOutline class="status-icon" />
@@ -252,16 +290,17 @@ const handleApplyServerUpdate = () => {
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%); background: var(--gradient-bg);
position: relative;
} }
/* Header */ /* Header - 毛玻璃效果 */
.app-header { .app-header {
height: 60px; height: 64px;
background: rgba(15, 12, 41, 0.9); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-bottom: 1px solid rgba(255, 255, 255, 0.1); border-bottom: 1px solid var(--color-border);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@@ -269,40 +308,62 @@ const handleApplyServerUpdate = () => {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 100; z-index: 100;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
/* 头部顶部高光线 */
.app-header::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 50%,
transparent 100%);
} }
.logo { .logo {
font-size: 20px; font-size: 20px;
font-weight: 700; font-weight: 700;
color: white; background: var(--gradient-accent);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
letter-spacing: -0.5px;
} }
/* Navigation */ /* Navigation */
.header-nav { .header-nav {
display: flex; display: flex;
gap: 4px; gap: 6px;
} }
.nav-item { .nav-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 8px;
padding: 8px 16px; padding: 10px 18px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
text-decoration: none; text-decoration: none;
border-radius: 8px; border-radius: 10px;
font-size: 14px; font-size: 14px;
transition: all 0.2s; font-weight: 500;
transition: all 0.2s ease;
position: relative;
} }
.nav-item:hover { .nav-item:hover {
color: white; color: var(--color-text-primary);
background: rgba(255, 255, 255, 0.1); background: var(--glass-bg-light);
} }
.nav-item.active { .nav-item.active {
color: white; color: white;
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%); background: var(--gradient-accent);
box-shadow: 0 4px 15px var(--color-accent-glow);
} }
.nav-icon { .nav-icon {
@@ -317,14 +378,68 @@ const handleApplyServerUpdate = () => {
} }
.user-icon { .user-icon {
width: 28px; width: 32px;
height: 28px; height: 32px;
color: rgba(255, 255, 255, 0.8); color: var(--color-text-secondary);
transition: color 0.2s; transition: all 0.2s ease;
padding: 4px;
border-radius: 8px;
} }
.user-icon:hover { .user-icon:hover {
color: var(--color-text-primary);
background: var(--glass-bg-light);
}
/* Theme Menu */
.header-right {
display: flex;
align-items: center;
gap: 8px;
}
.theme-menu {
position: relative;
cursor: pointer;
}
.theme-icon {
width: 28px;
height: 28px;
padding: 4px;
color: var(--color-text-secondary);
transition: all 0.2s ease;
border-radius: 8px;
}
.theme-icon:hover {
color: var(--color-text-primary);
background: var(--glass-bg-light);
}
.theme-dropdown {
position: absolute;
top: 100%;
right: 0;
margin-top: 8px;
background: var(--glass-bg);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border: 1px solid var(--color-border);
border-radius: 12px;
padding: 6px;
min-width: 130px;
box-shadow: var(--shadow-lg);
}
.dropdown-item.active {
background: var(--gradient-accent);
color: white; color: white;
box-shadow: 0 2px 8px var(--color-accent-glow);
}
.dropdown-item.active:hover {
filter: brightness(1.1);
} }
.user-dropdown { .user-dropdown {
@@ -332,32 +447,33 @@ const handleApplyServerUpdate = () => {
top: 100%; top: 100%;
right: 0; right: 0;
margin-top: 8px; margin-top: 8px;
background: rgba(30, 27, 75, 0.95); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
border: 1px solid rgba(255, 255, 255, 0.1); -webkit-backdrop-filter: var(--glass-blur);
border-radius: 8px; border: 1px solid var(--color-border);
padding: 4px; border-radius: 12px;
min-width: 140px; padding: 6px;
min-width: 150px;
box-shadow: var(--shadow-lg);
} }
.dropdown-item { .dropdown-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 10px;
width: 100%; width: 100%;
padding: 8px 12px; padding: 10px 14px;
background: none; background: none;
border: none; border: none;
color: rgba(255, 255, 255, 0.8); color: var(--color-text-primary);
font-size: 13px; font-size: 14px;
cursor: pointer; cursor: pointer;
border-radius: 6px; border-radius: 8px;
transition: all 0.2s; transition: all 0.2s ease;
} }
.dropdown-item:hover { .dropdown-item:hover {
background: rgba(255, 255, 255, 0.1); background: var(--glass-bg-hover);
color: white;
} }
.dropdown-icon { .dropdown-icon {
@@ -370,13 +486,13 @@ const handleApplyServerUpdate = () => {
overflow-y: auto; overflow-y: auto;
} }
/* Footer */ /* Footer - 毛玻璃效果 */
.app-footer { .app-footer {
height: 48px; height: 52px;
background: rgba(15, 12, 41, 0.9); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-top: 1px solid rgba(255, 255, 255, 0.1); border-top: 1px solid var(--color-border);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@@ -387,20 +503,24 @@ const handleApplyServerUpdate = () => {
.footer-left { .footer-left {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12px; gap: 16px;
} }
.brand { .brand {
font-weight: 600; font-weight: 600;
color: rgba(255, 255, 255, 0.9); background: var(--gradient-accent);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
} }
.version { .version {
padding: 2px 8px; padding: 4px 10px;
background: rgba(255, 255, 255, 0.1); background: var(--glass-bg-light);
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
border-radius: 4px; border-radius: 6px;
font-size: 12px; font-size: 12px;
border: 1px solid var(--color-border);
} }
.version-info { .version-info {
@@ -412,7 +532,7 @@ const handleApplyServerUpdate = () => {
.version-icon { .version-icon {
width: 14px; width: 14px;
height: 14px; height: 14px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-secondary);
} }
.update-status { .update-status {
@@ -420,24 +540,33 @@ const handleApplyServerUpdate = () => {
align-items: center; align-items: center;
gap: 4px; gap: 4px;
font-size: 12px; font-size: 12px;
padding: 2px 8px; padding: 4px 10px;
border-radius: 4px; border-radius: 6px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s ease;
border: 1px solid transparent;
} }
.update-status:hover { .update-status:hover {
opacity: 0.8; transform: translateY(-1px);
} }
.update-status.latest { .update-status.latest {
color: #34d399; color: var(--color-success);
background: rgba(52, 211, 153, 0.15); background: rgba(16, 185, 129, 0.1);
border-color: rgba(16, 185, 129, 0.2);
} }
.update-status.has-update { .update-status.has-update {
color: #fbbf24; color: var(--color-warning);
background: rgba(251, 191, 36, 0.15); background: rgba(245, 158, 11, 0.1);
border-color: rgba(245, 158, 11, 0.2);
animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
0%, 100% { box-shadow: 0 0 0 0 var(--color-warning-glow); }
50% { box-shadow: 0 0 8px 2px var(--color-warning-glow); }
} }
.status-icon { .status-icon {
@@ -449,13 +578,13 @@ const handleApplyServerUpdate = () => {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
text-decoration: none; text-decoration: none;
transition: color 0.2s; transition: color 0.15s;
} }
.footer-link:hover { .footer-link:hover {
color: white; color: var(--color-text-primary);
} }
.footer-icon { .footer-icon {
@@ -464,7 +593,7 @@ const handleApplyServerUpdate = () => {
} }
.copyright { .copyright {
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
} }
/* Responsive */ /* Responsive */
@@ -483,7 +612,7 @@ const handleApplyServerUpdate = () => {
} }
} }
/* Update Modal */ /* Update Modal - 毛玻璃效果 */
.modal-overlay { .modal-overlay {
position: fixed; position: fixed;
inset: 0; inset: 0;
@@ -496,9 +625,10 @@ const handleApplyServerUpdate = () => {
} }
.update-modal { .update-modal {
background: rgba(30, 27, 75, 0.95); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
border: 1px solid rgba(255, 255, 255, 0.12); -webkit-backdrop-filter: var(--glass-blur);
border: 1px solid var(--color-border);
border-radius: 16px; border-radius: 16px;
width: 90%; width: 90%;
max-width: 480px; max-width: 480px;
@@ -506,11 +636,12 @@ const handleApplyServerUpdate = () => {
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
box-shadow: var(--shadow-lg), var(--shadow-glow);
} }
.modal-header { .modal-header {
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1); border-bottom: 1px solid var(--color-border);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -520,21 +651,21 @@ const handleApplyServerUpdate = () => {
margin: 0; margin: 0;
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
} }
.close-btn { .close-btn {
background: none; background: none;
border: none; border: none;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
cursor: pointer; cursor: pointer;
padding: 4px; padding: 4px;
display: flex; display: flex;
transition: color 0.2s; transition: color 0.15s;
} }
.close-btn:hover { .close-btn:hover {
color: white; color: var(--color-text-primary);
} }
.modal-body { .modal-body {
@@ -557,18 +688,18 @@ const handleApplyServerUpdate = () => {
} }
.info-label { .info-label {
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
font-size: 13px; font-size: 13px;
} }
.info-value { .info-value {
color: white; color: var(--color-text-primary);
font-size: 13px; font-size: 13px;
font-weight: 500; font-weight: 500;
} }
.info-value.highlight { .info-value.highlight {
color: #34d399; color: var(--color-success);
} }
.release-note { .release-note {
@@ -578,7 +709,7 @@ const handleApplyServerUpdate = () => {
.note-label { .note-label {
display: block; display: block;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-secondary);
margin-bottom: 8px; margin-bottom: 8px;
} }
@@ -586,8 +717,8 @@ const handleApplyServerUpdate = () => {
margin: 0; margin: 0;
white-space: pre-wrap; white-space: pre-wrap;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
background: rgba(0, 0, 0, 0.2); background: var(--color-bg-elevated);
padding: 12px; padding: 12px;
border-radius: 8px; border-radius: 8px;
max-height: 200px; max-height: 200px;
@@ -596,30 +727,39 @@ const handleApplyServerUpdate = () => {
.modal-footer { .modal-footer {
padding: 16px 20px; padding: 16px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1); border-top: 1px solid var(--color-border);
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
gap: 8px; gap: 8px;
} }
.modal-btn { .modal-btn {
padding: 8px 16px; padding: 10px 18px;
border-radius: 8px; border-radius: 10px;
font-size: 13px; font-size: 14px;
font-weight: 500;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s ease;
background: rgba(255, 255, 255, 0.1); background: var(--glass-bg);
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid var(--color-border);
color: white; color: var(--color-text-primary);
} }
.modal-btn:hover:not(:disabled) { .modal-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2); background: var(--glass-bg-hover);
transform: translateY(-1px);
} }
.modal-btn.primary { .modal-btn.primary {
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%); background: var(--gradient-accent);
border: none; border: none;
color: white;
box-shadow: 0 4px 15px var(--color-accent-glow);
}
.modal-btn.primary:hover:not(:disabled) {
box-shadow: 0 6px 20px var(--color-accent-glow);
filter: brightness(1.1);
} }
.modal-btn:disabled { .modal-btn:disabled {

View File

@@ -48,12 +48,28 @@ const emit = defineEmits<{
.modal-container { .modal-container {
width: 100%; width: 100%;
background: rgba(30, 27, 75, 0.95); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-radius: 16px; border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12); border: 1px solid var(--color-border);
overflow: hidden; overflow: hidden;
box-shadow: var(--shadow-lg), var(--shadow-glow);
position: relative;
}
/* 顶部高光 */
.modal-container::before {
content: '';
position: absolute;
top: 0;
left: 15%;
right: 15%;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.15) 50%,
transparent 100%);
} }
.modal-header { .modal-header {
@@ -61,32 +77,32 @@ const emit = defineEmits<{
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08); border-bottom: 1px solid var(--color-border-light);
} }
.modal-header h3 { .modal-header h3 {
margin: 0; margin: 0;
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
} }
.close-btn { .close-btn {
background: rgba(255, 255, 255, 0.1); background: var(--glass-bg-light);
border: none; border: none;
border-radius: 6px; border-radius: 8px;
padding: 6px; padding: 6px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s ease;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.close-btn:hover { .close-btn:hover {
background: rgba(239, 68, 68, 0.2); background: rgba(239, 68, 68, 0.15);
color: #fca5a5; color: var(--color-error);
} }
.close-btn svg { .close-btn svg {
@@ -100,7 +116,7 @@ const emit = defineEmits<{
.modal-footer { .modal-footer {
padding: 16px 20px; padding: 16px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.08); border-top: 1px solid var(--color-border-light);
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
gap: 12px; gap: 12px;

View File

@@ -134,9 +134,9 @@ onUnmounted(() => {
<style scoped> <style scoped>
.inline-log-panel { .inline-log-panel {
background: rgba(0, 0, 0, 0.3); background: var(--glass-bg);
border-radius: 12px; border-radius: 12px;
border: 1px solid rgba(255, 255, 255, 0.08); border: 1px solid var(--color-border);
overflow: hidden; overflow: hidden;
} }
@@ -145,8 +145,8 @@ onUnmounted(() => {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 12px 16px; padding: 12px 16px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08); border-bottom: 1px solid var(--color-border);
background: rgba(255, 255, 255, 0.03); background: var(--glass-bg-light);
} }
.toolbar-left { .toolbar-left {
@@ -158,7 +158,7 @@ onUnmounted(() => {
.log-title { .log-title {
font-size: 13px; font-size: 13px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
} }
.streaming-badge { .streaming-badge {
@@ -166,8 +166,8 @@ onUnmounted(() => {
align-items: center; align-items: center;
gap: 6px; gap: 6px;
font-size: 11px; font-size: 11px;
color: #34d399; color: var(--color-success);
background: rgba(52, 211, 153, 0.15); background: rgba(16, 185, 129, 0.15);
padding: 2px 8px; padding: 2px 8px;
border-radius: 10px; border-radius: 10px;
} }
@@ -176,7 +176,7 @@ onUnmounted(() => {
width: 6px; width: 6px;
height: 6px; height: 6px;
border-radius: 50%; border-radius: 50%;
background: #34d399; background: var(--color-success);
animation: pulse 1.5s ease-in-out infinite; animation: pulse 1.5s ease-in-out infinite;
} }
@@ -192,11 +192,11 @@ onUnmounted(() => {
} }
.tool-btn { .tool-btn {
background: rgba(255, 255, 255, 0.1); background: var(--color-border);
border: none; border: none;
border-radius: 6px; border-radius: 6px;
padding: 6px; padding: 6px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s;
display: flex; display: flex;
@@ -205,8 +205,8 @@ onUnmounted(() => {
} }
.tool-btn:hover { .tool-btn:hover {
background: rgba(255, 255, 255, 0.2); background: var(--color-bg-elevated);
color: white; color: var(--color-text-primary);
} }
.tool-icon { .tool-icon {
@@ -219,14 +219,14 @@ onUnmounted(() => {
align-items: center; align-items: center;
gap: 6px; gap: 6px;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
cursor: pointer; cursor: pointer;
} }
.auto-scroll-toggle input { .auto-scroll-toggle input {
width: 14px; width: 14px;
height: 14px; height: 14px;
accent-color: #a78bfa; accent-color: var(--color-accent);
} }
.log-content { .log-content {
@@ -235,6 +235,7 @@ onUnmounted(() => {
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
font-size: 12px; font-size: 12px;
line-height: 1.6; line-height: 1.6;
background: var(--color-bg-elevated);
} }
.log-loading, .log-loading,
@@ -243,7 +244,7 @@ onUnmounted(() => {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
font-size: 13px; font-size: 13px;
} }
@@ -259,7 +260,7 @@ onUnmounted(() => {
} }
.log-time { .log-time {
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
flex-shrink: 0; flex-shrink: 0;
} }
@@ -269,12 +270,12 @@ onUnmounted(() => {
} }
.log-src { .log-src {
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
flex-shrink: 0; flex-shrink: 0;
} }
.log-msg { .log-msg {
color: rgba(255, 255, 255, 0.8); color: var(--color-text-secondary);
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
@@ -289,11 +290,11 @@ onUnmounted(() => {
} }
.log-content::-webkit-scrollbar-thumb { .log-content::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.2); background: var(--color-border);
border-radius: 3px; border-radius: 3px;
} }
.log-content::-webkit-scrollbar-thumb:hover { .log-content::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.3); background: var(--color-text-muted);
} }
</style> </style>

View File

@@ -0,0 +1,47 @@
import { ref, watch, onMounted } from 'vue'
export type ThemeMode = 'light' | 'dark' | 'auto'
const STORAGE_KEY = 'gotunnel-theme'
const themeMode = ref<ThemeMode>('auto')
function getSystemTheme(): 'light' | 'dark' {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
function applyTheme(mode: ThemeMode) {
const theme = mode === 'auto' ? getSystemTheme() : mode
document.documentElement.setAttribute('data-theme', theme)
}
export function useTheme() {
onMounted(() => {
const saved = localStorage.getItem(STORAGE_KEY) as ThemeMode | null
if (saved && ['light', 'dark', 'auto'].includes(saved)) {
themeMode.value = saved
}
applyTheme(themeMode.value)
// 监听系统主题变化
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (themeMode.value === 'auto') {
applyTheme('auto')
}
})
})
watch(themeMode, (mode) => {
localStorage.setItem(STORAGE_KEY, mode)
applyTheme(mode)
})
const setTheme = (mode: ThemeMode) => {
themeMode.value = mode
}
return {
themeMode,
setTheme
}
}

View File

@@ -1,5 +1,123 @@
@import "tailwindcss"; @import "tailwindcss";
/* ========================================
GoTunnel 毛玻璃设计系统
Glassmorphism Design System
======================================== */
/* 深色主题(默认) - 深邃渐变背景 */
:root,
[data-theme="dark"] {
/* 背景色 - 深色渐变基底 */
--color-bg-primary: #0a0e17;
--color-bg-secondary: #0d1220;
--color-bg-tertiary: #111827;
--color-bg-elevated: #1a2332;
/* 玻璃态背景 - 半透明 */
--glass-bg: rgba(17, 24, 39, 0.6);
--glass-bg-hover: rgba(26, 35, 50, 0.7);
--glass-bg-light: rgba(255, 255, 255, 0.03);
--glass-bg-card: rgba(17, 24, 39, 0.5);
/* 边框 - 高光描边 */
--color-border: rgba(255, 255, 255, 0.08);
--color-border-light: rgba(255, 255, 255, 0.05);
--color-border-glow: rgba(99, 179, 237, 0.3);
--glass-border: 1px solid rgba(255, 255, 255, 0.1);
--glass-border-hover: 1px solid rgba(255, 255, 255, 0.15);
/* 文字颜色 */
--color-text-primary: #f0f4f8;
--color-text-secondary: rgba(240, 244, 248, 0.7);
--color-text-muted: rgba(240, 244, 248, 0.45);
/* 强调色 - 霓虹高光 */
--color-accent: #3b82f6;
--color-accent-hover: #60a5fa;
--color-accent-glow: rgba(59, 130, 246, 0.4);
--color-success: #10b981;
--color-success-glow: rgba(16, 185, 129, 0.4);
--color-warning: #f59e0b;
--color-warning-glow: rgba(245, 158, 11, 0.4);
--color-error: #ef4444;
--color-error-glow: rgba(239, 68, 68, 0.4);
--color-info: #06b6d4;
--color-info-glow: rgba(6, 182, 212, 0.4);
/* 渐变背景 */
--gradient-bg: linear-gradient(135deg, #0a0e17 0%, #1a1f35 50%, #0d1220 100%);
--gradient-accent: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
--gradient-card: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
/* 模糊效果 */
--glass-blur: blur(20px);
--glass-blur-light: blur(12px);
/* 阴影 - 悬浮感 */
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
--shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
--shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
/* 浅色主题 - 柔和渐变背景 */
[data-theme="light"] {
/* 背景色 - 浅色渐变基底 */
--color-bg-primary: #f0f4f8;
--color-bg-secondary: #e8eef4;
--color-bg-tertiary: #ffffff;
--color-bg-elevated: #ffffff;
/* 玻璃态背景 - 半透明白 */
--glass-bg: rgba(255, 255, 255, 0.7);
--glass-bg-hover: rgba(255, 255, 255, 0.85);
--glass-bg-light: rgba(255, 255, 255, 0.5);
--glass-bg-card: rgba(255, 255, 255, 0.6);
/* 边框 - 柔和描边 */
--color-border: rgba(0, 0, 0, 0.08);
--color-border-light: rgba(0, 0, 0, 0.05);
--color-border-glow: rgba(59, 130, 246, 0.3);
--glass-border: 1px solid rgba(255, 255, 255, 0.8);
--glass-border-hover: 1px solid rgba(255, 255, 255, 0.95);
/* 文字颜色 */
--color-text-primary: #1a202c;
--color-text-secondary: rgba(26, 32, 44, 0.7);
--color-text-muted: rgba(26, 32, 44, 0.5);
/* 强调色 */
--color-accent: #3b82f6;
--color-accent-hover: #2563eb;
--color-accent-glow: rgba(59, 130, 246, 0.3);
--color-success: #10b981;
--color-success-glow: rgba(16, 185, 129, 0.3);
--color-warning: #f59e0b;
--color-warning-glow: rgba(245, 158, 11, 0.3);
--color-error: #ef4444;
--color-error-glow: rgba(239, 68, 68, 0.3);
--color-info: #06b6d4;
--color-info-glow: rgba(6, 182, 212, 0.3);
/* 渐变背景 */
--gradient-bg: linear-gradient(135deg, #e8eef4 0%, #f0f4f8 50%, #e0e8f0 100%);
--gradient-accent: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
--gradient-card: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%);
/* 模糊效果 */
--glass-blur: blur(20px);
--glass-blur-light: blur(12px);
/* 阴影 */
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
--shadow-glow: 0 0 20px rgba(59, 130, 246, 0.1);
--shadow-card: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -10,24 +128,205 @@ body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
background: var(--gradient-bg);
color: var(--color-text-primary);
min-height: 100vh;
} }
#app { #app {
min-height: 100vh; min-height: 100vh;
position: relative;
} }
/* Glass morphism utilities */ /* ========================================
玻璃态卡片组件
======================================== */
.glass-card { .glass-card {
background: rgba(255, 255, 255, 0.1); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-radius: 16px; border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.18); border: 1px solid var(--color-border);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); box-shadow: var(--shadow-card);
position: relative;
overflow: hidden;
transition: all 0.2s ease;
}
/* 卡片顶部高光 */
.glass-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 50%,
transparent 100%);
pointer-events: none;
} }
.glass-card-hover:hover { .glass-card-hover:hover {
background: rgba(255, 255, 255, 0.15); background: var(--glass-bg-hover);
box-shadow: 0 12px 48px 0 rgba(31, 38, 135, 0.45); border-color: rgba(255, 255, 255, 0.12);
transform: translateY(-4px); box-shadow: var(--shadow-lg), var(--shadow-glow);
transform: translateY(-2px);
}
/* ========================================
玻璃态按钮
======================================== */
.glass-btn {
background: var(--glass-bg);
backdrop-filter: var(--glass-blur-light);
-webkit-backdrop-filter: var(--glass-blur-light);
border: 1px solid var(--color-border);
border-radius: 10px;
padding: 10px 18px;
color: var(--color-text-primary);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
position: relative;
overflow: hidden;
}
.glass-btn:hover {
background: var(--glass-bg-hover);
border-color: rgba(255, 255, 255, 0.15);
box-shadow: var(--shadow-sm);
}
.glass-btn:active {
transform: scale(0.98);
}
.glass-btn.primary {
background: var(--gradient-accent);
border: none;
color: white;
box-shadow: 0 4px 15px var(--color-accent-glow);
}
.glass-btn.primary:hover {
box-shadow: 0 6px 20px var(--color-accent-glow);
filter: brightness(1.1);
}
.glass-btn.small {
padding: 6px 12px;
font-size: 12px;
border-radius: 8px;
}
/* ========================================
玻璃态输入框
======================================== */
.glass-input {
background: var(--glass-bg-light);
backdrop-filter: var(--glass-blur-light);
-webkit-backdrop-filter: var(--glass-blur-light);
border: 1px solid var(--color-border);
border-radius: 10px;
padding: 12px 16px;
color: var(--color-text-primary);
font-size: 15px;
width: 100%;
transition: all 0.2s ease;
outline: none;
}
.glass-input:focus {
border-color: var(--color-accent);
box-shadow: 0 0 0 3px var(--color-accent-glow);
}
.glass-input::placeholder {
color: var(--color-text-muted);
}
/* ========================================
动画背景粒子
======================================== */
.particles {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
z-index: 0;
}
.particle {
position: absolute;
border-radius: 50%;
opacity: 0.15;
filter: blur(60px);
animation: float 20s ease-in-out infinite;
}
.particle-1 {
width: 400px;
height: 400px;
background: var(--color-accent);
top: -100px;
right: -100px;
animation-delay: 0s;
}
.particle-2 {
width: 300px;
height: 300px;
background: #8b5cf6;
bottom: -50px;
left: -50px;
animation-delay: -5s;
}
.particle-3 {
width: 250px;
height: 250px;
background: var(--color-info);
top: 50%;
left: 50%;
animation-delay: -10s;
}
.particle-4 {
width: 200px;
height: 200px;
background: var(--color-success);
bottom: 20%;
right: 20%;
animation-delay: -15s;
}
.particle-5 {
width: 350px;
height: 350px;
background: #ec4899;
top: 30%;
left: 10%;
animation-delay: -7s;
}
@keyframes float {
0%, 100% {
transform: translate(0, 0) scale(1);
}
25% {
transform: translate(30px, -30px) scale(1.05);
}
50% {
transform: translate(-20px, 20px) scale(0.95);
}
75% {
transform: translate(-30px, -20px) scale(1.02);
}
} }

View File

@@ -1,10 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue' import { ref, onMounted, onUnmounted } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { import {
ArrowBackOutline, CreateOutline, TrashOutline, ArrowBackOutline, CreateOutline, TrashOutline,
PushOutline, AddOutline, StorefrontOutline, DocumentTextOutline, PushOutline, AddOutline, StorefrontOutline,
ExtensionPuzzleOutline, SettingsOutline, CloudDownloadOutline, RefreshOutline ExtensionPuzzleOutline, SettingsOutline, RefreshOutline
} from '@vicons/ionicons5' } from '@vicons/ionicons5'
import GlassModal from '../components/GlassModal.vue' import GlassModal from '../components/GlassModal.vue'
import GlassTag from '../components/GlassTag.vue' import GlassTag from '../components/GlassTag.vue'
@@ -15,10 +15,10 @@ import {
getClient, updateClient, deleteClient, pushConfigToClient, disconnectClient, restartClient, getClient, updateClient, deleteClient, pushConfigToClient, disconnectClient, restartClient,
getClientPluginConfig, updateClientPluginConfig, getClientPluginConfig, updateClientPluginConfig,
getStorePlugins, installStorePlugin, getRuleSchemas, startClientPlugin, restartClientPlugin, stopClientPlugin, deleteClientPlugin, getStorePlugins, installStorePlugin, getRuleSchemas, startClientPlugin, restartClientPlugin, stopClientPlugin, deleteClientPlugin,
checkClientUpdate, applyClientUpdate, getClientSystemStats, type UpdateInfo, type SystemStats checkClientUpdate, applyClientUpdate, getClientSystemStats, getVersionInfo,
type UpdateInfo, type SystemStats
} from '../api' } from '../api'
import type { ProxyRule, ClientPlugin, ConfigField, StorePluginInfo, RuleSchemasMap } from '../types' import type { ProxyRule, ClientPlugin, ConfigField, StorePluginInfo, RuleSchemasMap } from '../types'
import LogViewer from '../components/LogViewer.vue'
import InlineLogPanel from '../components/InlineLogPanel.vue' import InlineLogPanel from '../components/InlineLogPanel.vue'
const route = useRoute() const route = useRoute()
@@ -41,8 +41,8 @@ const clientVersion = ref('')
// 客户端更新相关 // 客户端更新相关
const clientUpdate = ref<UpdateInfo | null>(null) const clientUpdate = ref<UpdateInfo | null>(null)
const checkingUpdate = ref(false)
const updatingClient = ref(false) const updatingClient = ref(false)
const serverVersion = ref('')
// 系统状态相关 // 系统状态相关
const systemStats = ref<SystemStats | null>(null) const systemStats = ref<SystemStats | null>(null)
@@ -95,6 +95,61 @@ const getExtraFields = (type: string): ConfigField[] => {
return schema?.extra_fields || [] return schema?.extra_fields || []
} }
// 加载服务端版本
const loadServerVersion = async () => {
try {
const { data } = await getVersionInfo()
serverVersion.value = data.version || ''
} catch (e) {
console.error('Failed to load server version', e)
}
}
// 版本比较函数:返回 -1 (v1 < v2), 0 (v1 == v2), 1 (v1 > v2)
const compareVersions = (v1: string, v2: string): number => {
const normalize = (v: string) => v.replace(/^v/, '').split('.').map(n => parseInt(n, 10) || 0)
const parts1 = normalize(v1)
const parts2 = normalize(v2)
const len = Math.max(parts1.length, parts2.length)
for (let i = 0; i < len; i++) {
const p1 = parts1[i] || 0
const p2 = parts2[i] || 0
if (p1 < p2) return -1
if (p1 > p2) return 1
}
return 0
}
// 判断客户端是否需要更新
// 逻辑:如果客户端最新版>=服务端版本,则目标版本为服务端版本;否则为客户端最新版
const needsUpdate = (): boolean => {
if (!clientUpdate.value?.latest || !clientVersion.value) return false
const latestClientVer = clientUpdate.value.latest
const currentClientVer = clientVersion.value
const serverVer = serverVersion.value
// 确定目标版本
let targetVersion = latestClientVer
if (serverVer && compareVersions(latestClientVer, serverVer) >= 0) {
targetVersion = serverVer
}
// 比较当前客户端版本和目标版本
return compareVersions(currentClientVer, targetVersion) < 0
}
// 获取目标更新版本
const getTargetVersion = (): string => {
if (!clientUpdate.value?.latest) return ''
const latestClientVer = clientUpdate.value.latest
const serverVer = serverVersion.value
if (serverVer && compareVersions(latestClientVer, serverVer) >= 0) {
return serverVer
}
return latestClientVer
}
// Actions // Actions
const loadClient = async () => { const loadClient = async () => {
loading.value = true loading.value = true
@@ -157,31 +212,6 @@ const formatBytes = (bytes: number): string => {
} }
// 客户端更新 // 客户端更新
const handleCheckClientUpdate = async () => {
if (!online.value) {
message.warning('客户端离线,无法检查更新')
return
}
if (!clientOs.value || !clientArch.value) {
message.warning('无法获取客户端平台信息')
return
}
checkingUpdate.value = true
try {
const { data } = await checkClientUpdate(clientOs.value, clientArch.value)
clientUpdate.value = data
if (data.download_url) {
message.success('找到客户端更新: ' + data.latest)
} else {
message.info('已是最新版本或未找到对应平台的更新包')
}
} catch (e: any) {
message.error(e.response?.data || '检查更新失败')
} finally {
checkingUpdate.value = false
}
}
const handleApplyClientUpdate = () => { const handleApplyClientUpdate = () => {
if (!clientUpdate.value?.download_url) { if (!clientUpdate.value?.download_url) {
message.error('没有可用的下载链接') message.error('没有可用的下载链接')
@@ -463,13 +493,24 @@ const handleRestartClient = () => {
} }
// Lifecycle // Lifecycle
const pollTimer = ref<number | null>(null)
onMounted(() => { onMounted(() => {
loadRuleSchemas() loadRuleSchemas()
loadServerVersion()
loadClient() loadClient()
// 启动自动轮询,每 5 秒刷新一次
pollTimer.value = window.setInterval(() => {
loadClient()
}, 5000)
}) })
// Log Viewer onUnmounted(() => {
const showLogViewer = ref(false) if (pollTimer.value) {
clearInterval(pollTimer.value)
pollTimer.value = null
}
})
// Plugin Menu // Plugin Menu
const activePluginMenu = ref('') const activePluginMenu = ref('')
@@ -533,10 +574,6 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
<PushOutline class="btn-icon" /> <PushOutline class="btn-icon" />
<span>推送配置</span> <span>推送配置</span>
</button> </button>
<button class="glass-btn" @click="showLogViewer=true">
<DocumentTextOutline class="btn-icon" />
<span>日志</span>
</button>
<button class="glass-btn danger" @click="confirmDelete"> <button class="glass-btn danger" @click="confirmDelete">
<TrashOutline class="btn-icon" /> <TrashOutline class="btn-icon" />
<span>删除</span> <span>删除</span>
@@ -552,6 +589,10 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
<div class="glass-card"> <div class="glass-card">
<div class="card-header"> <div class="card-header">
<h3>客户端状态</h3> <h3>客户端状态</h3>
<!-- Heartbeat indicator -->
<div class="heartbeat-indicator" :class="{ online: online, offline: !online }">
<span class="heartbeat-dot"></span>
</div>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="stat-item"> <div class="stat-item">
@@ -566,8 +607,11 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
<span class="stat-label">客户端版本</span> <span class="stat-label">客户端版本</span>
<span class="stat-value"> <span class="stat-value">
{{ clientVersion || '-' }} {{ clientVersion || '-' }}
<span v-if="clientUpdate?.available" class="update-badge" @click="handleApplyClientUpdate"> <span v-if="needsUpdate()" class="update-badge" @click="handleApplyClientUpdate">
可更新 可更新 {{ getTargetVersion() }}
</span>
<span v-else-if="clientVersion" class="latest-badge">
最新版本
</span> </span>
</span> </span>
</div> </div>
@@ -608,11 +652,12 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
刷新 刷新
</button> </button>
</div> </div>
<div class="card-body"> <div class="card-body system-stats-body">
<div v-if="!systemStats" class="empty-hint"> <Transition name="fade-slide" mode="out-in">
{{ loadingStats ? '加载中...' : '点击刷新获取状态' }} <div v-if="!systemStats" class="empty-hint" key="empty">
</div> {{ loadingStats ? '加载中...' : '点击刷新获取状态' }}
<template v-else> </div>
<div v-else class="system-stats-content" key="stats">
<div class="system-stat-item"> <div class="system-stat-item">
<span class="system-stat-label">CPU</span> <span class="system-stat-label">CPU</span>
<div class="progress-bar"> <div class="progress-bar">
@@ -640,36 +685,11 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
<div class="system-stat-detail"> <div class="system-stat-detail">
{{ formatBytes(systemStats.disk_used) }} / {{ formatBytes(systemStats.disk_total) }} {{ formatBytes(systemStats.disk_used) }} / {{ formatBytes(systemStats.disk_total) }}
</div> </div>
</template> </div>
</Transition>
</div> </div>
</div> </div>
<!-- Update Card -->
<div class="glass-card">
<div class="card-header">
<h3>客户端更新</h3>
<button class="glass-btn tiny" :disabled="!online || checkingUpdate" @click="handleCheckClientUpdate">
<RefreshOutline class="btn-icon-sm" />
检查
</button>
</div>
<div class="card-body">
<div v-if="clientOs && clientArch" class="platform-info">
平台: {{ clientOs }}/{{ clientArch }}
</div>
<div v-if="!clientUpdate" class="empty-hint">点击检查更新</div>
<template v-else>
<div v-if="clientUpdate.download_url" class="update-available">
<p>发现新版本 {{ clientUpdate.latest }}</p>
<button class="glass-btn primary small" :disabled="updatingClient" @click="handleApplyClientUpdate">
<CloudDownloadOutline class="btn-icon-sm" />
更新
</button>
</div>
<div v-else class="empty-hint">已是最新版本</div>
</template>
</div>
</div>
</div> </div>
<!-- Right Column --> <!-- Right Column -->
@@ -877,40 +897,66 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
<button class="glass-btn primary" @click="confirmInstallPlugin">确认安装</button> <button class="glass-btn primary" @click="confirmInstallPlugin">确认安装</button>
</template> </template>
</GlassModal> </GlassModal>
<LogViewer :visible="showLogViewer" @close="showLogViewer = false" :client-id="clientId" />
</div> </div>
</template> </template>
<style scoped> <style scoped>
.client-page { .client-page {
min-height: calc(100vh - 108px); min-height: calc(100vh - 108px);
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%); background: transparent;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
padding: 32px; padding: 32px;
} }
/* Particles */
.particles { .particles {
position: absolute; position: absolute;
inset: 0; inset: 0;
overflow: hidden;
pointer-events: none; pointer-events: none;
z-index: 0;
} }
.particle { .particle {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05)); opacity: 0.15;
animation: float-particle 20s ease-in-out infinite; filter: blur(60px);
animation: float 20s ease-in-out infinite;
} }
.particle-1 { width: 250px; height: 250px; top: -80px; right: -50px; } .particle-1 {
.particle-2 { width: 180px; height: 180px; bottom: 10%; left: 5%; animation-delay: -7s; } width: 350px;
.particle-3 { width: 120px; height: 120px; top: 50%; right: 15%; animation-delay: -12s; } height: 350px;
background: var(--color-accent);
top: -80px;
right: -80px;
}
@keyframes float-particle { .particle-2 {
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; } width: 280px;
50% { transform: translate(-20px, -60px) scale(0.95); opacity: 0.4; } height: 280px;
background: #8b5cf6;
bottom: -40px;
left: -40px;
animation-delay: -5s;
}
.particle-3 {
width: 220px;
height: 220px;
background: var(--color-success);
top: 40%;
left: 30%;
animation-delay: -10s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); }
25% { transform: translate(30px, -30px) scale(1.05); }
50% { transform: translate(-20px, 20px) scale(0.95); }
75% { transform: translate(-30px, -20px) scale(1.02); }
} }
.client-content { .client-content {
@@ -937,26 +983,26 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
} }
.back-btn, .edit-btn { .back-btn, .edit-btn {
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-tertiary);
border: none; border: 1px solid var(--color-border);
border-radius: 8px; border-radius: 8px;
padding: 8px; padding: 8px;
color: rgba(255, 255, 255, 0.8); color: var(--color-text-secondary);
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.15s;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.back-btn:hover, .edit-btn:hover { .back-btn:hover, .edit-btn:hover {
background: rgba(255, 255, 255, 0.2); background: var(--color-bg-elevated);
color: white; color: var(--color-text-primary);
} }
.page-title { .page-title {
font-size: 24px; font-size: 24px;
font-weight: 700; font-weight: 700;
color: white; color: var(--color-text-primary);
margin: 0; margin: 0;
} }
@@ -965,13 +1011,13 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
border-radius: 20px; border-radius: 20px;
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
background: rgba(239, 68, 68, 0.2); background: rgba(244, 33, 46, 0.15);
color: #fca5a5; color: var(--color-error);
} }
.status-tag.online { .status-tag.online {
background: rgba(52, 211, 153, 0.2); background: rgba(0, 186, 124, 0.15);
color: #34d399; color: var(--color-success);
} }
.header-actions { .header-actions {
@@ -981,21 +1027,21 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
/* Glass Button */ /* Glass Button */
.glass-btn { .glass-btn {
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-tertiary);
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid var(--color-border);
border-radius: 8px; border-radius: 8px;
padding: 8px 16px; padding: 8px 16px;
color: white; color: var(--color-text-primary);
font-size: 13px; font-size: 13px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.15s;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
} }
.glass-btn:hover:not(:disabled) { .glass-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2); background: var(--color-bg-elevated);
} }
.glass-btn:disabled { .glass-btn:disabled {
@@ -1004,20 +1050,24 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
} }
.glass-btn.primary { .glass-btn.primary {
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%); background: var(--color-accent);
border: none; border: none;
} }
.glass-btn.primary:hover:not(:disabled) {
background: var(--color-accent-hover);
}
.glass-btn.danger { .glass-btn.danger {
background: rgba(239, 68, 68, 0.2); background: rgba(244, 33, 46, 0.15);
border-color: rgba(239, 68, 68, 0.3); border-color: rgba(244, 33, 46, 0.3);
color: #fca5a5; color: var(--color-error);
} }
.glass-btn.warning { .glass-btn.warning {
background: rgba(251, 191, 36, 0.2); background: rgba(247, 147, 26, 0.15);
border-color: rgba(251, 191, 36, 0.3); border-color: rgba(247, 147, 26, 0.3);
color: #fcd34d; color: var(--color-warning);
} }
.glass-btn.small { padding: 6px 12px; font-size: 12px; } .glass-btn.small { padding: 6px 12px; font-size: 12px; }
@@ -1029,6 +1079,7 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
display: grid; display: grid;
grid-template-columns: 300px 1fr; grid-template-columns: 300px 1fr;
gap: 24px; gap: 24px;
align-items: start;
} }
@media (max-width: 900px) { @media (max-width: 900px) {
@@ -1043,17 +1094,15 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
/* Glass Card */ /* Glass Card */
.glass-card { .glass-card {
background: rgba(255, 255, 255, 0.08); background: var(--color-bg-tertiary);
backdrop-filter: blur(20px); border-radius: 12px;
-webkit-backdrop-filter: blur(20px); border: 1px solid var(--color-border);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
overflow: hidden; overflow: hidden;
} }
.card-header { .card-header {
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08); border-bottom: 1px solid var(--color-border-light);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -1063,13 +1112,47 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
margin: 0; margin: 0;
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
}
/* Heartbeat Indicator */
.heartbeat-indicator {
position: relative;
}
.heartbeat-dot {
display: block;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--color-error);
}
.heartbeat-indicator.online .heartbeat-dot {
background: var(--color-success);
animation: heartbeat-pulse 2s ease-in-out infinite;
}
.heartbeat-indicator.offline .heartbeat-dot {
background: var(--color-error);
animation: none;
}
@keyframes heartbeat-pulse {
0%, 100% {
box-shadow: 0 0 0 0 rgba(0, 186, 124, 0.5);
transform: scale(1);
}
50% {
box-shadow: 0 0 0 6px rgba(0, 186, 124, 0);
transform: scale(1.1);
}
} }
.card-body { padding: 20px; } .card-body { padding: 20px; }
.card-actions { .card-actions {
padding: 16px 20px; padding: 16px 20px;
border-top: 1px solid rgba(255, 255, 255, 0.08); border-top: 1px solid var(--color-border-light);
display: flex; display: flex;
gap: 8px; gap: 8px;
} }
@@ -1079,18 +1162,18 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 8px 0; padding: 8px 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid var(--color-border-light);
} }
.stat-item:last-child { border-bottom: none; } .stat-item:last-child { border-bottom: none; }
.stat-label { .stat-label {
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
font-size: 13px; font-size: 13px;
} }
.stat-value { .stat-value {
color: white; color: var(--color-text-primary);
font-size: 13px; font-size: 13px;
} }
@@ -1104,15 +1187,25 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
margin-left: 8px; margin-left: 8px;
padding: 2px 8px; padding: 2px 8px;
font-size: 11px; font-size: 11px;
background: rgba(251, 191, 36, 0.2); background: rgba(247, 147, 26, 0.15);
color: #fbbf24; color: var(--color-warning);
border-radius: 10px; border-radius: 10px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.15s;
} }
.update-badge:hover { .update-badge:hover {
background: rgba(251, 191, 36, 0.3); background: rgba(247, 147, 26, 0.25);
}
.latest-badge {
display: inline-block;
margin-left: 8px;
padding: 2px 8px;
font-size: 11px;
background: rgba(0, 186, 124, 0.15);
color: var(--color-success);
border-radius: 10px;
} }
/* Mini Stats */ /* Mini Stats */
@@ -1129,23 +1222,23 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
display: block; display: block;
font-size: 28px; font-size: 28px;
font-weight: 700; font-weight: 700;
color: white; color: var(--color-text-primary);
} }
.mini-stat-label { .mini-stat-label {
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
} }
/* Update Card */ /* Update Card */
.platform-info { .platform-info {
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
margin-bottom: 8px; margin-bottom: 8px;
} }
.empty-hint { .empty-hint {
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
font-size: 13px; font-size: 13px;
text-align: center; text-align: center;
padding: 16px 0; padding: 16px 0;
@@ -1153,7 +1246,7 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.update-available p { .update-available p {
margin: 0 0 8px 0; margin: 0 0 8px 0;
color: #34d399; color: var(--color-success);
font-size: 13px; font-size: 13px;
} }
@@ -1161,7 +1254,7 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.empty-state { .empty-state {
text-align: center; text-align: center;
padding: 32px; padding: 32px;
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
} }
.rules-table { .rules-table {
@@ -1177,37 +1270,37 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
} }
.table-header { .table-header {
border-bottom: 1px solid rgba(255, 255, 255, 0.1); border-bottom: 1px solid var(--color-border);
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
} }
.table-row { .table-row {
border-bottom: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid var(--color-border-light);
color: rgba(255, 255, 255, 0.8); color: var(--color-text-secondary);
font-size: 13px; font-size: 13px;
} }
.rule-name { font-weight: 500; color: white; } .rule-name { font-weight: 500; color: var(--color-text-primary); }
.rule-mapping { font-family: monospace; font-size: 12px; } .rule-mapping { font-family: monospace; font-size: 12px; }
.rule-actions { display: flex; gap: 6px; justify-content: flex-end; } .rule-actions { display: flex; gap: 6px; justify-content: flex-end; }
/* Icon Button */ /* Icon Button */
.icon-btn { .icon-btn {
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-elevated);
border: none; border: none;
border-radius: 6px; border-radius: 6px;
padding: 4px 10px; padding: 4px 10px;
color: rgba(255, 255, 255, 0.8); color: var(--color-text-secondary);
font-size: 12px; font-size: 12px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.15s;
} }
.icon-btn:hover:not(:disabled) { .icon-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2); background: var(--color-border);
color: white; color: var(--color-text-primary);
} }
.icon-btn:disabled { .icon-btn:disabled {
@@ -1216,19 +1309,19 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
} }
.icon-btn.danger { .icon-btn.danger {
color: #fca5a5; color: var(--color-error);
} }
.icon-btn.danger:hover:not(:disabled) { .icon-btn.danger:hover:not(:disabled) {
background: rgba(239, 68, 68, 0.2); background: rgba(244, 33, 46, 0.15);
} }
.icon-btn.success { .icon-btn.success {
color: #34d399; color: var(--color-success);
} }
.icon-btn.success:hover:not(:disabled) { .icon-btn.success:hover:not(:disabled) {
background: rgba(52, 211, 153, 0.2); background: rgba(0, 186, 124, 0.15);
} }
/* Plugins List */ /* Plugins List */
@@ -1239,8 +1332,8 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
} }
.plugin-item { .plugin-item {
background: rgba(255, 255, 255, 0.05); background: var(--color-bg-elevated);
border-radius: 12px; border-radius: 10px;
padding: 16px; padding: 16px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -1255,13 +1348,13 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.plugin-name { .plugin-name {
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
font-size: 14px; font-size: 14px;
} }
.plugin-version { .plugin-version {
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
} }
.plugin-meta { .plugin-meta {
@@ -1269,7 +1362,7 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
align-items: center; align-items: center;
gap: 12px; gap: 12px;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
} }
.plugin-actions { .plugin-actions {
@@ -1280,10 +1373,10 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
/* Store Plugin Card */ /* Store Plugin Card */
.store-plugin-card { .store-plugin-card {
background: rgba(255, 255, 255, 0.05); background: var(--color-bg-elevated);
border-radius: 12px; border-radius: 10px;
padding: 16px; padding: 16px;
border: 1px solid rgba(255, 255, 255, 0.08); border: 1px solid var(--color-border-light);
} }
.store-plugin-header { .store-plugin-header {
@@ -1295,12 +1388,12 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.store-plugin-name { .store-plugin-name {
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
font-size: 14px; font-size: 14px;
} }
.store-plugin-desc { .store-plugin-desc {
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
font-size: 12px; font-size: 12px;
margin: 0 0 12px 0; margin: 0 0 12px 0;
line-height: 1.5; line-height: 1.5;
@@ -1325,29 +1418,29 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.form-label { .form-label {
display: block; display: block;
font-size: 13px; font-size: 13px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
margin-bottom: 6px; margin-bottom: 6px;
} }
.form-input { .form-input {
width: 100%; width: 100%;
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-elevated);
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid var(--color-border);
border-radius: 8px; border-radius: 8px;
padding: 10px 12px; padding: 10px 12px;
color: white; color: var(--color-text-primary);
font-size: 14px; font-size: 14px;
outline: none; outline: none;
transition: border-color 0.2s; transition: border-color 0.15s;
box-sizing: border-box; box-sizing: border-box;
} }
.form-input:focus { .form-input:focus {
border-color: rgba(167, 139, 250, 0.5); border-color: var(--color-accent);
} }
.form-input::placeholder { .form-input::placeholder {
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
} }
.form-input:disabled { .form-input:disabled {
@@ -1357,26 +1450,26 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.form-select { .form-select {
width: 100%; width: 100%;
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-elevated);
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid var(--color-border);
border-radius: 8px; border-radius: 8px;
padding: 10px 12px; padding: 10px 12px;
color: white; color: var(--color-text-primary);
font-size: 14px; font-size: 14px;
outline: none; outline: none;
cursor: pointer; cursor: pointer;
} }
.form-select option { .form-select option {
background: #1e1b4b; background: var(--color-bg-tertiary);
color: white; color: var(--color-text-primary);
} }
.form-toggle { .form-toggle {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
font-size: 13px; font-size: 13px;
cursor: pointer; cursor: pointer;
} }
@@ -1384,13 +1477,13 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.form-toggle input[type="checkbox"] { .form-toggle input[type="checkbox"] {
width: 18px; width: 18px;
height: 18px; height: 18px;
accent-color: #a78bfa; accent-color: var(--color-accent);
} }
.loading-state { .loading-state {
text-align: center; text-align: center;
padding: 32px; padding: 32px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
} }
/* Dropdown Menu */ /* Dropdown Menu */
@@ -1403,9 +1496,8 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
top: 100%; top: 100%;
right: 0; right: 0;
margin-top: 4px; margin-top: 4px;
background: rgba(30, 27, 75, 0.95); background: var(--color-bg-tertiary);
backdrop-filter: blur(20px); border: 1px solid var(--color-border);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 8px; border-radius: 8px;
padding: 4px; padding: 4px;
min-width: 100px; min-width: 100px;
@@ -1418,17 +1510,17 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
padding: 8px 12px; padding: 8px 12px;
background: none; background: none;
border: none; border: none;
color: rgba(255, 255, 255, 0.8); color: var(--color-text-secondary);
font-size: 13px; font-size: 13px;
text-align: left; text-align: left;
cursor: pointer; cursor: pointer;
border-radius: 4px; border-radius: 4px;
transition: all 0.2s; transition: all 0.15s;
} }
.dropdown-menu button:hover:not(:disabled) { .dropdown-menu button:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-elevated);
color: white; color: var(--color-text-primary);
} }
.dropdown-menu button:disabled { .dropdown-menu button:disabled {
@@ -1437,11 +1529,11 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
} }
.dropdown-menu button.danger { .dropdown-menu button.danger {
color: #fca5a5; color: var(--color-error);
} }
.dropdown-menu button.danger:hover:not(:disabled) { .dropdown-menu button.danger:hover:not(:disabled) {
background: rgba(239, 68, 68, 0.2); background: rgba(244, 33, 46, 0.15);
} }
/* Icon styles */ /* Icon styles */
@@ -1463,7 +1555,7 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.plugin-icon { .plugin-icon {
width: 18px; width: 18px;
height: 18px; height: 18px;
color: #a78bfa; color: var(--color-accent);
} }
.settings-icon { .settings-icon {
@@ -1471,6 +1563,31 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
height: 16px; height: 16px;
} }
/* System Stats Transition */
.system-stats-body {
overflow: hidden;
}
.system-stats-content {
display: flex;
flex-direction: column;
}
.fade-slide-enter-active,
.fade-slide-leave-active {
transition: all 0.3s ease;
}
.fade-slide-enter-from {
opacity: 0;
transform: translateY(-10px);
}
.fade-slide-leave-to {
opacity: 0;
transform: translateY(10px);
}
/* System Stats */ /* System Stats */
.system-stat-item { .system-stat-item {
display: flex; display: flex;
@@ -1482,20 +1599,20 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
.system-stat-label { .system-stat-label {
width: 40px; width: 40px;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
} }
.progress-bar { .progress-bar {
flex: 1; flex: 1;
height: 8px; height: 8px;
background: rgba(255, 255, 255, 0.1); background: var(--color-border);
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
} }
.progress-fill { .progress-fill {
height: 100%; height: 100%;
background: linear-gradient(90deg, #60a5fa, #a78bfa); background: var(--color-accent);
border-radius: 4px; border-radius: 4px;
transition: width 0.3s ease; transition: width 0.3s ease;
} }
@@ -1504,13 +1621,13 @@ const handleDeletePlugin = (plugin: ClientPlugin) => {
width: 50px; width: 50px;
text-align: right; text-align: right;
font-size: 12px; font-size: 12px;
color: white; color: var(--color-text-primary);
font-family: monospace; font-family: monospace;
} }
.system-stat-detail { .system-stat-detail {
font-size: 11px; font-size: 11px;
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
text-align: right; text-align: right;
margin-bottom: 12px; margin-bottom: 12px;
margin-top: -4px; margin-top: -4px;

View File

@@ -92,6 +92,10 @@ onMounted(loadClients)
<div class="client-tag" :class="client.online ? 'online' : 'offline'"> <div class="client-tag" :class="client.online ? 'online' : 'offline'">
{{ client.online ? '在线' : '离线' }} {{ client.online ? '在线' : '离线' }}
</div> </div>
<!-- Heartbeat indicator -->
<div class="heartbeat-indicator" :class="{ online: client.online, offline: !client.online }">
<span class="heartbeat-dot"></span>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -102,33 +106,60 @@ onMounted(loadClients)
<style scoped> <style scoped>
.clients-page { .clients-page {
min-height: calc(100vh - 108px); min-height: calc(100vh - 116px);
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%);
position: relative; position: relative;
overflow: hidden; overflow: hidden;
padding: 32px; padding: 32px;
} }
/* 动画背景粒子 */
.particles { .particles {
position: absolute; position: absolute;
inset: 0; inset: 0;
overflow: hidden;
pointer-events: none; pointer-events: none;
z-index: 0;
} }
.particle { .particle {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05)); opacity: 0.15;
animation: float-particle 20s ease-in-out infinite; filter: blur(60px);
animation: float 20s ease-in-out infinite;
} }
.particle-1 { width: 250px; height: 250px; top: -80px; right: -50px; } .particle-1 {
.particle-2 { width: 180px; height: 180px; bottom: 10%; left: 5%; animation-delay: -7s; } width: 350px;
.particle-3 { width: 120px; height: 120px; top: 50%; right: 15%; animation-delay: -12s; } height: 350px;
background: var(--color-accent);
top: -80px;
right: -80px;
}
@keyframes float-particle { .particle-2 {
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; } width: 280px;
50% { transform: translate(-20px, -60px) scale(0.95); opacity: 0.4; } height: 280px;
background: #8b5cf6;
bottom: -40px;
left: -40px;
animation-delay: -5s;
}
.particle-3 {
width: 220px;
height: 220px;
background: var(--color-success);
top: 40%;
left: 30%;
animation-delay: -10s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); }
25% { transform: translate(30px, -30px) scale(1.05); }
50% { transform: translate(-20px, 20px) scale(0.95); }
75% { transform: translate(-30px, -20px) scale(1.02); }
} }
.clients-content { .clients-content {
@@ -142,11 +173,11 @@ onMounted(loadClients)
.page-title { .page-title {
font-size: 28px; font-size: 28px;
font-weight: 700; font-weight: 700;
color: white; color: var(--color-text-primary);
margin: 0 0 8px 0; margin: 0 0 8px 0;
} }
.page-subtitle { .page-subtitle {
color: rgba(255,255,255,0.6); color: var(--color-text-secondary);
margin: 0; margin: 0;
font-size: 14px; font-size: 14px;
} }
@@ -160,38 +191,76 @@ onMounted(loadClients)
} }
.stat-card { .stat-card {
background: rgba(255,255,255,0.08); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-radius: 16px; border-radius: 16px;
border: 1px solid rgba(255,255,255,0.12); border: 1px solid var(--color-border);
padding: 20px; padding: 20px;
text-align: center; text-align: center;
box-shadow: var(--shadow-card);
transition: all 0.2s ease;
position: relative;
}
.stat-card::before {
content: '';
position: absolute;
top: 0;
left: 20%;
right: 20%;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 50%,
transparent 100%);
}
.stat-card:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-lg), var(--shadow-glow);
} }
.stat-value { .stat-value {
display: block; display: block;
font-size: 32px; font-size: 32px;
font-weight: 700; font-weight: 700;
color: white; color: var(--color-text-primary);
} }
.stat-value.online { color: #34d399; } .stat-value.online { color: var(--color-success); }
.stat-value.offline { color: rgba(255,255,255,0.5); } .stat-value.offline { color: var(--color-text-muted); }
.stat-label { .stat-label {
font-size: 13px; font-size: 13px;
color: rgba(255,255,255,0.6); color: var(--color-text-secondary);
} }
/* Glass Card */ /* Glass Card */
.glass-card { .glass-card {
background: rgba(255,255,255,0.08); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-radius: 16px; border-radius: 16px;
border: 1px solid rgba(255,255,255,0.12); border: 1px solid var(--color-border);
box-shadow: var(--shadow-card);
position: relative;
}
.glass-card::before {
content: '';
position: absolute;
top: 0;
left: 10%;
right: 10%;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 50%,
transparent 100%);
} }
.card-header { .card-header {
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid rgba(255,255,255,0.08); border-bottom: 1px solid var(--color-border-light);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -200,18 +269,18 @@ onMounted(loadClients)
margin: 0; margin: 0;
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
} }
.card-body { padding: 20px; } .card-body { padding: 20px; }
.loading-state, .empty-state { .loading-state, .empty-state {
text-align: center; text-align: center;
padding: 48px; padding: 48px;
color: rgba(255,255,255,0.5); color: var(--color-text-muted);
} }
.empty-hint { .empty-hint {
font-size: 13px; font-size: 13px;
color: rgba(255,255,255,0.3); color: var(--color-text-muted);
margin-top: 8px; margin-top: 8px;
} }
@@ -231,17 +300,18 @@ onMounted(loadClients)
} }
.client-card { .client-card {
background: rgba(255,255,255,0.05); background: var(--glass-bg-light);
border-radius: 12px; border-radius: 12px;
padding: 16px; padding: 18px;
border: 1px solid rgba(255,255,255,0.08); border: 1px solid var(--color-border);
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s ease;
position: relative; position: relative;
} }
.client-card:hover { .client-card:hover {
background: rgba(255,255,255,0.1); background: var(--glass-bg-hover);
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: var(--shadow-md);
} }
.client-header { .client-header {
@@ -255,23 +325,23 @@ onMounted(loadClients)
width: 10px; width: 10px;
height: 10px; height: 10px;
border-radius: 50%; border-radius: 50%;
background: rgba(255,255,255,0.3); background: var(--color-text-muted);
} }
.client-status.online { .client-status.online {
background: #34d399; background: var(--color-success);
box-shadow: 0 0 8px rgba(52,211,153,0.6); box-shadow: 0 0 10px var(--color-success-glow);
} }
.client-name { .client-name {
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
margin: 0; margin: 0;
} }
.client-id { .client-id {
font-size: 12px; font-size: 12px;
color: rgba(255,255,255,0.4); color: var(--color-text-muted);
margin: 0 0 8px 0; margin: 0 0 8px 0;
font-family: monospace; font-family: monospace;
} }
@@ -281,37 +351,80 @@ onMounted(loadClients)
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
font-size: 13px; font-size: 13px;
color: rgba(255,255,255,0.6); color: var(--color-text-secondary);
margin-bottom: 12px; margin-bottom: 12px;
} }
.client-tag { .client-tag {
display: inline-block; display: inline-block;
padding: 4px 10px; padding: 4px 10px;
border-radius: 6px; border-radius: 8px;
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
} }
.client-tag.online { .client-tag.online {
background: rgba(52,211,153,0.2); background: rgba(16, 185, 129, 0.15);
color: #34d399; color: var(--color-success);
border: 1px solid rgba(16, 185, 129, 0.2);
} }
.client-tag.offline { .client-tag.offline {
background: rgba(255,255,255,0.1); background: var(--glass-bg-light);
color: rgba(255,255,255,0.5); color: var(--color-text-muted);
border: 1px solid var(--color-border);
} }
/* Button */ /* Button */
.glass-btn { .glass-btn {
background: rgba(255,255,255,0.1); background: var(--glass-bg);
border: 1px solid rgba(255,255,255,0.15); backdrop-filter: var(--glass-blur-light);
border-radius: 8px; border: 1px solid var(--color-border);
border-radius: 10px;
padding: 8px 16px; padding: 8px 16px;
color: white; color: var(--color-text-primary);
font-size: 13px; font-size: 13px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s ease;
}
.glass-btn:hover {
background: var(--glass-bg-hover);
transform: translateY(-1px);
} }
.glass-btn:hover { background: rgba(255,255,255,0.2); }
.glass-btn.small { padding: 6px 12px; font-size: 12px; } .glass-btn.small { padding: 6px 12px; font-size: 12px; }
/* Heartbeat Indicator */
.heartbeat-indicator {
position: absolute;
top: 18px;
right: 18px;
}
.heartbeat-dot {
display: block;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--color-error);
}
.heartbeat-indicator.online .heartbeat-dot {
background: var(--color-success);
animation: heartbeat-pulse 2s ease-in-out infinite;
box-shadow: 0 0 8px var(--color-success-glow);
}
.heartbeat-indicator.offline .heartbeat-dot {
background: var(--color-error);
animation: none;
}
@keyframes heartbeat-pulse {
0%, 100% {
box-shadow: 0 0 0 0 var(--color-success-glow);
transform: scale(1);
}
50% {
box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
transform: scale(1.1);
}
}
</style> </style>

View File

@@ -123,83 +123,84 @@ onMounted(() => {
<div class="dashboard-content"> <div class="dashboard-content">
<!-- Header --> <!-- Header -->
<div class="dashboard-header"> <div class="dashboard-header">
<h1 class="text-3xl font-bold text-white mb-2">仪表盘</h1> <h1 class="dashboard-title">仪表盘</h1>
<p class="text-white/70">监控隧道连接和流量状态</p> <p class="dashboard-subtitle">监控隧道连接和流量状态</p>
</div> </div>
<!-- Stats Grid --> <!-- Stats Grid -->
<div class="stats-grid"> <div class="stats-grid">
<!-- Outbound Traffic --> <!-- 24H Traffic Combined -->
<div class="stat-card glass-stat"> <div class="stat-card glass-stat">
<div class="stat-icon outbound"> <div class="stat-icon-large traffic-24h">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="icon-lg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 11l5-5m0 0l5 5m-5-5v12" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" />
</svg> </svg>
</div> </div>
<div class="stat-content"> <div class="stat-details">
<span class="stat-label">24h出站</span> <div class="stat-row">
<span class="stat-value">{{ formatted24hOutbound.value }}</span> <span class="stat-title">24H 出站</span>
<span class="stat-unit">{{ formatted24hOutbound.unit }}</span> <div class="stat-data">
<span class="stat-number">{{ formatted24hOutbound.value }}</span>
<span class="stat-unit">{{ formatted24hOutbound.unit }}</span>
</div>
</div>
<div class="stat-row">
<span class="stat-title">24H 入站</span>
<div class="stat-data">
<span class="stat-number">{{ formatted24hInbound.value }}</span>
<span class="stat-unit">{{ formatted24hInbound.unit }}</span>
</div>
</div>
</div> </div>
</div> </div>
<!-- Inbound Traffic --> <!-- Total Traffic Combined -->
<div class="stat-card glass-stat"> <div class="stat-card glass-stat">
<div class="stat-icon inbound"> <div class="stat-icon-large traffic-total">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="icon-lg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 13l-5 5m0 0l-5-5m5 5V6" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
</svg> </svg>
</div> </div>
<div class="stat-content"> <div class="stat-details">
<span class="stat-label">24h入站</span> <div class="stat-row">
<span class="stat-value">{{ formatted24hInbound.value }}</span> <span class="stat-title">总出站</span>
<span class="stat-unit">{{ formatted24hInbound.unit }}</span> <div class="stat-data">
</div> <span class="stat-number">{{ formattedTotalOutbound.value }}</span>
</div> <span class="stat-unit">{{ formattedTotalOutbound.unit }}</span>
</div>
<!-- Total Outbound Traffic --> </div>
<div class="stat-card glass-stat"> <div class="stat-row">
<div class="stat-icon total-out"> <span class="stat-title">总入站</span>
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <div class="stat-data">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 11l5-5m0 0l5 5m-5-5v12" /> <span class="stat-number">{{ formattedTotalInbound.value }}</span>
</svg> <span class="stat-unit">{{ formattedTotalInbound.unit }}</span>
</div> </div>
<div class="stat-content"> </div>
<span class="stat-label">总出站</span>
<span class="stat-value">{{ formattedTotalOutbound.value }}</span>
<span class="stat-unit">{{ formattedTotalOutbound.unit }}</span>
</div>
</div>
<!-- Total Inbound Traffic -->
<div class="stat-card glass-stat">
<div class="stat-icon total-in">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 13l-5 5m0 0l-5-5m5 5V6" />
</svg>
</div>
<div class="stat-content">
<span class="stat-label">总入站</span>
<span class="stat-value">{{ formattedTotalInbound.value }}</span>
<span class="stat-unit">{{ formattedTotalInbound.unit }}</span>
</div> </div>
</div> </div>
<!-- Client Count --> <!-- Client Count -->
<div class="stat-card glass-stat"> <div class="stat-card glass-stat">
<div class="stat-icon clients"> <div class="stat-icon-large clients">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="icon-lg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />
</svg> </svg>
</div> </div>
<div class="stat-content"> <div class="stat-details">
<span class="stat-label">客户端</span> <div class="stat-row">
<div class="client-count"> <span class="stat-title">在线客户端</span>
<span class="stat-value online">{{ onlineClients }}</span> <div class="stat-data">
<span class="stat-separator">/</span> <span class="stat-number online">{{ onlineClients }}</span>
<span class="stat-value total">{{ clients.length }}</span> <span class="stat-unit"></span>
</div>
</div>
<div class="stat-row">
<span class="stat-title">总客户端</span>
<div class="stat-data">
<span class="stat-number">{{ clients.length }}</span>
<span class="stat-unit"></span>
</div>
</div> </div>
<span class="stat-unit">在线 / 总数</span>
</div> </div>
<div class="online-indicator" :class="{ active: onlineClients > 0 }"> <div class="online-indicator" :class="{ active: onlineClients > 0 }">
<span class="pulse"></span> <span class="pulse"></span>
@@ -208,15 +209,19 @@ onMounted(() => {
<!-- Rules Count --> <!-- Rules Count -->
<div class="stat-card glass-stat"> <div class="stat-card glass-stat">
<div class="stat-icon rules"> <div class="stat-icon-large rules">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg xmlns="http://www.w3.org/2000/svg" class="icon-lg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16" /> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16" />
</svg> </svg>
</div> </div>
<div class="stat-content"> <div class="stat-details">
<span class="stat-label">代理规则</span> <div class="stat-row single">
<span class="stat-value">{{ totalRules }}</span> <span class="stat-title">代理规则</span>
<span class="stat-unit">条规则</span> <div class="stat-data">
<span class="stat-number">{{ totalRules }}</span>
<span class="stat-unit"></span>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -250,75 +255,80 @@ onMounted(() => {
</template> </template>
<style scoped> <style scoped>
/* Container with gradient background */ /* Container */
.dashboard-container { .dashboard-container {
min-height: calc(100vh - 108px); min-height: calc(100vh - 116px);
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%);
position: relative; position: relative;
overflow: hidden; overflow: hidden;
padding: 32px; padding: 32px;
} }
/* Floating particles */ /* 动画背景粒子 */
.particles { .particles {
position: absolute; position: absolute;
inset: 0; inset: 0;
pointer-events: none;
overflow: hidden; overflow: hidden;
pointer-events: none;
z-index: 0;
} }
.particle { .particle {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05)); opacity: 0.15;
animation: float-particle 20s ease-in-out infinite; filter: blur(60px);
animation: float 20s ease-in-out infinite;
} }
.particle-1 { .particle-1 {
width: 300px; width: 400px;
height: 300px; height: 400px;
background: var(--color-accent);
top: -100px; top: -100px;
right: -50px; right: -100px;
animation-delay: 0s;
} }
.particle-2 { .particle-2 {
width: 200px; width: 300px;
height: 200px; height: 300px;
bottom: 10%; background: #8b5cf6;
left: 5%; bottom: -50px;
left: -50px;
animation-delay: -5s; animation-delay: -5s;
} }
.particle-3 { .particle-3 {
width: 150px; width: 250px;
height: 150px; height: 250px;
top: 40%; background: var(--color-info);
right: 20%; top: 50%;
left: 50%;
animation-delay: -10s; animation-delay: -10s;
} }
.particle-4 { .particle-4 {
width: 100px; width: 200px;
height: 100px; height: 200px;
top: 20%; background: var(--color-success);
left: 30%; bottom: 20%;
right: 20%;
animation-delay: -15s; animation-delay: -15s;
} }
.particle-5 { .particle-5 {
width: 80px; width: 350px;
height: 80px; height: 350px;
bottom: 30%; background: #ec4899;
right: 10%; top: 30%;
animation-delay: -8s; left: 10%;
animation-delay: -7s;
} }
@keyframes float-particle { @keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; } 0%, 100% { transform: translate(0, 0) scale(1); }
25% { transform: translate(30px, -40px) scale(1.1); opacity: 0.5; } 25% { transform: translate(30px, -30px) scale(1.05); }
50% { transform: translate(-20px, -80px) scale(0.9); opacity: 0.4; } 50% { transform: translate(-20px, 20px) scale(0.95); }
75% { transform: translate(-40px, -40px) scale(1.05); opacity: 0.35; } 75% { transform: translate(-30px, -20px) scale(1.02); }
} }
/* Main content */ /* Main content */
@@ -333,10 +343,23 @@ onMounted(() => {
margin-bottom: 32px; margin-bottom: 32px;
} }
.dashboard-title {
font-size: 28px;
font-weight: 700;
color: var(--color-text-primary);
margin: 0 0 8px 0;
}
.dashboard-subtitle {
color: var(--color-text-secondary);
margin: 0;
font-size: 14px;
}
/* Stats Grid */ /* Stats Grid */
.stats-grid { .stats-grid {
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(4, 1fr);
gap: 20px; gap: 20px;
margin-bottom: 32px; margin-bottom: 32px;
} }
@@ -353,137 +376,119 @@ onMounted(() => {
} }
} }
/* Glass stat card */ /* Glass stat card - 毛玻璃效果 */
.glass-stat { .glass-stat {
background: rgba(255, 255, 255, 0.08); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-radius: 20px; border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12); border: 1px solid var(--color-border);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2); padding: 20px;
padding: 24px;
display: flex; display: flex;
align-items: flex-start; align-items: center;
gap: 16px; gap: 16px;
position: relative; position: relative;
transition: all 0.25s ease; transition: all 0.2s ease;
box-shadow: var(--shadow-card);
}
/* 卡片顶部高光 */
.glass-stat::before {
content: '';
position: absolute;
top: 0;
left: 10%;
right: 10%;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 50%,
transparent 100%);
} }
.glass-stat:hover { .glass-stat:hover {
background: rgba(255, 255, 255, 0.12); background: var(--glass-bg-hover);
transform: translateY(-4px); transform: translateY(-2px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); box-shadow: var(--shadow-lg), var(--shadow-glow);
} }
/* Stat icon */ /* Large Stat icon */
.stat-icon { .stat-icon-large {
width: 48px; width: 64px;
height: 48px; height: 64px;
border-radius: 12px; border-radius: 14px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-shrink: 0; flex-shrink: 0;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
} }
.stat-icon.outbound { .stat-icon-large.traffic-24h {
background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); background: var(--gradient-accent);
box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
} }
.stat-icon.inbound { .stat-icon-large.traffic-total {
background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%); background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
} }
.stat-icon.clients { .stat-icon-large.clients {
background: linear-gradient(135deg, #34d399 0%, #10b981 100%); background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
} }
.stat-icon.rules { .stat-icon-large.rules {
background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
} }
.stat-icon.total-out { .icon-lg {
background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%); width: 32px;
box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4); height: 32px;
}
.stat-icon.total-in {
background: linear-gradient(135deg, #c084fc 0%, #9333ea 100%);
box-shadow: 0 4px 16px rgba(147, 51, 234, 0.4);
}
.stat-icon svg {
color: white; color: white;
} }
/* Stat content */ /* Stat details */
.stat-content { .stat-details {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px; gap: 8px;
min-height: 48px;
justify-content: center;
} }
.stat-label { .stat-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.stat-row.single {
padding: 12px 0;
}
.stat-title {
font-size: 13px; font-size: 13px;
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
font-weight: 500; font-weight: 500;
line-height: 1.2;
} }
.stat-value { .stat-data {
font-size: 28px;
font-weight: 700;
color: white;
line-height: 1.2;
}
.stat-unit {
font-size: 12px;
color: rgba(255, 255, 255, 0.5);
line-height: 1.2;
}
/* Client count special styling */
.client-count {
display: flex; display: flex;
align-items: baseline; align-items: baseline;
gap: 4px; gap: 4px;
} }
.client-count .stat-value.online { .stat-number {
color: #34d399;
}
.client-count .stat-value.total {
font-size: 24px;
color: rgba(255, 255, 255, 0.7);
}
.stat-separator {
font-size: 20px; font-size: 20px;
color: rgba(255, 255, 255, 0.4); font-weight: 700;
color: var(--color-text-primary);
} }
/* Stat trend indicator */ .stat-number.online {
.stat-trend { color: var(--color-success);
position: absolute; }
top: 16px;
right: 16px; .stat-unit {
padding: 4px 8px;
border-radius: 8px;
font-size: 12px; font-size: 12px;
} color: var(--color-text-muted);
.stat-trend.up {
background: rgba(52, 211, 153, 0.2);
color: #34d399;
} }
/* Online indicator with pulse */ /* Online indicator with pulse */
@@ -495,20 +500,21 @@ onMounted(() => {
.online-indicator .pulse { .online-indicator .pulse {
display: block; display: block;
width: 12px; width: 10px;
height: 12px; height: 10px;
border-radius: 50%; border-radius: 50%;
background: rgba(255, 255, 255, 0.3); background: var(--color-text-muted);
} }
.online-indicator.active .pulse { .online-indicator.active .pulse {
background: #34d399; background: var(--color-success);
animation: pulse-animation 2s ease-in-out infinite; animation: pulse-animation 2s ease-in-out infinite;
box-shadow: 0 0 8px var(--color-success-glow);
} }
@keyframes pulse-animation { @keyframes pulse-animation {
0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); } 0%, 100% { box-shadow: 0 0 0 0 var(--color-success-glow); }
50% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } 50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
} }
/* Chart Section */ /* Chart Section */
@@ -524,9 +530,9 @@ onMounted(() => {
} }
.section-title { .section-title {
font-size: 18px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
margin: 0; margin: 0;
} }
@@ -540,7 +546,7 @@ onMounted(() => {
align-items: center; align-items: center;
gap: 6px; gap: 6px;
font-size: 13px; font-size: 13px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
} }
.legend-dot { .legend-dot {
@@ -550,11 +556,11 @@ onMounted(() => {
} }
.legend-item.inbound .legend-dot { .legend-item.inbound .legend-dot {
background: #a78bfa; background: #8b5cf6;
} }
.legend-item.outbound .legend-dot { .legend-item.outbound .legend-dot {
background: #60a5fa; background: var(--color-accent);
} }
/* Chart Card */ /* Chart Card */
@@ -599,34 +605,49 @@ onMounted(() => {
} }
.bar.inbound { .bar.inbound {
background: linear-gradient(180deg, #a78bfa 0%, #8b5cf6 100%); background: #8b5cf6;
} }
.bar.outbound { .bar.outbound {
background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%); background: var(--color-accent);
} }
.bar-label { .bar-label {
font-size: 10px; font-size: 10px;
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
white-space: nowrap; white-space: nowrap;
} }
.chart-hint { .chart-hint {
margin-top: 16px; margin-top: 16px;
padding-top: 16px; padding-top: 16px;
border-top: 1px solid rgba(255, 255, 255, 0.08); border-top: 1px solid var(--color-border);
text-align: center; text-align: center;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
} }
/* Glass card base */ /* Glass card base - 毛玻璃效果 */
.glass-card { .glass-card {
background: rgba(255, 255, 255, 0.08); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-radius: 16px; border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12); border: 1px solid var(--color-border);
box-shadow: var(--shadow-card);
position: relative;
}
.glass-card::before {
content: '';
position: absolute;
top: 0;
left: 10%;
right: 10%;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.1) 50%,
transparent 100%);
} }
</style> </style>

View File

@@ -101,97 +101,116 @@ const handleLogin = async () => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%); background: var(--gradient-bg);
padding: 16px; padding: 16px;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
} }
/* Particles */ /* 动画背景粒子 */
.particles { .particles {
position: absolute; position: absolute;
inset: 0; inset: 0;
pointer-events: none;
overflow: hidden; overflow: hidden;
pointer-events: none;
z-index: 0;
} }
.particle { .particle {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05)); opacity: 0.2;
animation: float-particle 20s ease-in-out infinite; filter: blur(60px);
animation: float 20s ease-in-out infinite;
} }
.particle-1 { .particle-1 {
width: 300px; width: 400px;
height: 300px; height: 400px;
background: var(--color-accent);
top: -100px; top: -100px;
left: -100px; right: -100px;
animation-delay: 0s;
} }
.particle-2 { .particle-2 {
width: 200px; width: 300px;
height: 200px; height: 300px;
background: #8b5cf6;
bottom: -50px; bottom: -50px;
right: -50px; left: -50px;
animation-delay: -5s; animation-delay: -5s;
} }
.particle-3 { .particle-3 {
width: 150px; width: 250px;
height: 150px; height: 250px;
background: var(--color-info);
top: 50%; top: 50%;
right: 10%; left: 20%;
animation-delay: -10s; animation-delay: -10s;
} }
.particle-4 { .particle-4 {
width: 100px; width: 200px;
height: 100px; height: 200px;
bottom: 20%; background: #ec4899;
left: 10%; bottom: 30%;
right: 10%;
animation-delay: -15s; animation-delay: -15s;
} }
@keyframes float-particle { @keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; } 0%, 100% { transform: translate(0, 0) scale(1); }
25% { transform: translate(30px, -40px) scale(1.1); opacity: 0.5; } 25% { transform: translate(30px, -30px) scale(1.05); }
50% { transform: translate(-20px, -80px) scale(0.9); opacity: 0.4; } 50% { transform: translate(-20px, 20px) scale(0.95); }
75% { transform: translate(-40px, -40px) scale(1.05); opacity: 0.35; } 75% { transform: translate(-30px, -20px) scale(1.02); }
} }
/* Login card */ /* Login card - 毛玻璃效果 */
.login-card { .login-card {
width: 100%; width: 100%;
max-width: 400px; max-width: 400px;
background: rgba(255, 255, 255, 0.08); background: var(--glass-bg);
backdrop-filter: blur(20px); backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: blur(20px); -webkit-backdrop-filter: var(--glass-blur);
border-radius: 24px; border-radius: 20px;
border: 1px solid rgba(255, 255, 255, 0.12); border: 1px solid var(--color-border);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); box-shadow: var(--shadow-card);
padding: 40px; padding: 48px 36px;
position: relative; position: relative;
z-index: 10; z-index: 10;
} }
/* 卡片顶部高光 */
.login-card::before {
content: '';
position: absolute;
top: 0;
left: 20%;
right: 20%;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
rgba(255, 255, 255, 0.15) 50%,
transparent 100%);
}
/* Header */ /* Header */
.login-header { .login-header {
text-align: center; text-align: center;
margin-bottom: 32px; margin-bottom: 36px;
} }
.logo-icon { .logo-icon {
width: 64px; width: 64px;
height: 64px; height: 64px;
margin: 0 auto 16px; margin: 0 auto 20px;
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%); background: var(--gradient-accent);
border-radius: 16px; border-radius: 16px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-shadow: 0 4px 16px rgba(96, 165, 250, 0.4); box-shadow: 0 8px 24px var(--color-accent-glow);
} }
.logo-icon svg { .logo-icon svg {
@@ -203,12 +222,15 @@ const handleLogin = async () => {
.logo-text { .logo-text {
font-size: 28px; font-size: 28px;
font-weight: 700; font-weight: 700;
color: white; background: var(--gradient-accent);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin: 0 0 8px 0; margin: 0 0 8px 0;
} }
.subtitle { .subtitle {
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
margin: 0; margin: 0;
font-size: 14px; font-size: 14px;
} }
@@ -229,17 +251,17 @@ const handleLogin = async () => {
.form-label { .form-label {
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 500;
color: rgba(255, 255, 255, 0.8); color: var(--color-text-primary);
} }
.glass-input { .glass-input {
background: rgba(255, 255, 255, 0.05); background: var(--glass-bg-light);
backdrop-filter: blur(10px); backdrop-filter: var(--glass-blur-light);
-webkit-backdrop-filter: blur(10px); -webkit-backdrop-filter: var(--glass-blur-light);
border: 1px solid rgba(255, 255, 255, 0.1); border: 1px solid var(--color-border);
border-radius: 12px; border-radius: 12px;
padding: 14px 16px; padding: 14px 16px;
color: white; color: var(--color-text-primary);
font-size: 15px; font-size: 15px;
width: 100%; width: 100%;
transition: all 0.2s ease; transition: all 0.2s ease;
@@ -247,13 +269,12 @@ const handleLogin = async () => {
} }
.glass-input:focus { .glass-input:focus {
background: rgba(255, 255, 255, 0.1); border-color: var(--color-accent);
border-color: rgba(255, 255, 255, 0.3); box-shadow: 0 0 0 3px var(--color-accent-glow);
box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
} }
.glass-input::placeholder { .glass-input::placeholder {
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
} }
.glass-input:disabled { .glass-input:disabled {
@@ -266,11 +287,11 @@ const handleLogin = async () => {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
padding: 12px 16px; padding: 12px 14px;
background: rgba(239, 68, 68, 0.2); background: rgba(239, 68, 68, 0.1);
border: 1px solid rgba(239, 68, 68, 0.3); border: 1px solid rgba(239, 68, 68, 0.3);
border-radius: 12px; border-radius: 10px;
color: #fca5a5; color: var(--color-error);
font-size: 14px; font-size: 14px;
} }
@@ -280,12 +301,12 @@ const handleLogin = async () => {
/* Button */ /* Button */
.glass-button { .glass-button {
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%); background: var(--gradient-accent);
border: none; border: none;
border-radius: 12px; border-radius: 12px;
padding: 14px 24px; padding: 14px 24px;
color: white; color: white;
font-size: 16px; font-size: 15px;
font-weight: 600; font-weight: 600;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: all 0.2s ease;
@@ -293,20 +314,21 @@ const handleLogin = async () => {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 8px; gap: 8px;
box-shadow: 0 4px 16px rgba(96, 165, 250, 0.4); box-shadow: 0 4px 15px var(--color-accent-glow);
} }
.glass-button:hover:not(:disabled) { .glass-button:hover:not(:disabled) {
box-shadow: 0 6px 20px var(--color-accent-glow);
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 6px 24px rgba(96, 165, 250, 0.5); filter: brightness(1.1);
} }
.glass-button:active:not(:disabled) { .glass-button:active:not(:disabled) {
transform: translateY(0); transform: translateY(0) scale(0.98);
} }
.glass-button:disabled { .glass-button:disabled {
opacity: 0.7; opacity: 0.6;
cursor: not-allowed; cursor: not-allowed;
} }
@@ -327,10 +349,10 @@ const handleLogin = async () => {
/* Footer */ /* Footer */
.login-footer { .login-footer {
text-align: center; text-align: center;
margin-top: 24px; margin-top: 28px;
padding-top: 24px; padding-top: 24px;
border-top: 1px solid rgba(255, 255, 255, 0.1); border-top: 1px solid var(--color-border);
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
font-size: 13px; font-size: 13px;
} }
</style> </style>

View File

@@ -1,762 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { ExtensionPuzzleOutline, CodeSlashOutline, SettingsOutline } from '@vicons/ionicons5'
import GlassModal from '../components/GlassModal.vue'
import GlassTag from '../components/GlassTag.vue'
import GlassSwitch from '../components/GlassSwitch.vue'
import { useToast } from '../composables/useToast'
import {
getPlugins, enablePlugin, disablePlugin, getJSPlugins,
pushJSPluginToClient, getClients, updateJSPluginConfig, setJSPluginEnabled
} from '../api'
import type { PluginInfo, JSPlugin, ClientStatus } from '../types'
const message = useToast()
const plugins = ref<PluginInfo[]>([])
const jsPlugins = ref<JSPlugin[]>([])
const clients = ref<ClientStatus[]>([])
const loading = ref(true)
const jsLoading = ref(false)
const activeTab = ref('installed')
const loadPlugins = async () => {
try {
const { data } = await getPlugins()
plugins.value = data || []
} catch (e) {
console.error('Failed to load plugins', e)
} finally {
loading.value = false
}
}
const proxyPlugins = computed(() => plugins.value.filter(p => p.type === 'proxy'))
const appPlugins = computed(() => plugins.value.filter(p => p.type === 'app'))
const togglePlugin = async (plugin: PluginInfo) => {
try {
if (plugin.enabled) {
await disablePlugin(plugin.name)
message.success(`已禁用 ${plugin.name}`)
} else {
await enablePlugin(plugin.name)
message.success(`已启用 ${plugin.name}`)
}
plugin.enabled = !plugin.enabled
} catch (e) {
message.error('操作失败')
}
}
const getTypeLabel = (type: string) => {
const labels: Record<string, string> = { proxy: '协议', app: '应用', service: '服务', tool: '工具' }
return labels[type] || type
}
const handleTabChange = (tab: string) => {
if (tab === 'js' && jsPlugins.value.length === 0) loadJSPlugins()
}
const loadJSPlugins = async () => {
jsLoading.value = true
try {
const { data } = await getJSPlugins()
jsPlugins.value = data || []
} catch (e) {
console.error('Failed to load JS plugins', e)
} finally {
jsLoading.value = false
}
}
const loadClients = async () => {
try {
const { data } = await getClients()
clients.value = data || []
} catch (e) {
console.error('Failed to load clients', e)
}
}
// JS Plugin Push
const showPushModal = ref(false)
const selectedJSPlugin = ref<JSPlugin | null>(null)
const pushClientId = ref('')
const pushRemotePort = ref<number | null>(8080)
const pushing = ref(false)
const openPushModal = (plugin: JSPlugin) => {
selectedJSPlugin.value = plugin
pushClientId.value = ''
pushRemotePort.value = 8080
showPushModal.value = true
}
const handlePushJSPlugin = async () => {
if (!selectedJSPlugin.value || !pushClientId.value) {
message.warning('请选择要推送到的客户端')
return
}
pushing.value = true
try {
await pushJSPluginToClient(selectedJSPlugin.value.name, pushClientId.value, pushRemotePort.value || 0)
message.success(`已推送 ${selectedJSPlugin.value.name}`)
showPushModal.value = false
} catch (e: any) {
message.error(e.response?.data || '推送失败')
} finally {
pushing.value = false
}
}
const onlineClients = computed(() => clients.value.filter(c => c.online))
// JS Plugin Config
const showJSConfigModal = ref(false)
const currentJSPlugin = ref<JSPlugin | null>(null)
const jsConfigItems = ref<Array<{ key: string; value: string }>>([])
const jsConfigSaving = ref(false)
const openJSConfigModal = (plugin: JSPlugin) => {
currentJSPlugin.value = plugin
jsConfigItems.value = Object.entries(plugin.config || {}).map(([key, value]) => ({ key, value }))
if (jsConfigItems.value.length === 0) jsConfigItems.value.push({ key: '', value: '' })
showJSConfigModal.value = true
}
const addJSConfigItem = () => jsConfigItems.value.push({ key: '', value: '' })
const removeJSConfigItem = (index: number) => jsConfigItems.value.splice(index, 1)
const saveJSPluginConfig = async () => {
if (!currentJSPlugin.value) return
jsConfigSaving.value = true
try {
const config: Record<string, string> = {}
for (const item of jsConfigItems.value) {
if (item.key.trim()) config[item.key.trim()] = item.value
}
await updateJSPluginConfig(currentJSPlugin.value.name, config)
const plugin = jsPlugins.value.find(p => p.name === currentJSPlugin.value!.name)
if (plugin) plugin.config = config
message.success('配置已保存')
showJSConfigModal.value = false
} catch (e: any) {
message.error(e.response?.data || '保存失败')
} finally {
jsConfigSaving.value = false
}
}
const toggleJSPlugin = async (plugin: JSPlugin) => {
try {
await setJSPluginEnabled(plugin.name, !plugin.enabled)
plugin.enabled = !plugin.enabled
message.success(plugin.enabled ? `已启用 ${plugin.name}` : `已禁用 ${plugin.name}`)
} catch (e: any) {
message.error(e.response?.data || '操作失败')
}
}
onMounted(() => {
loadPlugins()
loadClients()
})
</script>
<template>
<div class="plugins-page">
<!-- Particles -->
<div class="particles">
<div class="particle particle-1"></div>
<div class="particle particle-2"></div>
<div class="particle particle-3"></div>
</div>
<div class="plugins-content">
<!-- Header -->
<div class="page-header">
<h1 class="page-title">插件管理</h1>
<p class="page-subtitle">管理已安装插件和 JS 插件</p>
</div>
<!-- Stats Row -->
<div class="stats-row">
<div class="stat-card">
<span class="stat-value">{{ plugins.length }}</span>
<span class="stat-label">总插件数</span>
</div>
<div class="stat-card">
<span class="stat-value">{{ proxyPlugins.length }}</span>
<span class="stat-label">协议插件</span>
</div>
<div class="stat-card">
<span class="stat-value">{{ appPlugins.length }}</span>
<span class="stat-label">应用插件</span>
</div>
</div>
<!-- Tabs -->
<div class="glass-card">
<div class="tabs-header">
<button class="tab-btn" :class="{ active: activeTab === 'installed' }" @click="activeTab = 'installed'">
已安装插件
</button>
<button class="tab-btn" :class="{ active: activeTab === 'js' }" @click="activeTab = 'js'; handleTabChange('js')">
JS 插件
</button>
</div>
<!-- Installed Plugins Tab -->
<div v-if="activeTab === 'installed'" class="tab-content">
<div v-if="loading" class="loading-state">加载中...</div>
<div v-else-if="plugins.length === 0" class="empty-state">暂无已安装插件</div>
<div v-else class="plugins-grid">
<div v-for="plugin in plugins" :key="plugin.name" class="plugin-card">
<div class="plugin-header">
<div class="plugin-icon">
<ExtensionPuzzleOutline class="icon-purple" />
</div>
<span class="plugin-name">{{ plugin.name }}</span>
<GlassSwitch :model-value="plugin.enabled" size="small" @update:model-value="togglePlugin(plugin)" />
</div>
<div class="plugin-tags">
<GlassTag>v{{ plugin.version }}</GlassTag>
<GlassTag :type="plugin.type === 'proxy' ? 'info' : 'success'">{{ getTypeLabel(plugin.type) }}</GlassTag>
<GlassTag :type="plugin.source === 'builtin' ? 'default' : 'warning'">
{{ plugin.source === 'builtin' ? '内置' : 'JS' }}
</GlassTag>
</div>
<p class="plugin-desc">{{ plugin.description }}</p>
</div>
</div>
</div>
<!-- JS Plugins Tab -->
<div v-if="activeTab === 'js'" class="tab-content">
<div v-if="jsLoading" class="loading-state">加载中...</div>
<div v-else-if="jsPlugins.length === 0" class="empty-state">暂无 JS 插件</div>
<div v-else class="plugins-grid wide">
<div v-for="plugin in jsPlugins" :key="plugin.name" class="plugin-card js">
<div class="plugin-header">
<div class="plugin-icon js">
<CodeSlashOutline class="icon-yellow" />
</div>
<span class="plugin-name">{{ plugin.name }}</span>
<GlassTag v-if="plugin.version">v{{ plugin.version }}</GlassTag>
<GlassSwitch :model-value="plugin.enabled" size="small" @update:model-value="toggleJSPlugin(plugin)" />
</div>
<div class="plugin-tags">
<GlassTag type="warning">JS</GlassTag>
<GlassTag v-if="plugin.auto_start" type="success">自动启动</GlassTag>
<GlassTag v-if="plugin.signature" type="info">已签名</GlassTag>
</div>
<p class="plugin-desc">{{ plugin.description || '无描述' }}</p>
<p v-if="plugin.author" class="plugin-author">作者: {{ plugin.author }}</p>
<div v-if="Object.keys(plugin.config || {}).length > 0" class="plugin-config-preview">
<span class="config-label">配置:</span>
<div class="config-tags">
<GlassTag v-for="(value, key) in plugin.config" :key="key">
{{ key }}: {{ String(value).length > 10 ? String(value).slice(0, 10) + '...' : value }}
</GlassTag>
</div>
</div>
<div class="plugin-actions">
<button class="glass-btn tiny" @click="openJSConfigModal(plugin)">
<SettingsOutline class="btn-icon" />
配置
</button>
<button v-if="onlineClients.length > 0" class="glass-btn primary tiny" @click="openPushModal(plugin)">
推送到客户端
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- JS Config Modal -->
<GlassModal :show="showJSConfigModal" :title="`${currentJSPlugin?.name || ''} 配置`" @close="showJSConfigModal = false">
<p class="config-hint">编辑插件配置参数</p>
<div v-for="(item, index) in jsConfigItems" :key="index" class="config-row">
<input v-model="item.key" class="form-input config-key" placeholder="参数名" />
<input v-model="item.value" class="form-input config-value" placeholder="参数值" />
<button v-if="jsConfigItems.length > 1" class="icon-btn danger" @click="removeJSConfigItem(index)">删除</button>
</div>
<button class="glass-btn small dashed" @click="addJSConfigItem">添加配置项</button>
<template #footer>
<button class="glass-btn" @click="showJSConfigModal = false">取消</button>
<button class="glass-btn primary" :disabled="jsConfigSaving" @click="saveJSPluginConfig">
{{ jsConfigSaving ? '保存中...' : '保存' }}
</button>
</template>
</GlassModal>
<!-- Push Modal -->
<GlassModal :show="showPushModal" title="推送插件到客户端" width="400px" @close="showPushModal = false">
<div v-if="selectedJSPlugin" class="plugin-info-box">
<p class="plugin-info-name">插件: {{ selectedJSPlugin.name }}</p>
<p class="plugin-info-desc">{{ selectedJSPlugin.description || '无描述' }}</p>
</div>
<div class="form-group">
<label class="form-label">选择客户端</label>
<select v-model="pushClientId" class="form-select">
<option value="" disabled>选择客户端</option>
<option v-for="c in onlineClients" :key="c.id" :value="c.id">{{ c.nickname || c.id }}</option>
</select>
</div>
<div class="form-group">
<label class="form-label">远程端口</label>
<input v-model.number="pushRemotePort" type="number" class="form-input" min="1" max="65535" />
</div>
<template #footer>
<button class="glass-btn" @click="showPushModal = false">取消</button>
<button class="glass-btn primary" :disabled="!pushClientId || pushing" @click="handlePushJSPlugin">
{{ pushing ? '推送中...' : '推送' }}
</button>
</template>
</GlassModal>
</div>
</template>
<style scoped>
.plugins-page {
min-height: calc(100vh - 108px);
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%);
position: relative;
overflow: hidden;
padding: 32px;
}
.particles {
position: absolute;
inset: 0;
pointer-events: none;
}
.particle {
position: absolute;
border-radius: 50%;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
animation: float-particle 20s ease-in-out infinite;
}
.particle-1 { width: 250px; height: 250px; top: -80px; right: -50px; }
.particle-2 { width: 180px; height: 180px; bottom: 10%; left: 5%; animation-delay: -7s; }
.particle-3 { width: 120px; height: 120px; top: 50%; right: 15%; animation-delay: -12s; }
@keyframes float-particle {
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; }
50% { transform: translate(-20px, -60px) scale(0.95); opacity: 0.4; }
}
.plugins-content {
position: relative;
z-index: 10;
max-width: 1200px;
margin: 0 auto;
}
.page-header {
margin-bottom: 24px;
}
.page-title {
font-size: 28px;
font-weight: 700;
color: white;
margin: 0 0 8px 0;
}
.page-subtitle {
color: rgba(255, 255, 255, 0.6);
margin: 0;
font-size: 14px;
}
/* Stats Row */
.stats-row {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-bottom: 24px;
}
.stat-card {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
padding: 20px;
text-align: center;
}
.stat-value {
display: block;
font-size: 32px;
font-weight: 700;
color: white;
}
.stat-label {
font-size: 13px;
color: rgba(255, 255, 255, 0.6);
}
/* Glass Card */
.glass-card {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
overflow: hidden;
}
/* Tabs */
.tabs-header {
display: flex;
gap: 4px;
padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tab-btn {
background: transparent;
border: none;
padding: 8px 16px;
color: rgba(255, 255, 255, 0.6);
font-size: 14px;
cursor: pointer;
border-radius: 8px;
transition: all 0.2s;
}
.tab-btn:hover {
color: white;
background: rgba(255, 255, 255, 0.1);
}
.tab-btn.active {
color: white;
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
}
.tab-content {
padding: 20px;
}
.loading-state, .empty-state {
text-align: center;
padding: 48px;
color: rgba(255, 255, 255, 0.5);
}
/* Plugins Grid */
.plugins-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
.plugins-grid.wide {
grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 900px) {
.plugins-grid { grid-template-columns: repeat(2, 1fr); }
.plugins-grid.wide { grid-template-columns: 1fr; }
.stats-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
.plugins-grid { grid-template-columns: 1fr; }
}
/* Plugin Card */
.plugin-card {
background: rgba(255, 255, 255, 0.05);
border-radius: 12px;
padding: 16px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.plugin-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 12px;
}
.plugin-icon {
width: 36px;
height: 36px;
border-radius: 8px;
background: rgba(167, 139, 250, 0.2);
display: flex;
align-items: center;
justify-content: center;
}
.plugin-icon.store {
background: rgba(96, 165, 250, 0.2);
}
.plugin-icon.js {
background: rgba(251, 191, 36, 0.2);
}
.plugin-name {
flex: 1;
font-weight: 600;
color: white;
font-size: 14px;
}
.plugin-tags {
display: flex;
gap: 6px;
flex-wrap: wrap;
margin-bottom: 8px;
}
.plugin-desc {
margin: 0;
color: rgba(255, 255, 255, 0.6);
font-size: 13px;
line-height: 1.5;
}
.plugin-author {
margin: 8px 0 0 0;
color: rgba(255, 255, 255, 0.4);
font-size: 12px;
}
.plugin-config-preview {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.config-label {
display: block;
font-size: 12px;
color: rgba(255, 255, 255, 0.5);
margin-bottom: 6px;
}
.plugin-actions {
display: flex;
gap: 8px;
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
}
/* Glass Button */
.glass-btn {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 6px;
padding: 6px 12px;
color: white;
font-size: 12px;
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 4px;
}
.glass-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
.glass-btn.primary {
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
border: none;
}
.glass-btn.tiny {
padding: 4px 10px;
font-size: 11px;
}
.glass-btn.small {
padding: 6px 12px;
font-size: 12px;
}
.glass-btn.dashed {
border-style: dashed;
}
.glass-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Form Styles */
.form-group {
margin-bottom: 16px;
}
.form-label {
display: block;
font-size: 13px;
color: rgba(255, 255, 255, 0.7);
margin-bottom: 6px;
}
.form-input {
width: 100%;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 8px;
padding: 10px 12px;
color: white;
font-size: 14px;
outline: none;
transition: border-color 0.2s;
box-sizing: border-box;
}
.form-input:focus {
border-color: rgba(167, 139, 250, 0.5);
}
.form-input::placeholder {
color: rgba(255, 255, 255, 0.4);
}
.form-select {
width: 100%;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 8px;
padding: 10px 12px;
color: white;
font-size: 14px;
outline: none;
cursor: pointer;
}
.form-select option {
background: #1e1b4b;
color: white;
}
.form-toggle {
display: flex;
align-items: center;
gap: 8px;
color: rgba(255, 255, 255, 0.7);
font-size: 13px;
cursor: pointer;
}
.form-toggle input[type="checkbox"] {
width: 18px;
height: 18px;
accent-color: #a78bfa;
}
/* Plugin Info Box */
.plugin-info-box {
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
padding: 12px;
margin-bottom: 16px;
}
.plugin-info-name {
margin: 0 0 4px 0;
color: white;
font-weight: 500;
}
.plugin-info-desc {
margin: 0;
color: rgba(255, 255, 255, 0.6);
font-size: 13px;
}
/* Config Row */
.config-hint {
margin: 0 0 12px 0;
color: rgba(255, 255, 255, 0.5);
font-size: 13px;
}
.config-row {
display: flex;
gap: 8px;
align-items: center;
margin-bottom: 8px;
}
.config-key {
width: 150px;
flex-shrink: 0;
}
.config-value {
flex: 1;
}
.icon-btn {
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 6px;
padding: 6px 10px;
color: rgba(255, 255, 255, 0.7);
font-size: 12px;
cursor: pointer;
transition: all 0.2s;
}
.icon-btn:hover {
background: rgba(255, 255, 255, 0.2);
color: white;
}
.icon-btn.danger {
color: #fca5a5;
}
.icon-btn.danger:hover {
background: rgba(239, 68, 68, 0.2);
}
/* Icon styles */
.icon-purple {
width: 20px;
height: 20px;
color: #a78bfa;
}
.icon-blue {
width: 20px;
height: 20px;
color: #60a5fa;
}
.icon-yellow {
width: 20px;
height: 20px;
color: #fbbf24;
}
.btn-icon {
width: 14px;
height: 14px;
}
.config-tags {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
</style>

View File

@@ -19,7 +19,6 @@ const savingConfig = ref(false)
// 配置表单 // 配置表单
const configForm = ref({ const configForm = ref({
bind_addr: '',
heartbeat_sec: 30, heartbeat_sec: 30,
heartbeat_timeout: 90, heartbeat_timeout: 90,
web_username: '', web_username: '',
@@ -45,7 +44,6 @@ const loadServerConfig = async () => {
serverConfig.value = data serverConfig.value = data
// 填充表单 // 填充表单
configForm.value = { configForm.value = {
bind_addr: data.server.bind_addr,
heartbeat_sec: data.server.heartbeat_sec, heartbeat_sec: data.server.heartbeat_sec,
heartbeat_timeout: data.server.heartbeat_timeout, heartbeat_timeout: data.server.heartbeat_timeout,
web_username: data.web.username, web_username: data.web.username,
@@ -64,7 +62,6 @@ const handleSaveConfig = async () => {
try { try {
const updateReq: any = { const updateReq: any = {
server: { server: {
bind_addr: configForm.value.bind_addr,
heartbeat_sec: configForm.value.heartbeat_sec, heartbeat_sec: configForm.value.heartbeat_sec,
heartbeat_timeout: configForm.value.heartbeat_timeout heartbeat_timeout: configForm.value.heartbeat_timeout
}, },
@@ -158,17 +155,6 @@ onMounted(() => {
<div class="card-body"> <div class="card-body">
<div v-if="configLoading" class="loading-state">加载中...</div> <div v-if="configLoading" class="loading-state">加载中...</div>
<div v-else-if="serverConfig" class="config-form"> <div v-else-if="serverConfig" class="config-form">
<div class="form-group">
<label class="form-label">服务器地址</label>
<input
v-model="configForm.bind_addr"
type="text"
class="glass-input"
placeholder="0.0.0.0"
/>
<span class="form-hint">服务器监听地址修改后需重启生效</span>
</div>
<div class="form-row"> <div class="form-row">
<div class="form-group"> <div class="form-group">
<label class="form-label">心跳间隔 ()</label> <label class="form-label">心跳间隔 ()</label>
@@ -223,9 +209,9 @@ onMounted(() => {
v-model="configForm.plugin_store_url" v-model="configForm.plugin_store_url"
type="text" type="text"
class="glass-input" class="glass-input"
placeholder="https://example.com/plugins" placeholder="https://git.92coco.cn/flik/GoTunnel-Plugins/raw/branch/main/store.json"
/> />
<span class="form-hint">插件商店的 API 地址</span> <span class="form-hint">插件商店的 API 地址留空使用默认地址</span>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@@ -249,32 +235,60 @@ onMounted(() => {
<style scoped> <style scoped>
.settings-page { .settings-page {
min-height: calc(100vh - 108px); min-height: calc(100vh - 108px);
background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4c1d95 60%, #581c87 100%); background: transparent;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
padding: 32px; padding: 32px;
} }
/* Hide particles */
.particles { .particles {
position: absolute; position: absolute;
inset: 0; inset: 0;
overflow: hidden;
pointer-events: none; pointer-events: none;
z-index: 0;
} }
.particle { .particle {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05)); opacity: 0.15;
animation: float-particle 20s ease-in-out infinite; filter: blur(60px);
animation: float 20s ease-in-out infinite;
} }
.particle-1 { width: 250px; height: 250px; top: -80px; right: -50px; } .particle-1 {
.particle-2 { width: 180px; height: 180px; bottom: 10%; left: 5%; animation-delay: -7s; } width: 350px;
.particle-3 { width: 120px; height: 120px; top: 50%; right: 15%; animation-delay: -12s; } height: 350px;
background: var(--color-accent);
top: -80px;
right: -80px;
}
@keyframes float-particle { .particle-2 {
0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; } width: 280px;
50% { transform: translate(-20px, -60px) scale(0.95); opacity: 0.4; } height: 280px;
background: #8b5cf6;
bottom: -40px;
left: -40px;
animation-delay: -5s;
}
.particle-3 {
width: 220px;
height: 220px;
background: var(--color-success);
top: 40%;
left: 30%;
animation-delay: -10s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); }
25% { transform: translate(30px, -30px) scale(1.05); }
50% { transform: translate(-20px, 20px) scale(0.95); }
75% { transform: translate(-30px, -20px) scale(1.02); }
} }
.settings-content { .settings-content {
@@ -291,29 +305,27 @@ onMounted(() => {
.page-title { .page-title {
font-size: 28px; font-size: 28px;
font-weight: 700; font-weight: 700;
color: white; color: var(--color-text-primary);
margin: 0 0 8px 0; margin: 0 0 8px 0;
} }
.page-subtitle { .page-subtitle {
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
margin: 0; margin: 0;
font-size: 14px; font-size: 14px;
} }
/* Glass Card */ /* Glass Card */
.glass-card { .glass-card {
background: rgba(255, 255, 255, 0.08); background: var(--color-bg-tertiary);
backdrop-filter: blur(20px); border-radius: 12px;
-webkit-backdrop-filter: blur(20px); border: 1px solid var(--color-border);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.12);
margin-bottom: 20px; margin-bottom: 20px;
} }
.card-header { .card-header {
padding: 16px 20px; padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, 0.08); border-bottom: 1px solid var(--color-border-light);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
@@ -323,7 +335,7 @@ onMounted(() => {
margin: 0; margin: 0;
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: white; color: var(--color-text-primary);
} }
.card-body { .card-body {
@@ -349,12 +361,12 @@ onMounted(() => {
.info-label { .info-label {
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
} }
.info-value { .info-value {
font-size: 14px; font-size: 14px;
color: white; color: var(--color-text-primary);
font-weight: 500; font-weight: 500;
} }
@@ -366,7 +378,7 @@ onMounted(() => {
.loading-state, .empty-state { .loading-state, .empty-state {
text-align: center; text-align: center;
padding: 32px; padding: 32px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
} }
/* Update Alert */ /* Update Alert */
@@ -378,20 +390,20 @@ onMounted(() => {
} }
.update-alert.success { .update-alert.success {
background: rgba(52, 211, 153, 0.15); background: rgba(0, 186, 124, 0.15);
border: 1px solid rgba(52, 211, 153, 0.3); border: 1px solid rgba(0, 186, 124, 0.3);
color: #34d399; color: var(--color-success);
} }
.update-alert.info { .update-alert.info {
background: rgba(96, 165, 250, 0.15); background: rgba(29, 155, 240, 0.15);
border: 1px solid rgba(96, 165, 250, 0.3); border: 1px solid rgba(29, 155, 240, 0.3);
color: #60a5fa; color: var(--color-info);
} }
/* Download Info */ /* Download Info */
.download-info { .download-info {
color: rgba(255, 255, 255, 0.6); color: var(--color-text-secondary);
font-size: 13px; font-size: 13px;
margin-bottom: 12px; margin-bottom: 12px;
} }
@@ -404,7 +416,7 @@ onMounted(() => {
.note-label { .note-label {
display: block; display: block;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
margin-bottom: 6px; margin-bottom: 6px;
} }
@@ -412,8 +424,8 @@ onMounted(() => {
margin: 0; margin: 0;
white-space: pre-wrap; white-space: pre-wrap;
font-size: 12px; font-size: 12px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
background: rgba(0, 0, 0, 0.2); background: var(--color-bg-elevated);
padding: 12px; padding: 12px;
border-radius: 8px; border-radius: 8px;
max-height: 150px; max-height: 150px;
@@ -422,21 +434,21 @@ onMounted(() => {
/* Glass Button */ /* Glass Button */
.glass-btn { .glass-btn {
background: rgba(255, 255, 255, 0.1); background: var(--color-bg-elevated);
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid var(--color-border);
border-radius: 8px; border-radius: 8px;
padding: 8px 16px; padding: 8px 16px;
color: white; color: var(--color-text-primary);
font-size: 13px; font-size: 13px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.15s;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6px; gap: 6px;
} }
.glass-btn:hover:not(:disabled) { .glass-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2); background: var(--color-border);
} }
.glass-btn:disabled { .glass-btn:disabled {
@@ -450,15 +462,19 @@ onMounted(() => {
} }
.glass-btn.primary { .glass-btn.primary {
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%); background: var(--color-accent);
border: none; border: none;
} }
.glass-btn.primary:hover:not(:disabled) {
background: var(--color-accent-hover);
}
/* Icon styles */ /* Icon styles */
.header-icon { .header-icon {
width: 20px; width: 20px;
height: 20px; height: 20px;
color: rgba(255, 255, 255, 0.5); color: var(--color-text-muted);
} }
.btn-icon { .btn-icon {
@@ -481,13 +497,13 @@ onMounted(() => {
.form-label { .form-label {
font-size: 13px; font-size: 13px;
color: rgba(255, 255, 255, 0.7); color: var(--color-text-secondary);
font-weight: 500; font-weight: 500;
} }
.form-hint { .form-hint {
font-size: 11px; font-size: 11px;
color: rgba(255, 255, 255, 0.4); color: var(--color-text-muted);
} }
.form-row { .form-row {
@@ -504,7 +520,7 @@ onMounted(() => {
.form-divider { .form-divider {
height: 1px; height: 1px;
background: rgba(255, 255, 255, 0.1); background: var(--color-border-light);
margin: 8px 0; margin: 8px 0;
} }
@@ -514,22 +530,21 @@ onMounted(() => {
/* Glass Input */ /* Glass Input */
.glass-input { .glass-input {
background: rgba(255, 255, 255, 0.08); background: var(--color-bg-elevated);
border: 1px solid rgba(255, 255, 255, 0.15); border: 1px solid var(--color-border);
border-radius: 8px; border-radius: 8px;
padding: 10px 14px; padding: 10px 14px;
color: white; color: var(--color-text-primary);
font-size: 14px; font-size: 14px;
outline: none; outline: none;
transition: all 0.2s; transition: all 0.15s;
} }
.glass-input:focus { .glass-input:focus {
border-color: rgba(96, 165, 250, 0.5); border-color: var(--color-accent);
background: rgba(255, 255, 255, 0.12);
} }
.glass-input::placeholder { .glass-input::placeholder {
color: rgba(255, 255, 255, 0.3); color: var(--color-text-muted);
} }
</style> </style>