Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3386b0fcb6 | ||
|
|
98a5525e6d | ||
|
|
5c8020d5fb | ||
|
|
a2773aa1a7 | ||
|
|
9cc2fa8076 | ||
|
|
1890cad8d9 | ||
|
|
11572f132c | ||
|
|
9f13b0d4e9 | ||
|
|
7cddb7b3e7 | ||
|
|
d1058f9e89 | ||
|
|
06dfcfaff3 | ||
|
|
67c41cde5c | ||
|
|
4500f48d4c | ||
|
|
381c6911af | ||
|
|
42445d18eb | ||
|
|
d3969079a5 | ||
|
|
23fa089608 |
@@ -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,22 +185,22 @@ 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
|
||||||
uses: softprops/action-gh-release@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ inputs.version }}
|
tag_name: ${{ inputs.version }}
|
||||||
name: Release ${{ inputs.version }}
|
name: Release ${{ inputs.version }}
|
||||||
body_path: release_notes.md
|
body_path: release_notes.md
|
||||||
files: |
|
files: |-
|
||||||
dist/*.tar.gz
|
dist/*.tar.gz
|
||||||
dist/*.zip
|
dist/*.zip
|
||||||
dist/SHA256SUMS
|
dist/SHA256SUMS
|
||||||
draft: ${{ inputs.draft }}
|
draft: ${{ inputs.draft }}
|
||||||
prerelease: ${{ inputs.prerelease }}
|
prerelease: ${{ inputs.prerelease }}
|
||||||
env:
|
token: ${{ secrets.ACCOUNT_TOKEN }}
|
||||||
GITHUB_TOKEN: ${{ secrets.ACCOUNT_TOKEN }}
|
|
||||||
|
|
||||||
- name: Release created successfully
|
- name: Release created successfully
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -8,8 +8,19 @@ import (
|
|||||||
"github.com/gotunnel/internal/client/tunnel"
|
"github.com/gotunnel/internal/client/tunnel"
|
||||||
"github.com/gotunnel/pkg/crypto"
|
"github.com/gotunnel/pkg/crypto"
|
||||||
"github.com/gotunnel/pkg/plugin"
|
"github.com/gotunnel/pkg/plugin"
|
||||||
|
"github.com/gotunnel/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 版本信息(通过 ldflags 注入)
|
||||||
|
var Version string
|
||||||
|
var BuildTime string
|
||||||
|
var GitCommit string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
version.SetVersion(Version)
|
||||||
|
version.SetBuildInfo(GitCommit, BuildTime)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
server := flag.String("s", "", "server address (ip:port)")
|
server := flag.String("s", "", "server address (ip:port)")
|
||||||
token := flag.String("t", "", "auth token")
|
token := flag.String("t", "", "auth token")
|
||||||
|
|||||||
@@ -27,9 +27,19 @@ import (
|
|||||||
"github.com/gotunnel/internal/server/tunnel"
|
"github.com/gotunnel/internal/server/tunnel"
|
||||||
"github.com/gotunnel/pkg/crypto"
|
"github.com/gotunnel/pkg/crypto"
|
||||||
"github.com/gotunnel/pkg/plugin"
|
"github.com/gotunnel/pkg/plugin"
|
||||||
"github.com/gotunnel/pkg/plugin/sign"
|
"github.com/gotunnel/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 版本信息(通过 ldflags 注入)
|
||||||
|
var Version string
|
||||||
|
var BuildTime string
|
||||||
|
var GitCommit string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
version.SetVersion(Version)
|
||||||
|
version.SetBuildInfo(GitCommit, BuildTime)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configPath := flag.String("c", "server.yaml", "config file path")
|
configPath := flag.String("c", "server.yaml", "config file path")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@@ -75,18 +85,12 @@ func main() {
|
|||||||
server.SetPluginRegistry(registry)
|
server.SetPluginRegistry(registry)
|
||||||
server.SetJSPluginStore(clientStore) // 设置 JS 插件存储,用于客户端重连时恢复插件
|
server.SetJSPluginStore(clientStore) // 设置 JS 插件存储,用于客户端重连时恢复插件
|
||||||
|
|
||||||
// 加载 JS 插件配置
|
|
||||||
if len(cfg.JSPlugins) > 0 {
|
|
||||||
jsPlugins := loadJSPlugins(cfg.JSPlugins)
|
|
||||||
server.LoadJSPlugins(jsPlugins)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 启动 Web 控制台
|
// 启动 Web 控制台
|
||||||
if cfg.Web.Enabled {
|
if cfg.Server.Web.Enabled {
|
||||||
// 强制生成 Web 凭据(如果未配置)
|
// 强制生成 Web 凭据(如果未配置)
|
||||||
if config.GenerateWebCredentials(cfg) {
|
if config.GenerateWebCredentials(cfg) {
|
||||||
log.Printf("[Web] Auto-generated credentials - Username: %s, Password: %s",
|
log.Printf("[Web] Auto-generated credentials - Username: %s, Password: %s",
|
||||||
cfg.Web.Username, cfg.Web.Password)
|
cfg.Server.Web.Username, cfg.Server.Web.Password)
|
||||||
log.Printf("[Web] Please save these credentials and update your config file")
|
log.Printf("[Web] Please save these credentials and update your config file")
|
||||||
// 保存配置以持久化凭据
|
// 保存配置以持久化凭据
|
||||||
if err := config.SaveServerConfig(*configPath, cfg); err != nil {
|
if err := config.SaveServerConfig(*configPath, cfg); err != nil {
|
||||||
@@ -95,11 +99,11 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ws := app.NewWebServer(clientStore, server, cfg, *configPath, clientStore)
|
ws := app.NewWebServer(clientStore, server, cfg, *configPath, clientStore)
|
||||||
addr := fmt.Sprintf("%s:%d", cfg.Web.BindAddr, cfg.Web.BindPort)
|
addr := fmt.Sprintf("%s:%d", cfg.Server.BindAddr, cfg.Server.Web.BindPort)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// 始终使用 JWT 认证
|
// 始终使用 JWT 认证
|
||||||
err := ws.RunWithJWT(addr, cfg.Web.Username, cfg.Web.Password, cfg.Server.Token)
|
err := ws.RunWithJWT(addr, cfg.Server.Web.Username, cfg.Server.Web.Password, cfg.Server.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[Web] Server error: %v", err)
|
log.Printf("[Web] Server error: %v", err)
|
||||||
}
|
}
|
||||||
@@ -120,69 +124,3 @@ func main() {
|
|||||||
|
|
||||||
log.Fatal(server.Run())
|
log.Fatal(server.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadJSPlugins 加载 JS 插件文件
|
|
||||||
func loadJSPlugins(configs []config.JSPluginConfig) []tunnel.JSPluginEntry {
|
|
||||||
var plugins []tunnel.JSPluginEntry
|
|
||||||
|
|
||||||
for _, cfg := range configs {
|
|
||||||
source, err := os.ReadFile(cfg.Path)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[JSPlugin] Failed to load %s: %v", cfg.Path, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载签名文件
|
|
||||||
sigPath := cfg.SigPath
|
|
||||||
if sigPath == "" {
|
|
||||||
sigPath = cfg.Path + ".sig"
|
|
||||||
}
|
|
||||||
signature, err := os.ReadFile(sigPath)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[JSPlugin] Failed to load signature for %s: %v", cfg.Name, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// 服务端也验证签名,防止配置文件被篡改
|
|
||||||
if err := verifyPluginSignature(cfg.Name, string(source), string(signature)); err != nil {
|
|
||||||
log.Printf("[JSPlugin] Signature verification failed for %s: %v", cfg.Name, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins = append(plugins, tunnel.JSPluginEntry{
|
|
||||||
Name: cfg.Name,
|
|
||||||
Source: string(source),
|
|
||||||
Signature: string(signature),
|
|
||||||
AutoPush: cfg.AutoPush,
|
|
||||||
Config: cfg.Config,
|
|
||||||
AutoStart: cfg.AutoStart,
|
|
||||||
})
|
|
||||||
|
|
||||||
log.Printf("[JSPlugin] Loaded: %s from %s (verified)", cfg.Name, cfg.Path)
|
|
||||||
}
|
|
||||||
|
|
||||||
return plugins
|
|
||||||
}
|
|
||||||
|
|
||||||
// verifyPluginSignature 验证插件签名
|
|
||||||
func verifyPluginSignature(name, source, signature string) error {
|
|
||||||
// 解码签名
|
|
||||||
signed, err := sign.DecodeSignedPlugin(signature)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("decode signature: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取公钥
|
|
||||||
pubKey, err := sign.GetPublicKeyByID(signed.Payload.KeyID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证插件名称
|
|
||||||
if signed.Payload.Name != name {
|
|
||||||
return fmt.Errorf("name mismatch: %s vs %s", signed.Payload.Name, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证签名
|
|
||||||
return sign.VerifyPlugin(pubKey, signed, source)
|
|
||||||
}
|
|
||||||
|
|||||||
38
go.mod
38
go.mod
@@ -3,31 +3,35 @@ module github.com/gotunnel
|
|||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9
|
||||||
|
github.com/gin-gonic/gin v1.11.0
|
||||||
|
github.com/go-playground/validator/v10 v10.30.1
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0
|
github.com/golang-jwt/jwt/v5 v5.3.0
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/hashicorp/yamux v0.1.1
|
github.com/hashicorp/yamux v0.1.1
|
||||||
|
github.com/shirou/gopsutil/v3 v3.24.5
|
||||||
|
github.com/swaggo/files v1.0.1
|
||||||
|
github.com/swaggo/gin-swagger v1.6.1
|
||||||
|
github.com/swaggo/swag v1.16.6
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
modernc.org/sqlite v1.41.0
|
modernc.org/sqlite v1.41.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||||
github.com/PuerkitoBio/purell v1.2.1 // indirect
|
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
|
||||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||||
github.com/bytedance/sonic v1.14.2 // indirect
|
github.com/bytedance/sonic v1.14.2 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.4.0 // indirect
|
github.com/bytedance/sonic/loader v0.4.0 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
|
|
||||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||||
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9 // indirect
|
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/gin-gonic/gin v1.11.0 // indirect
|
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.22.4 // indirect
|
github.com/go-openapi/jsonpointer v0.22.4 // indirect
|
||||||
github.com/go-openapi/jsonreference v0.21.4 // indirect
|
github.com/go-openapi/jsonreference v0.21.4 // indirect
|
||||||
github.com/go-openapi/spec v0.22.3 // indirect
|
github.com/go-openapi/spec v0.22.3 // indirect
|
||||||
github.com/go-openapi/swag v0.25.4 // indirect
|
|
||||||
github.com/go-openapi/swag/conv v0.25.4 // indirect
|
github.com/go-openapi/swag/conv v0.25.4 // indirect
|
||||||
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
|
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
|
||||||
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
|
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
|
||||||
@@ -37,37 +41,31 @@ require (
|
|||||||
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
|
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
|
||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/goccy/go-yaml v1.19.1 // indirect
|
github.com/goccy/go-yaml v1.19.1 // indirect
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/mailru/easyjson v0.9.1 // indirect
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||||
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/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||||
github.com/swaggo/files v1.0.1 // indirect
|
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||||
github.com/swaggo/gin-swagger v1.6.1 // indirect
|
|
||||||
github.com/swaggo/swag v1.16.6 // indirect
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||||
github.com/urfave/cli/v2 v2.27.7 // indirect
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
|
|
||||||
go.uber.org/mock v0.6.0 // indirect
|
go.uber.org/mock v0.6.0 // indirect
|
||||||
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
|
||||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||||
golang.org/x/arch v0.23.0 // indirect
|
golang.org/x/arch v0.23.0 // indirect
|
||||||
golang.org/x/crypto v0.46.0 // indirect
|
golang.org/x/crypto v0.46.0 // indirect
|
||||||
@@ -79,9 +77,7 @@ require (
|
|||||||
golang.org/x/text v0.32.0 // indirect
|
golang.org/x/text v0.32.0 // indirect
|
||||||
golang.org/x/tools v0.40.0 // indirect
|
golang.org/x/tools v0.40.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.11 // indirect
|
google.golang.org/protobuf v1.36.11 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
||||||
modernc.org/libc v1.66.10 // indirect
|
modernc.org/libc v1.66.10 // indirect
|
||||||
modernc.org/mathutil v1.7.1 // indirect
|
modernc.org/mathutil v1.7.1 // indirect
|
||||||
modernc.org/memory v1.11.0 // indirect
|
modernc.org/memory v1.11.0 // indirect
|
||||||
sigs.k8s.io/yaml v1.6.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
118
go.sum
118
go.sum
@@ -1,24 +1,18 @@
|
|||||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||||
github.com/PuerkitoBio/purell v1.2.1 h1:QsZ4TjvwiMpat6gBCBxEQI0rcS9ehtkKtSpiUnd9N28=
|
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
|
||||||
github.com/PuerkitoBio/purell v1.2.1/go.mod h1:ZwHcC/82TOaovDi//J/804umJFFmbOHPngi8iYYv/Eo=
|
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
|
||||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
|
||||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||||
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
|
|
||||||
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
|
|
||||||
github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE=
|
github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE=
|
||||||
github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980=
|
github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980=
|
||||||
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
|
|
||||||
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
|
||||||
github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o=
|
github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o=
|
||||||
github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
|
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
|
||||||
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||||
@@ -26,28 +20,31 @@ github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9 h1:3uSSOd6mVlwcX3k5OYO
|
|||||||
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
|
github.com/dop251/goja v0.0.0-20251201205617-2bb4c724c0f9/go.mod h1:MxLav0peU43GgvwVgNbLAj1s/bSGboKkhuULvq/7hx4=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||||
|
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||||
|
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
|
||||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
||||||
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
||||||
|
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||||
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
|
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
|
||||||
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
|
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
|
||||||
github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8=
|
github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8=
|
||||||
github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4=
|
github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4=
|
||||||
github.com/go-openapi/spec v0.22.3 h1:qRSmj6Smz2rEBxMnLRBMeBWxbbOvuOoElvSvObIgwQc=
|
github.com/go-openapi/spec v0.22.3 h1:qRSmj6Smz2rEBxMnLRBMeBWxbbOvuOoElvSvObIgwQc=
|
||||||
github.com/go-openapi/spec v0.22.3/go.mod h1:iIImLODL2loCh3Vnox8TY2YWYJZjMAKYyLH2Mu8lOZs=
|
github.com/go-openapi/spec v0.22.3/go.mod h1:iIImLODL2loCh3Vnox8TY2YWYJZjMAKYyLH2Mu8lOZs=
|
||||||
github.com/go-openapi/swag v0.25.4 h1:OyUPUFYDPDBMkqyxOTkqDYFnrhuhi9NR6QVUvIochMU=
|
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
|
||||||
github.com/go-openapi/swag v0.25.4/go.mod h1:zNfJ9WZABGHCFg2RnY0S4IOkAcVTzJ6z2Bi+Q4i6qFQ=
|
|
||||||
github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4=
|
github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4=
|
||||||
github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU=
|
github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU=
|
||||||
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
|
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
|
||||||
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
|
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
|
||||||
github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA=
|
github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA=
|
||||||
github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY=
|
github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY=
|
||||||
|
github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4 h1:IACsSvBhiNJwlDix7wq39SS2Fh7lUOCJRmx/4SN4sVo=
|
||||||
|
github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4/go.mod h1:Mt0Ost9l3cUzVv4OEZG+WSeoHwjWLnarzMePNDAOBiM=
|
||||||
github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s=
|
github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s=
|
||||||
github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE=
|
github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE=
|
||||||
github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8=
|
github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8=
|
||||||
@@ -56,26 +53,29 @@ github.com/go-openapi/swag/typeutils v0.25.4 h1:1/fbZOUN472NTc39zpa+YGHn3jzHWhv4
|
|||||||
github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE=
|
github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE=
|
||||||
github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw=
|
github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw=
|
||||||
github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc=
|
github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc=
|
||||||
|
github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4=
|
||||||
|
github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg=
|
||||||
|
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls=
|
||||||
|
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
|
||||||
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
|
|
||||||
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
|
||||||
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
||||||
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
||||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
||||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
|
||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
|
||||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
|
||||||
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
|
||||||
github.com/goccy/go-yaml v1.19.1 h1:3rG3+v8pkhRqoQ/88NYNMHYVGYztCOCIZ7UQhu7H+NE=
|
github.com/goccy/go-yaml v1.19.1 h1:3rG3+v8pkhRqoQ/88NYNMHYVGYztCOCIZ7UQhu7H+NE=
|
||||||
github.com/goccy/go-yaml v1.19.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
github.com/goccy/go-yaml v1.19.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
||||||
@@ -85,19 +85,20 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN
|
|||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||||
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/mailru/easyjson v0.9.1 h1:LbtsOm5WAswyWbvTEOqhypdPeZzHavpZx96/n553mR8=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||||
github.com/mailru/easyjson v0.9.1/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -107,21 +108,24 @@ github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdh
|
|||||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||||
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||||
github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=
|
|
||||||
github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
|
|
||||||
github.com/quic-go/quic-go v0.58.0 h1:ggY2pvZaVdB9EyojxL1p+5mptkuHyX5MOSv4dgWF4Ug=
|
github.com/quic-go/quic-go v0.58.0 h1:ggY2pvZaVdB9EyojxL1p+5mptkuHyX5MOSv4dgWF4Ug=
|
||||||
github.com/quic-go/quic-go v0.58.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
github.com/quic-go/quic-go v0.58.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
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.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||||
|
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
|
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
||||||
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=
|
||||||
@@ -129,74 +133,63 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/
|
|||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||||
github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY=
|
github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY=
|
||||||
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw=
|
||||||
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI=
|
||||||
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg=
|
||||||
|
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||||
|
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||||
|
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||||
|
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
|
||||||
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
|
||||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
|
|
||||||
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
|
|
||||||
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
|
|
||||||
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
|
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||||
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
|
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
|
|
||||||
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
|
|
||||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=
|
|
||||||
golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
|
||||||
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
|
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
|
||||||
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
|
||||||
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
|
||||||
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
||||||
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
||||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
|
||||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
|
|
||||||
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
|
|
||||||
golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
|
golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
|
||||||
golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
|
golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
|
||||||
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
|
||||||
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
|
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
|
||||||
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
|
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
|
||||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
|
||||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||||
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
@@ -205,28 +198,21 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
|||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
|
|
||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
|
||||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
|
||||||
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
|
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
|
||||||
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
|
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
|
|
||||||
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
|
|
||||||
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
|
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
|
||||||
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
|
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
|
||||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
@@ -258,5 +244,3 @@ modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
|||||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
|
|
||||||
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import (
|
|||||||
"github.com/gotunnel/pkg/protocol"
|
"github.com/gotunnel/pkg/protocol"
|
||||||
"github.com/gotunnel/pkg/relay"
|
"github.com/gotunnel/pkg/relay"
|
||||||
"github.com/gotunnel/pkg/update"
|
"github.com/gotunnel/pkg/update"
|
||||||
|
"github.com/gotunnel/pkg/utils"
|
||||||
|
"github.com/gotunnel/pkg/version"
|
||||||
"github.com/hashicorp/yamux"
|
"github.com/hashicorp/yamux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ func NewClient(serverAddr, token, id string) *Client {
|
|||||||
|
|
||||||
// 确保数据目录存在
|
// 确保数据目录存在
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
if id == "" {
|
if id == "" {
|
||||||
@@ -69,7 +71,7 @@ func NewClient(serverAddr, token, id string) *Client {
|
|||||||
// 初始化日志收集器
|
// 初始化日志收集器
|
||||||
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{
|
||||||
@@ -109,7 +111,7 @@ func loadClientID(dataDir string) string {
|
|||||||
// saveClientID 保存客户端 ID 到本地文件
|
// saveClientID 保存客户端 ID 到本地文件
|
||||||
func saveClientID(dataDir, id string) {
|
func saveClientID(dataDir, id string) {
|
||||||
if err := os.WriteFile(getIDFilePath(dataDir), []byte(id), 0600); err != nil {
|
if err := os.WriteFile(getIDFilePath(dataDir), []byte(id), 0600); err != nil {
|
||||||
log.Printf("[Client] Failed to save client ID: %v", err)
|
log.Printf("Failed to save client ID: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,14 +151,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,7 +178,13 @@ func (c *Client) connect() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
authReq := protocol.AuthRequest{ClientID: c.ID, Token: c.Token}
|
authReq := protocol.AuthRequest{
|
||||||
|
ClientID: c.ID,
|
||||||
|
Token: c.Token,
|
||||||
|
OS: runtime.GOOS,
|
||||||
|
Arch: runtime.GOARCH,
|
||||||
|
Version: version.Version,
|
||||||
|
}
|
||||||
msg, _ := protocol.NewMessage(protocol.MsgTypeAuth, authReq)
|
msg, _ := protocol.NewMessage(protocol.MsgTypeAuth, authReq)
|
||||||
if err := protocol.WriteMessage(conn, msg); err != nil {
|
if err := protocol.WriteMessage(conn, msg); err != nil {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
@@ -203,10 +211,10 @@ func (c *Client) connect() error {
|
|||||||
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)
|
saveClientID(c.DataDir, c.ID)
|
||||||
c.logf("[Client] New ID assigned and saved: %s", c.ID)
|
c.logf("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 {
|
||||||
@@ -244,8 +252,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)
|
||||||
@@ -281,14 +288,18 @@ func (c *Client) handleStream(stream net.Conn) {
|
|||||||
c.handlePluginStatusQuery(stream, msg)
|
c.handlePluginStatusQuery(stream, msg)
|
||||||
case protocol.MsgTypePluginAPIRequest:
|
case protocol.MsgTypePluginAPIRequest:
|
||||||
c.handlePluginAPIRequest(stream, msg)
|
c.handlePluginAPIRequest(stream, msg)
|
||||||
|
case protocol.MsgTypeSystemStatsRequest:
|
||||||
|
c.handleSystemStatsRequest(stream, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,17 +307,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,14 +336,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,24 +453,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +484,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 {
|
||||||
@@ -501,7 +516,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, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +558,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
|
||||||
}
|
}
|
||||||
@@ -562,7 +577,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
|
||||||
@@ -573,9 +588,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)
|
||||||
}
|
}
|
||||||
@@ -583,11 +598,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)
|
||||||
@@ -601,7 +616,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 {
|
||||||
@@ -634,13 +649,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,7 +668,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 插件签名
|
||||||
@@ -731,13 +746,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, "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,7 +763,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{
|
||||||
@@ -761,7 +776,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)
|
||||||
@@ -803,7 +818,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")
|
||||||
@@ -814,7 +829,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()
|
||||||
@@ -835,7 +850,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, "")
|
||||||
@@ -859,17 +874,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)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -888,7 +903,7 @@ 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")
|
binaryPath, cleanup, err := update.DownloadAndExtract(downloadURL, "client")
|
||||||
@@ -935,7 +950,7 @@ func (c *Client) performSelfUpdate(downloadURL string) error {
|
|||||||
// 删除备份
|
// 删除备份
|
||||||
os.Remove(backupPath)
|
os.Remove(backupPath)
|
||||||
|
|
||||||
c.logf("[Client] Update completed, restarting...")
|
c.logf("Update completed, restarting...")
|
||||||
|
|
||||||
// 重启进程
|
// 重启进程
|
||||||
restartClientProcess(currentPath, c.ServerAddr, c.Token, c.ID)
|
restartClientProcess(currentPath, c.ServerAddr, c.Token, c.ID)
|
||||||
@@ -946,7 +961,7 @@ func (c *Client) performSelfUpdate(downloadURL string) error {
|
|||||||
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)
|
||||||
@@ -1112,7 +1127,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()
|
||||||
@@ -1168,3 +1183,27 @@ func (c *Client) sendPluginAPIResponse(stream net.Conn, status int, headers map[
|
|||||||
msg, _ := protocol.NewMessage(protocol.MsgTypePluginAPIResponse, resp)
|
msg, _ := protocol.NewMessage(protocol.MsgTypePluginAPIResponse, resp)
|
||||||
protocol.WriteMessage(stream, msg)
|
protocol.WriteMessage(stream, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleSystemStatsRequest 处理系统状态请求
|
||||||
|
func (c *Client) handleSystemStatsRequest(stream net.Conn, msg *protocol.Message) {
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
|
stats, err := utils.GetSystemStats()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to get system stats: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := protocol.SystemStatsResponse{
|
||||||
|
CPUUsage: stats.CPUUsage,
|
||||||
|
MemoryTotal: stats.MemoryTotal,
|
||||||
|
MemoryUsed: stats.MemoryUsed,
|
||||||
|
MemoryUsage: stats.MemoryUsage,
|
||||||
|
DiskTotal: stats.DiskTotal,
|
||||||
|
DiskUsed: stats.DiskUsed,
|
||||||
|
DiskUsage: stats.DiskUsage,
|
||||||
|
}
|
||||||
|
|
||||||
|
respMsg, _ := protocol.NewMessage(protocol.MsgTypeSystemStatsResponse, resp)
|
||||||
|
protocol.WriteMessage(stream, respMsg)
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,16 +21,18 @@ type WebServer struct {
|
|||||||
Config *config.ServerConfig
|
Config *config.ServerConfig
|
||||||
ConfigPath string
|
ConfigPath string
|
||||||
JSPluginStore db.JSPluginStore
|
JSPluginStore db.JSPluginStore
|
||||||
|
TrafficStore db.TrafficStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWebServer 创建Web服务
|
// NewWebServer 创建Web服务
|
||||||
func NewWebServer(cs db.ClientStore, srv router.ServerInterface, cfg *config.ServerConfig, cfgPath string, jsStore db.JSPluginStore) *WebServer {
|
func NewWebServer(cs db.ClientStore, srv router.ServerInterface, cfg *config.ServerConfig, cfgPath string, store db.Store) *WebServer {
|
||||||
return &WebServer{
|
return &WebServer{
|
||||||
ClientStore: cs,
|
ClientStore: cs,
|
||||||
Server: srv,
|
Server: srv,
|
||||||
Config: cfg,
|
Config: cfg,
|
||||||
ConfigPath: cfgPath,
|
ConfigPath: cfgPath,
|
||||||
JSPluginStore: jsStore,
|
JSPluginStore: store,
|
||||||
|
TrafficStore: store,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,3 +111,8 @@ func (w *WebServer) SaveConfig() error {
|
|||||||
func (w *WebServer) GetJSPluginStore() db.JSPluginStore {
|
func (w *WebServer) GetJSPluginStore() db.JSPluginStore {
|
||||||
return w.JSPluginStore
|
return w.JSPluginStore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTrafficStore 获取流量存储
|
||||||
|
func (w *WebServer) GetTrafficStore() db.TrafficStore {
|
||||||
|
return w.TrafficStore
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,20 +10,7 @@ import (
|
|||||||
|
|
||||||
// ServerConfig 服务端配置
|
// ServerConfig 服务端配置
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
Server ServerSettings `yaml:"server"`
|
Server ServerSettings `yaml:"server"`
|
||||||
Web WebSettings `yaml:"web"`
|
|
||||||
PluginStore PluginStoreSettings `yaml:"plugin_store"`
|
|
||||||
JSPlugins []JSPluginConfig `yaml:"js_plugins,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSPluginConfig JS 插件配置
|
|
||||||
type JSPluginConfig struct {
|
|
||||||
Name string `yaml:"name"`
|
|
||||||
Path string `yaml:"path"` // JS 文件路径
|
|
||||||
SigPath string `yaml:"sig_path,omitempty"` // 签名文件路径 (默认为 path + ".sig")
|
|
||||||
AutoPush []string `yaml:"auto_push,omitempty"` // 自动推送到的客户端 ID 列表
|
|
||||||
Config map[string]string `yaml:"config,omitempty"` // 插件配置
|
|
||||||
AutoStart bool `yaml:"auto_start,omitempty"` // 是否自动启动
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginStoreSettings 插件仓库设置
|
// PluginStoreSettings 插件仓库设置
|
||||||
@@ -44,19 +31,20 @@ func (s *PluginStoreSettings) GetPluginStoreURL() string {
|
|||||||
|
|
||||||
// ServerSettings 服务端设置
|
// ServerSettings 服务端设置
|
||||||
type ServerSettings struct {
|
type ServerSettings struct {
|
||||||
BindAddr string `yaml:"bind_addr"`
|
BindAddr string `yaml:"bind_addr"`
|
||||||
BindPort int `yaml:"bind_port"`
|
BindPort int `yaml:"bind_port"`
|
||||||
Token string `yaml:"token"`
|
Token string `yaml:"token"`
|
||||||
HeartbeatSec int `yaml:"heartbeat_sec"`
|
HeartbeatSec int `yaml:"heartbeat_sec"`
|
||||||
HeartbeatTimeout int `yaml:"heartbeat_timeout"`
|
HeartbeatTimeout int `yaml:"heartbeat_timeout"`
|
||||||
DBPath string `yaml:"db_path"`
|
DBPath string `yaml:"db_path"`
|
||||||
TLSDisabled bool `yaml:"tls_disabled"` // 默认启用 TLS,设置为 true 禁用
|
TLSDisabled bool `yaml:"tls_disabled"`
|
||||||
|
Web WebSettings `yaml:"web"`
|
||||||
|
PluginStore PluginStoreSettings `yaml:"plugin_store"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebSettings Web控制台设置
|
// WebSettings Web控制台设置
|
||||||
type WebSettings struct {
|
type WebSettings struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
BindAddr string `yaml:"bind_addr"`
|
|
||||||
BindPort int `yaml:"bind_port"`
|
BindPort int `yaml:"bind_port"`
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
@@ -99,12 +87,9 @@ func setDefaults(cfg *ServerConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Web 默认启用
|
// Web 默认启用
|
||||||
if cfg.Web.BindAddr == "" {
|
if cfg.Server.Web.BindPort == 0 {
|
||||||
cfg.Web.BindAddr = "0.0.0.0"
|
cfg.Server.Web.BindPort = 7500
|
||||||
}
|
cfg.Server.Web.Enabled = true
|
||||||
if cfg.Web.BindPort == 0 {
|
|
||||||
cfg.Web.BindPort = 7500
|
|
||||||
cfg.Web.Enabled = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Token 未配置时自动生成 32 位
|
// Token 未配置时自动生成 32 位
|
||||||
@@ -126,11 +111,11 @@ func generateToken(length int) string {
|
|||||||
|
|
||||||
// GenerateWebCredentials 生成 Web 控制台凭据
|
// GenerateWebCredentials 生成 Web 控制台凭据
|
||||||
func GenerateWebCredentials(cfg *ServerConfig) bool {
|
func GenerateWebCredentials(cfg *ServerConfig) bool {
|
||||||
if cfg.Web.Username == "" {
|
if cfg.Server.Web.Username == "" {
|
||||||
cfg.Web.Username = "admin"
|
cfg.Server.Web.Username = "admin"
|
||||||
}
|
}
|
||||||
if cfg.Web.Password == "" {
|
if cfg.Server.Web.Password == "" {
|
||||||
cfg.Web.Password = generateToken(16)
|
cfg.Server.Web.Password = generateToken(16)
|
||||||
return true // 表示生成了新密码
|
return true // 表示生成了新密码
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -76,5 +76,21 @@ type JSPluginStore interface {
|
|||||||
type Store interface {
|
type Store interface {
|
||||||
ClientStore
|
ClientStore
|
||||||
JSPluginStore
|
JSPluginStore
|
||||||
|
TrafficStore
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TrafficRecord 流量记录
|
||||||
|
type TrafficRecord struct {
|
||||||
|
Timestamp int64 `json:"timestamp"` // Unix 时间戳(小时级别)
|
||||||
|
Inbound int64 `json:"inbound"` // 入站流量(字节)
|
||||||
|
Outbound int64 `json:"outbound"` // 出站流量(字节)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TrafficStore 流量存储接口
|
||||||
|
type TrafficStore interface {
|
||||||
|
AddTraffic(inbound, outbound int64) error
|
||||||
|
GetTotalTraffic() (inbound, outbound int64, err error)
|
||||||
|
Get24HourTraffic() (inbound, outbound int64, err error)
|
||||||
|
GetHourlyTraffic(hours int) ([]TrafficRecord, error)
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
|
|
||||||
@@ -80,6 +81,33 @@ func (s *SQLiteStore) init() error {
|
|||||||
// 迁移:添加 updated_at 列
|
// 迁移:添加 updated_at 列
|
||||||
s.db.Exec(`ALTER TABLE js_plugins ADD COLUMN updated_at DATETIME DEFAULT CURRENT_TIMESTAMP`)
|
s.db.Exec(`ALTER TABLE js_plugins ADD COLUMN updated_at DATETIME DEFAULT CURRENT_TIMESTAMP`)
|
||||||
|
|
||||||
|
// 创建流量统计表
|
||||||
|
_, err = s.db.Exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS traffic_stats (
|
||||||
|
hour_ts INTEGER PRIMARY KEY,
|
||||||
|
inbound INTEGER NOT NULL DEFAULT 0,
|
||||||
|
outbound INTEGER NOT NULL DEFAULT 0
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建总流量表
|
||||||
|
_, err = s.db.Exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS traffic_total (
|
||||||
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||||
|
inbound INTEGER NOT NULL DEFAULT 0,
|
||||||
|
outbound INTEGER NOT NULL DEFAULT 0
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化总流量记录
|
||||||
|
s.db.Exec(`INSERT OR IGNORE INTO traffic_total (id, inbound, outbound) VALUES (1, 0, 0)`)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,3 +343,82 @@ func (s *SQLiteStore) UpdateJSPluginConfig(name string, config map[string]string
|
|||||||
_, err := s.db.Exec(`UPDATE js_plugins SET config = ?, updated_at = CURRENT_TIMESTAMP WHERE name = ?`, string(configJSON), name)
|
_, err := s.db.Exec(`UPDATE js_plugins SET config = ?, updated_at = CURRENT_TIMESTAMP WHERE name = ?`, string(configJSON), name)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========== 流量统计方法 ==========
|
||||||
|
|
||||||
|
// getHourTimestamp 获取当前小时的时间戳
|
||||||
|
func getHourTimestamp() int64 {
|
||||||
|
now := time.Now()
|
||||||
|
return time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), 0, 0, 0, now.Location()).Unix()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTraffic 添加流量记录
|
||||||
|
func (s *SQLiteStore) AddTraffic(inbound, outbound int64) error {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
|
hourTs := getHourTimestamp()
|
||||||
|
|
||||||
|
// 更新小时统计
|
||||||
|
_, err := s.db.Exec(`
|
||||||
|
INSERT INTO traffic_stats (hour_ts, inbound, outbound) VALUES (?, ?, ?)
|
||||||
|
ON CONFLICT(hour_ts) DO UPDATE SET inbound = inbound + ?, outbound = outbound + ?
|
||||||
|
`, hourTs, inbound, outbound, inbound, outbound)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新总流量
|
||||||
|
_, err = s.db.Exec(`
|
||||||
|
UPDATE traffic_total SET inbound = inbound + ?, outbound = outbound + ? WHERE id = 1
|
||||||
|
`, inbound, outbound)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTotalTraffic 获取总流量
|
||||||
|
func (s *SQLiteStore) GetTotalTraffic() (inbound, outbound int64, err error) {
|
||||||
|
s.mu.RLock()
|
||||||
|
defer s.mu.RUnlock()
|
||||||
|
|
||||||
|
err = s.db.QueryRow(`SELECT inbound, outbound FROM traffic_total WHERE id = 1`).Scan(&inbound, &outbound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get24HourTraffic 获取24小时流量
|
||||||
|
func (s *SQLiteStore) Get24HourTraffic() (inbound, outbound int64, err error) {
|
||||||
|
s.mu.RLock()
|
||||||
|
defer s.mu.RUnlock()
|
||||||
|
|
||||||
|
cutoff := time.Now().Add(-24 * time.Hour).Unix()
|
||||||
|
err = s.db.QueryRow(`
|
||||||
|
SELECT COALESCE(SUM(inbound), 0), COALESCE(SUM(outbound), 0)
|
||||||
|
FROM traffic_stats WHERE hour_ts >= ?
|
||||||
|
`, cutoff).Scan(&inbound, &outbound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHourlyTraffic 获取每小时流量记录
|
||||||
|
func (s *SQLiteStore) GetHourlyTraffic(hours int) ([]TrafficRecord, error) {
|
||||||
|
s.mu.RLock()
|
||||||
|
defer s.mu.RUnlock()
|
||||||
|
|
||||||
|
cutoff := time.Now().Add(-time.Duration(hours) * time.Hour).Unix()
|
||||||
|
rows, err := s.db.Query(`
|
||||||
|
SELECT hour_ts, inbound, outbound FROM traffic_stats
|
||||||
|
WHERE hour_ts >= ? ORDER BY hour_ts ASC
|
||||||
|
`, cutoff)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var records []TrafficRecord
|
||||||
|
for rows.Next() {
|
||||||
|
var r TrafficRecord
|
||||||
|
if err := rows.Scan(&r.Timestamp, &r.Inbound, &r.Outbound); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
records = append(records, r)
|
||||||
|
}
|
||||||
|
return records, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ type ClientResponse struct {
|
|||||||
Online bool `json:"online" example:"true"`
|
Online bool `json:"online" example:"true"`
|
||||||
LastPing string `json:"last_ping,omitempty" example:"2025-01-02T10:30:00Z"`
|
LastPing string `json:"last_ping,omitempty" example:"2025-01-02T10:30:00Z"`
|
||||||
RemoteAddr string `json:"remote_addr,omitempty" example:"192.168.1.100:54321"`
|
RemoteAddr string `json:"remote_addr,omitempty" example:"192.168.1.100:54321"`
|
||||||
|
OS string `json:"os,omitempty" example:"linux"`
|
||||||
|
Arch string `json:"arch,omitempty" example:"amd64"`
|
||||||
|
Version string `json:"version,omitempty" example:"1.0.0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientListItem 客户端列表项
|
// ClientListItem 客户端列表项
|
||||||
@@ -41,6 +44,8 @@ type ClientListItem struct {
|
|||||||
LastPing string `json:"last_ping,omitempty"`
|
LastPing string `json:"last_ping,omitempty"`
|
||||||
RemoteAddr string `json:"remote_addr,omitempty"`
|
RemoteAddr string `json:"remote_addr,omitempty"`
|
||||||
RuleCount int `json:"rule_count" example:"3"`
|
RuleCount int `json:"rule_count" example:"3"`
|
||||||
|
OS string `json:"os,omitempty" example:"linux"`
|
||||||
|
Arch string `json:"arch,omitempty" example:"amd64"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallPluginsRequest 安装插件到客户端请求
|
// InstallPluginsRequest 安装插件到客户端请求
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package dto
|
|||||||
// UpdateServerConfigRequest 更新服务器配置请求
|
// UpdateServerConfigRequest 更新服务器配置请求
|
||||||
// @Description 更新服务器配置
|
// @Description 更新服务器配置
|
||||||
type UpdateServerConfigRequest struct {
|
type UpdateServerConfigRequest struct {
|
||||||
Server *ServerConfigPart `json:"server"`
|
Server *ServerConfigPart `json:"server"`
|
||||||
Web *WebConfigPart `json:"web"`
|
Web *WebConfigPart `json:"web"`
|
||||||
|
PluginStore *PluginStoreConfigPart `json:"plugin_store"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerConfigPart 服务器配置部分
|
// ServerConfigPart 服务器配置部分
|
||||||
@@ -21,7 +22,6 @@ type ServerConfigPart struct {
|
|||||||
// @Description Web 控制台配置
|
// @Description Web 控制台配置
|
||||||
type WebConfigPart struct {
|
type WebConfigPart struct {
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
BindAddr string `json:"bind_addr" binding:"omitempty"`
|
|
||||||
BindPort int `json:"bind_port" binding:"omitempty,min=1,max=65535"`
|
BindPort int `json:"bind_port" binding:"omitempty,min=1,max=65535"`
|
||||||
Username string `json:"username" binding:"omitempty,min=3,max=32"`
|
Username string `json:"username" binding:"omitempty,min=3,max=32"`
|
||||||
Password string `json:"password" binding:"omitempty,min=6,max=64"`
|
Password string `json:"password" binding:"omitempty,min=6,max=64"`
|
||||||
@@ -30,8 +30,9 @@ type WebConfigPart struct {
|
|||||||
// ServerConfigResponse 服务器配置响应
|
// ServerConfigResponse 服务器配置响应
|
||||||
// @Description 服务器配置信息
|
// @Description 服务器配置信息
|
||||||
type ServerConfigResponse struct {
|
type ServerConfigResponse struct {
|
||||||
Server ServerConfigInfo `json:"server"`
|
Server ServerConfigInfo `json:"server"`
|
||||||
Web WebConfigInfo `json:"web"`
|
Web WebConfigInfo `json:"web"`
|
||||||
|
PluginStore PluginStoreConfigInfo `json:"plugin_store"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerConfigInfo 服务器配置信息
|
// ServerConfigInfo 服务器配置信息
|
||||||
@@ -46,8 +47,17 @@ type ServerConfigInfo struct {
|
|||||||
// WebConfigInfo Web 配置信息
|
// WebConfigInfo Web 配置信息
|
||||||
type WebConfigInfo struct {
|
type WebConfigInfo struct {
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
BindAddr string `json:"bind_addr"`
|
|
||||||
BindPort int `json:"bind_port"`
|
BindPort int `json:"bind_port"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"` // 显示为 ****
|
Password string `json:"password"` // 显示为 ****
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PluginStoreConfigPart 插件商店配置部分
|
||||||
|
type PluginStoreConfigPart struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PluginStoreConfigInfo 插件商店配置信息
|
||||||
|
type PluginStoreConfigInfo struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ type VersionInfo struct {
|
|||||||
GitCommit string `json:"git_commit,omitempty"`
|
GitCommit string `json:"git_commit,omitempty"`
|
||||||
BuildTime string `json:"build_time,omitempty"`
|
BuildTime string `json:"build_time,omitempty"`
|
||||||
GoVersion string `json:"go_version,omitempty"`
|
GoVersion string `json:"go_version,omitempty"`
|
||||||
Platform string `json:"platform,omitempty"`
|
OS string `json:"os,omitempty"`
|
||||||
|
Arch string `json:"arch,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatusResponse 服务器状态响应
|
// StatusResponse 服务器状态响应
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ func (h *ClientHandler) List(c *gin.Context) {
|
|||||||
item.Online = status.Online
|
item.Online = status.Online
|
||||||
item.LastPing = status.LastPing
|
item.LastPing = status.LastPing
|
||||||
item.RemoteAddr = status.RemoteAddr
|
item.RemoteAddr = status.RemoteAddr
|
||||||
|
item.OS = status.OS
|
||||||
|
item.Arch = status.Arch
|
||||||
}
|
}
|
||||||
result = append(result, item)
|
result = append(result, item)
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,7 @@ func (h *ClientHandler) Get(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
online, lastPing, remoteAddr := h.app.GetServer().GetClientStatus(clientID)
|
online, lastPing, remoteAddr, clientOS, clientArch, clientVersion := h.app.GetServer().GetClientStatus(clientID)
|
||||||
|
|
||||||
// 复制插件列表
|
// 复制插件列表
|
||||||
plugins := make([]db.ClientPlugin, len(client.Plugins))
|
plugins := make([]db.ClientPlugin, len(client.Plugins))
|
||||||
@@ -151,6 +153,9 @@ func (h *ClientHandler) Get(c *gin.Context) {
|
|||||||
Online: online,
|
Online: online,
|
||||||
LastPing: lastPing,
|
LastPing: lastPing,
|
||||||
RemoteAddr: remoteAddr,
|
RemoteAddr: remoteAddr,
|
||||||
|
OS: clientOS,
|
||||||
|
Arch: clientArch,
|
||||||
|
Version: clientVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
Success(c, resp)
|
Success(c, resp)
|
||||||
@@ -237,7 +242,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)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
||||||
if !online {
|
if !online {
|
||||||
ClientNotOnline(c)
|
ClientNotOnline(c)
|
||||||
return
|
return
|
||||||
@@ -306,7 +311,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)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
||||||
if !online {
|
if !online {
|
||||||
ClientNotOnline(c)
|
ClientNotOnline(c)
|
||||||
return
|
return
|
||||||
@@ -446,6 +451,17 @@ func (h *ClientHandler) deleteClientPlugin(clientID, pluginID string) error {
|
|||||||
return h.app.GetClientStore().UpdateClient(client)
|
return h.app.GetClientStore().UpdateClient(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSystemStats 获取客户端系统状态
|
||||||
|
func (h *ClientHandler) GetSystemStats(c *gin.Context) {
|
||||||
|
clientID := c.Param("id")
|
||||||
|
stats, err := h.app.GetServer().GetClientSystemStats(clientID)
|
||||||
|
if err != nil {
|
||||||
|
ClientNotOnline(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Success(c, stats)
|
||||||
|
}
|
||||||
|
|
||||||
// validateClientID 验证客户端 ID 格式
|
// validateClientID 验证客户端 ID 格式
|
||||||
func validateClientID(id string) bool {
|
func validateClientID(id string) bool {
|
||||||
if len(id) < 1 || len(id) > 64 {
|
if len(id) < 1 || len(id) > 64 {
|
||||||
|
|||||||
@@ -42,12 +42,14 @@ func (h *ConfigHandler) Get(c *gin.Context) {
|
|||||||
HeartbeatTimeout: cfg.Server.HeartbeatTimeout,
|
HeartbeatTimeout: cfg.Server.HeartbeatTimeout,
|
||||||
},
|
},
|
||||||
Web: dto.WebConfigInfo{
|
Web: dto.WebConfigInfo{
|
||||||
Enabled: cfg.Web.Enabled,
|
Enabled: cfg.Server.Web.Enabled,
|
||||||
BindAddr: cfg.Web.BindAddr,
|
BindPort: cfg.Server.Web.BindPort,
|
||||||
BindPort: cfg.Web.BindPort,
|
Username: cfg.Server.Web.Username,
|
||||||
Username: cfg.Web.Username,
|
|
||||||
Password: "****",
|
Password: "****",
|
||||||
},
|
},
|
||||||
|
PluginStore: dto.PluginStoreConfigInfo{
|
||||||
|
URL: cfg.Server.PluginStore.URL,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Success(c, resp)
|
Success(c, resp)
|
||||||
@@ -93,15 +95,17 @@ func (h *ConfigHandler) Update(c *gin.Context) {
|
|||||||
|
|
||||||
// 更新 Web 配置
|
// 更新 Web 配置
|
||||||
if req.Web != nil {
|
if req.Web != nil {
|
||||||
cfg.Web.Enabled = req.Web.Enabled
|
cfg.Server.Web.Enabled = req.Web.Enabled
|
||||||
if req.Web.BindAddr != "" {
|
|
||||||
cfg.Web.BindAddr = req.Web.BindAddr
|
|
||||||
}
|
|
||||||
if req.Web.BindPort > 0 {
|
if req.Web.BindPort > 0 {
|
||||||
cfg.Web.BindPort = req.Web.BindPort
|
cfg.Server.Web.BindPort = req.Web.BindPort
|
||||||
}
|
}
|
||||||
cfg.Web.Username = req.Web.Username
|
cfg.Server.Web.Username = req.Web.Username
|
||||||
cfg.Web.Password = req.Web.Password
|
cfg.Server.Web.Password = req.Web.Password
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新 PluginStore 配置
|
||||||
|
if req.PluginStore != nil {
|
||||||
|
cfg.Server.PluginStore.URL = req.PluginStore.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.app.SaveConfig(); err != nil {
|
if err := h.app.SaveConfig(); err != nil {
|
||||||
|
|||||||
@@ -14,15 +14,19 @@ type AppInterface interface {
|
|||||||
GetConfigPath() string
|
GetConfigPath() string
|
||||||
SaveConfig() error
|
SaveConfig() error
|
||||||
GetJSPluginStore() db.JSPluginStore
|
GetJSPluginStore() db.JSPluginStore
|
||||||
|
GetTrafficStore() db.TrafficStore
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerInterface 服务端接口
|
// ServerInterface 服务端接口
|
||||||
type ServerInterface interface {
|
type ServerInterface interface {
|
||||||
GetClientStatus(clientID string) (online bool, lastPing string, remoteAddr string)
|
GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientOS, clientArch, clientVersion string)
|
||||||
GetAllClientStatus() map[string]struct {
|
GetAllClientStatus() map[string]struct {
|
||||||
Online bool
|
Online bool
|
||||||
LastPing string
|
LastPing string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
|
OS string
|
||||||
|
Arch string
|
||||||
|
Version string
|
||||||
}
|
}
|
||||||
ReloadConfig() error
|
ReloadConfig() error
|
||||||
GetBindAddr() string
|
GetBindAddr() string
|
||||||
@@ -54,6 +58,8 @@ type ServerInterface interface {
|
|||||||
IsPortAvailable(port int, excludeClientID string) bool
|
IsPortAvailable(port int, excludeClientID string) bool
|
||||||
// 插件 API 代理
|
// 插件 API 代理
|
||||||
ProxyPluginAPIRequest(clientID string, req protocol.PluginAPIRequest) (*protocol.PluginAPIResponse, error)
|
ProxyPluginAPIRequest(clientID string, req protocol.PluginAPIRequest) (*protocol.PluginAPIResponse, error)
|
||||||
|
// 系统状态
|
||||||
|
GetClientSystemStats(clientID string) (*protocol.SystemStatsResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigField 配置字段
|
// ConfigField 配置字段
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ func (h *JSPluginHandler) PushToClient(c *gin.Context) {
|
|||||||
c.ShouldBindJSON(&pushReq) // 忽略错误,允许空请求体
|
c.ShouldBindJSON(&pushReq) // 忽略错误,允许空请求体
|
||||||
|
|
||||||
// 检查客户端是否在线
|
// 检查客户端是否在线
|
||||||
online, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
||||||
if !online {
|
if !online {
|
||||||
ClientNotOnline(c)
|
ClientNotOnline(c)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (h *LogHandler) StreamLogs(c *gin.Context) {
|
|||||||
clientID := c.Param("id")
|
clientID := c.Param("id")
|
||||||
|
|
||||||
// 检查客户端是否在线
|
// 检查客户端是否在线
|
||||||
online, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
||||||
if !online {
|
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
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ func (h *PluginHandler) UpdateClientConfig(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果客户端在线,同步配置
|
// 如果客户端在线,同步配置
|
||||||
online, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
||||||
if online {
|
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())
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (h *PluginAPIHandler) ProxyRequest(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查客户端是否在线
|
// 检查客户端是否在线
|
||||||
online, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(clientID)
|
||||||
if !online {
|
if !online {
|
||||||
ClientNotOnline(c)
|
ClientNotOnline(c)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func NewStoreHandler(app AppInterface) *StoreHandler {
|
|||||||
// @Router /api/store/plugins [get]
|
// @Router /api/store/plugins [get]
|
||||||
func (h *StoreHandler) ListPlugins(c *gin.Context) {
|
func (h *StoreHandler) ListPlugins(c *gin.Context) {
|
||||||
cfg := h.app.GetConfig()
|
cfg := h.app.GetConfig()
|
||||||
storeURL := cfg.PluginStore.GetPluginStoreURL()
|
storeURL := cfg.Server.PluginStore.GetPluginStoreURL()
|
||||||
|
|
||||||
// 从远程 URL 获取插件列表
|
// 从远程 URL 获取插件列表
|
||||||
client := &http.Client{Timeout: 10 * time.Second}
|
client := &http.Client{Timeout: 10 * time.Second}
|
||||||
@@ -82,7 +82,7 @@ func (h *StoreHandler) Install(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查客户端是否在线
|
// 检查客户端是否在线
|
||||||
online, _, _ := h.app.GetServer().GetClientStatus(req.ClientID)
|
online, _, _, _, _, _ := h.app.GetServer().GetClientStatus(req.ClientID)
|
||||||
if !online {
|
if !online {
|
||||||
ClientNotOnline(c)
|
ClientNotOnline(c)
|
||||||
return
|
return
|
||||||
|
|||||||
76
internal/server/router/handler/traffic.go
Normal file
76
internal/server/router/handler/traffic.go
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TrafficHandler 流量统计处理器
|
||||||
|
type TrafficHandler struct {
|
||||||
|
app AppInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTrafficHandler 创建流量统计处理器
|
||||||
|
func NewTrafficHandler(app AppInterface) *TrafficHandler {
|
||||||
|
return &TrafficHandler{app: app}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStats 获取流量统计
|
||||||
|
// @Summary 获取流量统计
|
||||||
|
// @Description 获取24小时和总流量统计
|
||||||
|
// @Tags 流量
|
||||||
|
// @Produce json
|
||||||
|
// @Security Bearer
|
||||||
|
// @Success 200 {object} Response
|
||||||
|
// @Router /api/traffic/stats [get]
|
||||||
|
func (h *TrafficHandler) GetStats(c *gin.Context) {
|
||||||
|
store := h.app.GetTrafficStore()
|
||||||
|
|
||||||
|
// 获取24小时流量
|
||||||
|
in24h, out24h, err := store.Get24HourTraffic()
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取总流量
|
||||||
|
inTotal, outTotal, err := store.GetTotalTraffic()
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Success(c, gin.H{
|
||||||
|
"traffic_24h": gin.H{
|
||||||
|
"inbound": in24h,
|
||||||
|
"outbound": out24h,
|
||||||
|
},
|
||||||
|
"traffic_total": gin.H{
|
||||||
|
"inbound": inTotal,
|
||||||
|
"outbound": outTotal,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHourly 获取每小时流量
|
||||||
|
// @Summary 获取每小时流量
|
||||||
|
// @Description 获取最近N小时的流量记录
|
||||||
|
// @Tags 流量
|
||||||
|
// @Produce json
|
||||||
|
// @Security Bearer
|
||||||
|
// @Param hours query int false "小时数" default(24)
|
||||||
|
// @Success 200 {object} Response
|
||||||
|
// @Router /api/traffic/hourly [get]
|
||||||
|
func (h *TrafficHandler) GetHourly(c *gin.Context) {
|
||||||
|
hours := 24
|
||||||
|
|
||||||
|
store := h.app.GetTrafficStore()
|
||||||
|
records, err := store.GetHourlyTraffic(hours)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(c, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Success(c, gin.H{
|
||||||
|
"records": records,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -127,6 +127,7 @@ func getVersionInfo() dto.VersionInfo {
|
|||||||
GitCommit: info.GitCommit,
|
GitCommit: info.GitCommit,
|
||||||
BuildTime: info.BuildTime,
|
BuildTime: info.BuildTime,
|
||||||
GoVersion: info.GoVersion,
|
GoVersion: info.GoVersion,
|
||||||
Platform: info.OS + "/" + info.Arch,
|
OS: info.OS,
|
||||||
|
Arch: info.Arch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ func (r *GinRouter) SetupRoutes(app handler.AppInterface, jwtAuth *auth.JWTAuth,
|
|||||||
api.POST("/client/:id/restart", clientHandler.Restart)
|
api.POST("/client/:id/restart", clientHandler.Restart)
|
||||||
api.POST("/client/:id/install-plugins", clientHandler.InstallPlugins)
|
api.POST("/client/:id/install-plugins", clientHandler.InstallPlugins)
|
||||||
api.POST("/client/:id/plugin/:pluginID/:action", clientHandler.PluginAction)
|
api.POST("/client/:id/plugin/:pluginID/:action", clientHandler.PluginAction)
|
||||||
|
api.GET("/client/:id/system-stats", clientHandler.GetSystemStats)
|
||||||
|
|
||||||
// 配置管理
|
// 配置管理
|
||||||
configHandler := handler.NewConfigHandler(app)
|
configHandler := handler.NewConfigHandler(app)
|
||||||
@@ -110,6 +111,11 @@ func (r *GinRouter) SetupRoutes(app handler.AppInterface, jwtAuth *auth.JWTAuth,
|
|||||||
logHandler := handler.NewLogHandler(app)
|
logHandler := handler.NewLogHandler(app)
|
||||||
api.GET("/client/:id/logs", logHandler.StreamLogs)
|
api.GET("/client/:id/logs", logHandler.StreamLogs)
|
||||||
|
|
||||||
|
// 流量统计
|
||||||
|
trafficHandler := handler.NewTrafficHandler(app)
|
||||||
|
api.GET("/traffic/stats", trafficHandler.GetStats)
|
||||||
|
api.GET("/traffic/hourly", trafficHandler.GetHourly)
|
||||||
|
|
||||||
// 插件 API 代理 (通过 Web API 访问客户端插件)
|
// 插件 API 代理 (通过 Web API 访问客户端插件)
|
||||||
pluginAPIHandler := handler.NewPluginAPIHandler(app)
|
pluginAPIHandler := handler.NewPluginAPIHandler(app)
|
||||||
api.Any("/client/:id/plugin-api/:pluginID/*route", pluginAPIHandler.ProxyRequest)
|
api.Any("/client/:id/plugin-api/:pluginID/*route", pluginAPIHandler.ProxyRequest)
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ type JSPluginEntry struct {
|
|||||||
type ClientSession struct {
|
type ClientSession struct {
|
||||||
ID string
|
ID string
|
||||||
RemoteAddr string // 客户端 IP 地址
|
RemoteAddr string // 客户端 IP 地址
|
||||||
|
OS string // 客户端操作系统
|
||||||
|
Arch string // 客户端架构
|
||||||
|
Version string // 客户端版本
|
||||||
Session *yamux.Session
|
Session *yamux.Session
|
||||||
Rules []protocol.ProxyRule
|
Rules []protocol.ProxyRule
|
||||||
Listeners map[int]net.Listener
|
Listeners map[int]net.Listener
|
||||||
@@ -287,11 +290,11 @@ func (s *Server) handleConnection(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
security.LogAuthSuccess(clientIP, clientID)
|
security.LogAuthSuccess(clientIP, clientID)
|
||||||
s.setupClientSession(conn, clientID, rules)
|
s.setupClientSession(conn, clientID, authReq.OS, authReq.Arch, authReq.Version, rules)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setupClientSession 建立客户端会话
|
// setupClientSession 建立客户端会话
|
||||||
func (s *Server) setupClientSession(conn net.Conn, clientID string, rules []protocol.ProxyRule) {
|
func (s *Server) setupClientSession(conn net.Conn, clientID, 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)
|
||||||
@@ -307,6 +310,9 @@ func (s *Server) setupClientSession(conn net.Conn, clientID string, rules []prot
|
|||||||
cs := &ClientSession{
|
cs := &ClientSession{
|
||||||
ID: clientID,
|
ID: clientID,
|
||||||
RemoteAddr: remoteAddr,
|
RemoteAddr: remoteAddr,
|
||||||
|
OS: clientOS,
|
||||||
|
Arch: clientArch,
|
||||||
|
Version: clientVersion,
|
||||||
Session: session,
|
Session: session,
|
||||||
Rules: rules,
|
Rules: rules,
|
||||||
Listeners: make(map[int]net.Listener),
|
Listeners: make(map[int]net.Listener),
|
||||||
@@ -342,7 +348,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 {
|
||||||
@@ -355,7 +361,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 注册客户端
|
||||||
@@ -567,16 +586,16 @@ func (s *Server) sendHeartbeat(cs *ClientSession) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetClientStatus 获取客户端状态
|
// GetClientStatus 获取客户端状态
|
||||||
func (s *Server) GetClientStatus(clientID string) (online bool, lastPing string, remoteAddr string) {
|
func (s *Server) GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, 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
|
return true, cs.LastPing.Format(time.RFC3339), cs.RemoteAddr, cs.OS, cs.Arch, cs.Version
|
||||||
}
|
}
|
||||||
return false, "", ""
|
return false, "", "", "", "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetClientPluginStatus 获取客户端插件运行状态
|
// GetClientPluginStatus 获取客户端插件运行状态
|
||||||
@@ -627,6 +646,9 @@ func (s *Server) GetAllClientStatus() map[string]struct {
|
|||||||
Online bool
|
Online bool
|
||||||
LastPing string
|
LastPing string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
|
OS string
|
||||||
|
Arch string
|
||||||
|
Version string
|
||||||
} {
|
} {
|
||||||
// 先复制客户端引用,避免嵌套锁
|
// 先复制客户端引用,避免嵌套锁
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
@@ -640,6 +662,9 @@ func (s *Server) GetAllClientStatus() map[string]struct {
|
|||||||
Online bool
|
Online bool
|
||||||
LastPing string
|
LastPing string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
|
OS string
|
||||||
|
Arch string
|
||||||
|
Version string
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, cs := range clients {
|
for _, cs := range clients {
|
||||||
@@ -648,10 +673,16 @@ func (s *Server) GetAllClientStatus() map[string]struct {
|
|||||||
Online bool
|
Online bool
|
||||||
LastPing string
|
LastPing string
|
||||||
RemoteAddr string
|
RemoteAddr string
|
||||||
|
OS string
|
||||||
|
Arch string
|
||||||
|
Version string
|
||||||
}{
|
}{
|
||||||
Online: true,
|
Online: true,
|
||||||
LastPing: cs.LastPing.Format(time.RFC3339),
|
LastPing: cs.LastPing.Format(time.RFC3339),
|
||||||
RemoteAddr: cs.RemoteAddr,
|
RemoteAddr: cs.RemoteAddr,
|
||||||
|
OS: cs.OS,
|
||||||
|
Arch: cs.Arch,
|
||||||
|
Version: cs.Version,
|
||||||
}
|
}
|
||||||
cs.mu.Unlock()
|
cs.mu.Unlock()
|
||||||
}
|
}
|
||||||
@@ -1857,3 +1888,46 @@ func (s *Server) StopClientLogStream(sessionID string) {
|
|||||||
func boolPtr(b bool) *bool {
|
func boolPtr(b bool) *bool {
|
||||||
return &b
|
return &b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetClientSystemStats 获取客户端系统状态
|
||||||
|
func (s *Server) GetClientSystemStats(clientID string) (*protocol.SystemStatsResponse, error) {
|
||||||
|
s.mu.RLock()
|
||||||
|
cs, ok := s.clients[clientID]
|
||||||
|
s.mu.RUnlock()
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("client %s not online", clientID)
|
||||||
|
}
|
||||||
|
|
||||||
|
stream, err := cs.Session.Open()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer stream.Close()
|
||||||
|
|
||||||
|
// 设置超时
|
||||||
|
stream.SetDeadline(time.Now().Add(10 * time.Second))
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
msg, _ := protocol.NewMessage(protocol.MsgTypeSystemStatsRequest, nil)
|
||||||
|
if err := protocol.WriteMessage(stream, msg); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取响应
|
||||||
|
resp, err := protocol.ReadMessage(stream)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.Type != protocol.MsgTypeSystemStatsResponse {
|
||||||
|
return nil, fmt.Errorf("unexpected response type: %d", resp.Type)
|
||||||
|
}
|
||||||
|
|
||||||
|
var stats protocol.SystemStatsResponse
|
||||||
|
if err := resp.ParsePayload(&stats); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &stats, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ const (
|
|||||||
// 插件 API 路由消息
|
// 插件 API 路由消息
|
||||||
MsgTypePluginAPIRequest uint8 = 90 // 插件 API 请求
|
MsgTypePluginAPIRequest uint8 = 90 // 插件 API 请求
|
||||||
MsgTypePluginAPIResponse uint8 = 91 // 插件 API 响应
|
MsgTypePluginAPIResponse uint8 = 91 // 插件 API 响应
|
||||||
|
|
||||||
|
// 系统状态消息
|
||||||
|
MsgTypeSystemStatsRequest uint8 = 100 // 请求系统状态
|
||||||
|
MsgTypeSystemStatsResponse uint8 = 101 // 系统状态响应
|
||||||
)
|
)
|
||||||
|
|
||||||
// Message 基础消息结构
|
// Message 基础消息结构
|
||||||
@@ -83,6 +87,9 @@ 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"`
|
||||||
|
OS string `json:"os,omitempty"` // 客户端操作系统
|
||||||
|
Arch string `json:"arch,omitempty"` // 客户端架构
|
||||||
|
Version string `json:"version,omitempty"` // 客户端版本
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthResponse 认证响应
|
// AuthResponse 认证响应
|
||||||
@@ -439,3 +446,17 @@ func NewMessage(msgType uint8, data interface{}) (*Message, error) {
|
|||||||
func (m *Message) ParsePayload(v interface{}) error {
|
func (m *Message) ParsePayload(v interface{}) error {
|
||||||
return json.Unmarshal(m.Payload, v)
|
return json.Unmarshal(m.Payload, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SystemStatsRequest 系统状态请求
|
||||||
|
type SystemStatsRequest struct{}
|
||||||
|
|
||||||
|
// SystemStatsResponse 系统状态响应
|
||||||
|
type SystemStatsResponse struct {
|
||||||
|
CPUUsage float64 `json:"cpu_usage"` // CPU 使用率 (0-100)
|
||||||
|
MemoryTotal uint64 `json:"memory_total"` // 总内存 (字节)
|
||||||
|
MemoryUsed uint64 `json:"memory_used"` // 已用内存 (字节)
|
||||||
|
MemoryUsage float64 `json:"memory_usage"` // 内存使用率 (0-100)
|
||||||
|
DiskTotal uint64 `json:"disk_total"` // 总磁盘 (字节)
|
||||||
|
DiskUsed uint64 `json:"disk_used"` // 已用磁盘 (字节)
|
||||||
|
DiskUsage float64 `json:"disk_usage"` // 磁盘使用率 (0-100)
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,10 +4,17 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bufferSize = 32 * 1024
|
const bufferSize = 32 * 1024
|
||||||
|
|
||||||
|
// TrafficStats 流量统计
|
||||||
|
type TrafficStats struct {
|
||||||
|
Inbound int64
|
||||||
|
Outbound int64
|
||||||
|
}
|
||||||
|
|
||||||
// Relay 双向数据转发
|
// Relay 双向数据转发
|
||||||
func Relay(c1, c2 net.Conn) {
|
func Relay(c1, c2 net.Conn) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@@ -17,7 +24,6 @@ func Relay(c1, c2 net.Conn) {
|
|||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
buf := make([]byte, bufferSize)
|
buf := make([]byte, bufferSize)
|
||||||
_, _ = io.CopyBuffer(dst, src, buf)
|
_, _ = io.CopyBuffer(dst, src, buf)
|
||||||
// 关闭写端,通知对方数据传输完成
|
|
||||||
if tc, ok := dst.(*net.TCPConn); ok {
|
if tc, ok := dst.(*net.TCPConn); ok {
|
||||||
tc.CloseWrite()
|
tc.CloseWrite()
|
||||||
}
|
}
|
||||||
@@ -27,3 +33,36 @@ func Relay(c1, c2 net.Conn) {
|
|||||||
go copyConn(c2, c1)
|
go copyConn(c2, c1)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RelayWithStats 带流量统计的双向数据转发
|
||||||
|
func RelayWithStats(c1, c2 net.Conn, onStats func(in, out int64)) {
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
var inbound, outbound int64
|
||||||
|
wg.Add(2)
|
||||||
|
|
||||||
|
copyWithCount := func(dst, src net.Conn, counter *int64) {
|
||||||
|
defer wg.Done()
|
||||||
|
buf := make([]byte, bufferSize)
|
||||||
|
for {
|
||||||
|
n, err := src.Read(buf)
|
||||||
|
if n > 0 {
|
||||||
|
atomic.AddInt64(counter, int64(n))
|
||||||
|
dst.Write(buf[:n])
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tc, ok := dst.(*net.TCPConn); ok {
|
||||||
|
tc.CloseWrite()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
go copyWithCount(c1, c2, &inbound)
|
||||||
|
go copyWithCount(c2, c1, &outbound)
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
if onStats != nil {
|
||||||
|
onStats(inbound, outbound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
61
pkg/utils/sysinfo.go
Normal file
61
pkg/utils/sysinfo.go
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
|
"github.com/shirou/gopsutil/v3/mem"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SystemStats 系统状态信息
|
||||||
|
type SystemStats struct {
|
||||||
|
CPUUsage float64 `json:"cpu_usage"`
|
||||||
|
MemoryTotal uint64 `json:"memory_total"`
|
||||||
|
MemoryUsed uint64 `json:"memory_used"`
|
||||||
|
MemoryUsage float64 `json:"memory_usage"`
|
||||||
|
DiskTotal uint64 `json:"disk_total"`
|
||||||
|
DiskUsed uint64 `json:"disk_used"`
|
||||||
|
DiskUsage float64 `json:"disk_usage"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSystemStats 获取系统状态信息
|
||||||
|
func GetSystemStats() (*SystemStats, error) {
|
||||||
|
stats := &SystemStats{}
|
||||||
|
|
||||||
|
// CPU 使用率
|
||||||
|
cpuPercent, err := cpu.Percent(time.Second, false)
|
||||||
|
if err == nil && len(cpuPercent) > 0 {
|
||||||
|
stats.CPUUsage = cpuPercent[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内存信息
|
||||||
|
memInfo, err := mem.VirtualMemory()
|
||||||
|
if err == nil {
|
||||||
|
stats.MemoryTotal = memInfo.Total
|
||||||
|
stats.MemoryUsed = memInfo.Used
|
||||||
|
stats.MemoryUsage = memInfo.UsedPercent
|
||||||
|
}
|
||||||
|
|
||||||
|
// 磁盘信息 - 获取根目录或当前工作目录所在磁盘
|
||||||
|
diskPath := "/"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// Windows 使用当前工作目录所在盘符
|
||||||
|
if wd, err := os.Getwd(); err == nil && len(wd) >= 2 {
|
||||||
|
diskPath = wd[:2] + "\\"
|
||||||
|
} else {
|
||||||
|
diskPath = "C:\\"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diskInfo, err := disk.Usage(diskPath)
|
||||||
|
if err == nil {
|
||||||
|
stats.DiskTotal = diskInfo.Total
|
||||||
|
stats.DiskUsed = diskInfo.Used
|
||||||
|
stats.DiskUsage = diskInfo.UsedPercent
|
||||||
|
}
|
||||||
|
|
||||||
|
return stats, nil
|
||||||
|
}
|
||||||
@@ -12,7 +12,26 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 版本信息
|
// 版本信息
|
||||||
const Version = "1.0.0"
|
var Version = "1.0.0"
|
||||||
|
var GitCommit = ""
|
||||||
|
var BuildTime = ""
|
||||||
|
|
||||||
|
// SetVersion 设置版本号(由 main 包在初始化时调用)
|
||||||
|
func SetVersion(v string) {
|
||||||
|
if v != "" {
|
||||||
|
Version = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBuildInfo 设置构建信息(由 main 包在初始化时调用)
|
||||||
|
func SetBuildInfo(gitCommit, buildTime string) {
|
||||||
|
if gitCommit != "" {
|
||||||
|
GitCommit = gitCommit
|
||||||
|
}
|
||||||
|
if buildTime != "" {
|
||||||
|
BuildTime = buildTime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 仓库信息
|
// 仓库信息
|
||||||
const (
|
const (
|
||||||
@@ -36,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,
|
||||||
|
|||||||
4
web/components.d.ts
vendored
4
web/components.d.ts
vendored
@@ -11,7 +11,11 @@ export {}
|
|||||||
/* prettier-ignore */
|
/* prettier-ignore */
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
GlassModal: typeof import('./src/components/GlassModal.vue')['default']
|
||||||
|
GlassSwitch: typeof import('./src/components/GlassSwitch.vue')['default']
|
||||||
|
GlassTag: typeof import('./src/components/GlassTag.vue')['default']
|
||||||
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
|
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
|
||||||
|
InlineLogPanel: typeof import('./src/components/InlineLogPanel.vue')['default']
|
||||||
LogViewer: typeof import('./src/components/LogViewer.vue')['default']
|
LogViewer: typeof import('./src/components/LogViewer.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
|
|||||||
1709
web/package-lock.json
generated
1709
web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,17 +11,18 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vicons/ionicons5": "^0.13.0",
|
"@vicons/ionicons5": "^0.13.0",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"naive-ui": "^2.43.2",
|
|
||||||
"vue": "^3.5.24",
|
"vue": "^3.5.24",
|
||||||
"vue-router": "^4.6.4"
|
"vue-router": "^4.6.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@tailwindcss/postcss": "^4.1.18",
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
|
"autoprefixer": "^10.4.23",
|
||||||
|
"postcss": "^8.5.6",
|
||||||
|
"tailwindcss": "^4.1.18",
|
||||||
"typescript": "~5.9.3",
|
"typescript": "~5.9.3",
|
||||||
"unplugin-auto-import": "^20.3.0",
|
|
||||||
"unplugin-vue-components": "^30.0.0",
|
|
||||||
"vite": "^7.2.4",
|
"vite": "^7.2.4",
|
||||||
"vue-tsc": "^3.1.4"
|
"vue-tsc": "^3.1.4"
|
||||||
}
|
}
|
||||||
|
|||||||
5
web/postcss.config.js
Normal file
5
web/postcss.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
'@tailwindcss/postcss': {},
|
||||||
|
},
|
||||||
|
}
|
||||||
856
web/src/App.vue
856
web/src/App.vue
@@ -1,48 +1,46 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed, h, watch } from 'vue'
|
import { ref, onMounted, computed, watch } from 'vue'
|
||||||
import { RouterView, useRouter, useRoute } from 'vue-router'
|
import { RouterView, useRouter, useRoute } from 'vue-router'
|
||||||
import {
|
import {
|
||||||
NLayout, NLayoutHeader, NLayoutContent, NLayoutSider, NMenu,
|
HomeOutline, DesktopOutline, SettingsOutline,
|
||||||
NButton, NIcon, NConfigProvider, NMessageProvider,
|
PersonCircleOutline, LogOutOutline, LogoGithub, ServerOutline, CheckmarkCircleOutline, ArrowUpCircleOutline, CloseOutline,
|
||||||
NDialogProvider, NGlobalStyle, NDropdown, type GlobalThemeOverrides
|
SunnyOutline, MoonOutline, ContrastOutline
|
||||||
} from 'naive-ui'
|
|
||||||
import {
|
|
||||||
HomeOutline, ExtensionPuzzleOutline, LogOutOutline,
|
|
||||||
ServerOutline, MenuOutline, PersonCircleOutline
|
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
import type { MenuOption } from 'naive-ui'
|
import { getServerStatus, getVersionInfo, checkServerUpdate, applyServerUpdate, removeToken, getToken, type UpdateInfo } from './api'
|
||||||
import { getServerStatus, removeToken, getToken } from './api'
|
import { useToast } from './composables/useToast'
|
||||||
|
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 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 collapsed = ref(false)
|
const version = ref('')
|
||||||
|
const showUserMenu = ref(false)
|
||||||
|
const updateInfo = ref<UpdateInfo | null>(null)
|
||||||
|
const showUpdateModal = ref(false)
|
||||||
|
const updatingServer = ref(false)
|
||||||
|
|
||||||
const isLoginPage = computed(() => route.path === '/login')
|
const isLoginPage = computed(() => route.path === '/login')
|
||||||
|
|
||||||
const menuOptions: MenuOption[] = [
|
const navItems = [
|
||||||
{
|
{ key: 'home', label: '首页', icon: HomeOutline, path: '/' },
|
||||||
label: 'Dashboard',
|
{ key: 'clients', label: '客户端', icon: DesktopOutline, path: '/clients' },
|
||||||
key: '/',
|
{ key: 'settings', label: '设置', icon: SettingsOutline, path: '/settings' }
|
||||||
icon: () => h(NIcon, null, { default: () => h(HomeOutline) })
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Plugins Store',
|
|
||||||
key: '/plugins',
|
|
||||||
icon: () => h(NIcon, null, { default: () => h(ExtensionPuzzleOutline) })
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const activeKey = computed(() => {
|
const activeNav = computed(() => {
|
||||||
if (route.path.startsWith('/client/')) return '/'
|
const path = route.path
|
||||||
return route.path
|
if (path === '/' || path === '/home') return 'home'
|
||||||
|
if (path === '/clients' || path.startsWith('/client/')) return 'clients'
|
||||||
|
if (path === '/settings') return 'settings'
|
||||||
|
return 'home'
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleMenuUpdate = (key: string) => {
|
|
||||||
router.push(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchServerStatus = async () => {
|
const fetchServerStatus = async () => {
|
||||||
if (isLoginPage.value || !getToken()) return
|
if (isLoginPage.value || !getToken()) return
|
||||||
try {
|
try {
|
||||||
@@ -54,14 +52,38 @@ const fetchServerStatus = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fetchVersion = async () => {
|
||||||
|
if (isLoginPage.value || !getToken()) return
|
||||||
|
try {
|
||||||
|
const { data } = await getVersionInfo()
|
||||||
|
version.value = data.version || ''
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to get version', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkUpdate = async () => {
|
||||||
|
if (isLoginPage.value || !getToken()) return
|
||||||
|
try {
|
||||||
|
const { data } = await checkServerUpdate()
|
||||||
|
updateInfo.value = data
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to check update', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => route.path, (newPath, oldPath) => {
|
watch(() => route.path, (newPath, oldPath) => {
|
||||||
if (oldPath === '/login' && newPath !== '/login') {
|
if (oldPath === '/login' && newPath !== '/login') {
|
||||||
fetchServerStatus()
|
fetchServerStatus()
|
||||||
|
fetchVersion()
|
||||||
|
checkUpdate()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchServerStatus()
|
fetchServerStatus()
|
||||||
|
fetchVersion()
|
||||||
|
checkUpdate()
|
||||||
})
|
})
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
@@ -69,173 +91,679 @@ const logout = () => {
|
|||||||
router.push('/login')
|
router.push('/login')
|
||||||
}
|
}
|
||||||
|
|
||||||
// User dropdown menu options
|
const toggleUserMenu = () => {
|
||||||
const userDropdownOptions = [
|
showUserMenu.value = !showUserMenu.value
|
||||||
{
|
}
|
||||||
label: '退出登录',
|
|
||||||
key: 'logout',
|
|
||||||
icon: () => h(NIcon, null, { default: () => h(LogOutOutline) })
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const handleUserDropdown = (key: string) => {
|
const toggleThemeMenu = () => {
|
||||||
if (key === 'logout') {
|
showThemeMenu.value = !showThemeMenu.value
|
||||||
logout()
|
}
|
||||||
|
|
||||||
|
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 = () => {
|
||||||
|
if (updateInfo.value && updateInfo.value.available) {
|
||||||
|
showUpdateModal.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Theme Overrides
|
const formatBytes = (bytes: number): string => {
|
||||||
const themeOverrides: GlobalThemeOverrides = {
|
if (bytes === 0) return '0 B'
|
||||||
common: {
|
const k = 1024
|
||||||
primaryColor: '#18a058',
|
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||||
primaryColorHover: '#36ad6a',
|
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||||
primaryColorPressed: '#0c7a43',
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
||||||
},
|
}
|
||||||
Layout: {
|
|
||||||
siderColor: '#f7fcf9',
|
const handleApplyServerUpdate = () => {
|
||||||
headerColor: '#ffffff'
|
if (!updateInfo.value?.download_url) {
|
||||||
|
message.error('没有可用的下载链接')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialog.warning({
|
||||||
|
title: '确认更新服务端',
|
||||||
|
content: `即将更新服务端到 ${updateInfo.value.latest},更新后服务器将自动重启。确定要继续吗?`,
|
||||||
|
positiveText: '更新并重启',
|
||||||
|
negativeText: '取消',
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
updatingServer.value = true
|
||||||
|
try {
|
||||||
|
await applyServerUpdate(updateInfo.value!.download_url)
|
||||||
|
message.success('更新已开始,服务器将在几秒后重启')
|
||||||
|
showUpdateModal.value = false
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload()
|
||||||
|
}, 5000)
|
||||||
|
} catch (e: any) {
|
||||||
|
message.error(e.response?.data || '更新失败')
|
||||||
|
updatingServer.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-config-provider :theme-overrides="themeOverrides">
|
<div v-if="!isLoginPage" class="app-layout">
|
||||||
<n-global-style />
|
<!-- Header -->
|
||||||
<n-dialog-provider>
|
<header class="app-header">
|
||||||
<n-message-provider>
|
<div class="header-left">
|
||||||
<n-layout v-if="!isLoginPage" class="main-layout" has-sider position="absolute">
|
<span class="logo">GoTunnel</span>
|
||||||
<n-layout-sider
|
</div>
|
||||||
bordered
|
<nav class="header-nav">
|
||||||
collapse-mode="width"
|
<router-link
|
||||||
:collapsed-width="64"
|
v-for="item in navItems"
|
||||||
:width="240"
|
:key="item.key"
|
||||||
:collapsed="collapsed"
|
:to="item.path"
|
||||||
show-trigger
|
class="nav-item"
|
||||||
@collapse="collapsed = true"
|
:class="{ active: activeNav === item.key }"
|
||||||
@expand="collapsed = false"
|
>
|
||||||
style="background: #f9fafb;"
|
<component :is="item.icon" class="nav-icon" />
|
||||||
>
|
<span>{{ item.label }}</span>
|
||||||
<div class="logo-container">
|
</router-link>
|
||||||
<n-icon size="32" color="#18a058"><ServerOutline /></n-icon>
|
</nav>
|
||||||
<span v-if="!collapsed" class="logo-text">GoTunnel</span>
|
<div class="header-right">
|
||||||
</div>
|
<!-- Theme Switcher -->
|
||||||
<n-menu
|
<div class="theme-menu" @click="toggleThemeMenu">
|
||||||
:collapsed="collapsed"
|
<component :is="themeIcon" class="theme-icon" />
|
||||||
:collapsed-width="64"
|
<div v-if="showThemeMenu" class="theme-dropdown" @click.stop>
|
||||||
:collapsed-icon-size="22"
|
<button class="dropdown-item" :class="{ active: themeMode === 'light' }" @click="selectTheme('light')">
|
||||||
:options="menuOptions"
|
<SunnyOutline class="dropdown-icon" />
|
||||||
:value="activeKey"
|
<span>浅色</span>
|
||||||
@update:value="handleMenuUpdate"
|
</button>
|
||||||
/>
|
<button class="dropdown-item" :class="{ active: themeMode === 'dark' }" @click="selectTheme('dark')">
|
||||||
<div v-if="!collapsed" class="server-status-card">
|
<MoonOutline class="dropdown-icon" />
|
||||||
<div class="status-item">
|
<span>深色</span>
|
||||||
<span class="label">Server:</span>
|
</button>
|
||||||
<span class="value">{{ serverInfo.bind_addr }}:{{ serverInfo.bind_port }}</span>
|
<button class="dropdown-item" :class="{ active: themeMode === 'auto' }" @click="selectTheme('auto')">
|
||||||
</div>
|
<ContrastOutline class="dropdown-icon" />
|
||||||
<div class="status-item">
|
<span>自动</span>
|
||||||
<span class="label">Clients:</span>
|
</button>
|
||||||
<span class="value">{{ clientCount }}</span>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- User Menu -->
|
||||||
</n-layout-sider>
|
<div class="user-menu" @click="toggleUserMenu">
|
||||||
|
<PersonCircleOutline class="user-icon" />
|
||||||
|
<div v-if="showUserMenu" class="user-dropdown" @click.stop>
|
||||||
|
<button class="dropdown-item" @click="logout">
|
||||||
|
<LogOutOutline class="dropdown-icon" />
|
||||||
|
<span>退出登录</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
<n-layout>
|
<!-- Main Content -->
|
||||||
<n-layout-header bordered class="header">
|
<main class="main-content">
|
||||||
<div class="header-content">
|
<RouterView />
|
||||||
<n-button quaternary circle size="large" @click="collapsed = !collapsed" class="mobile-toggle">
|
</main>
|
||||||
<template #icon><n-icon><MenuOutline /></n-icon></template>
|
|
||||||
</n-button>
|
<!-- Footer -->
|
||||||
<div class="header-right">
|
<footer class="app-footer">
|
||||||
<n-dropdown :options="userDropdownOptions" @select="handleUserDropdown">
|
<div class="footer-left">
|
||||||
<n-button quaternary circle size="large">
|
<span class="brand">GoTunnel</span>
|
||||||
<template #icon>
|
<div v-if="version" class="version-info">
|
||||||
<n-icon size="24"><PersonCircleOutline /></n-icon>
|
<ServerOutline class="version-icon" />
|
||||||
</template>
|
<span class="version">{{ version.startsWith('v') ? version : 'v' + version }}</span>
|
||||||
</n-button>
|
<span v-if="updateInfo" class="update-status" :class="{ latest: !updateInfo.available, 'has-update': updateInfo.available }" @click="openUpdateModal">
|
||||||
</n-dropdown>
|
<template v-if="updateInfo.available">
|
||||||
</div>
|
<ArrowUpCircleOutline class="status-icon" />
|
||||||
</div>
|
<span>新版本 ({{ updateInfo.latest }})</span>
|
||||||
</n-layout-header>
|
</template>
|
||||||
<n-layout-content content-style="padding: 24px; background-color: #f0f2f5; min-height: calc(100vh - 64px);">
|
<template v-else>
|
||||||
<RouterView />
|
<CheckmarkCircleOutline class="status-icon" />
|
||||||
</n-layout-content>
|
<span>最新版本</span>
|
||||||
</n-layout>
|
</template>
|
||||||
</n-layout>
|
</span>
|
||||||
<RouterView v-else />
|
</div>
|
||||||
</n-message-provider>
|
</div>
|
||||||
</n-dialog-provider>
|
<a href="https://github.com/user/gotunnel" target="_blank" class="footer-link">
|
||||||
</n-config-provider>
|
<LogoGithub class="footer-icon" />
|
||||||
|
<span>GitHub</span>
|
||||||
|
</a>
|
||||||
|
<span class="copyright">© 2024 Flik. MIT License</span>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Update Modal -->
|
||||||
|
<div v-if="showUpdateModal" class="modal-overlay" @click.self="showUpdateModal = false">
|
||||||
|
<div class="update-modal">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h3>系统更新</h3>
|
||||||
|
<button class="close-btn" @click="showUpdateModal = false">
|
||||||
|
<CloseOutline />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" v-if="updateInfo">
|
||||||
|
<div class="update-info-grid">
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">当前版本</span>
|
||||||
|
<span class="info-value">{{ updateInfo.current }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">最新版本</span>
|
||||||
|
<span class="info-value highlight">{{ updateInfo.latest }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="updateInfo.asset_name" class="info-row">
|
||||||
|
<span class="info-label">文件名</span>
|
||||||
|
<span class="info-value">{{ updateInfo.asset_name }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="updateInfo.asset_size" class="info-row">
|
||||||
|
<span class="info-label">文件大小</span>
|
||||||
|
<span class="info-value">{{ formatBytes(updateInfo.asset_size) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="updateInfo.release_note" class="release-note">
|
||||||
|
<span class="note-label">更新日志</span>
|
||||||
|
<pre>{{ updateInfo.release_note }}</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="modal-btn" @click="showUpdateModal = false">取消</button>
|
||||||
|
<button
|
||||||
|
v-if="updateInfo?.available && updateInfo?.download_url"
|
||||||
|
class="modal-btn primary"
|
||||||
|
:disabled="updatingServer"
|
||||||
|
@click="handleApplyServerUpdate"
|
||||||
|
>
|
||||||
|
{{ updatingServer ? '更新中...' : '立即更新' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<RouterView v-else />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.main-layout {
|
.app-layout {
|
||||||
height: 100vh;
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: var(--gradient-bg);
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo-container {
|
/* Header - 毛玻璃效果 */
|
||||||
|
.app-header {
|
||||||
height: 64px;
|
height: 64px;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 24px;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
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 {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Navigation */
|
||||||
|
.header-nav {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 10px 18px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item:hover {
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
background: var(--glass-bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-item.active {
|
||||||
|
color: white;
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
box-shadow: 0 4px 15px var(--color-accent-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-icon {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* User Menu */
|
||||||
|
.user-menu {
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-icon {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
padding: 4px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
box-shadow: 0 2px 8px var(--color-accent-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item.active:hover {
|
||||||
|
filter: brightness(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-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: 150px;
|
||||||
|
box-shadow: var(--shadow-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 14px;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 8px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item:hover {
|
||||||
|
background: var(--glass-bg-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Footer - 毛玻璃效果 */
|
||||||
|
.app-footer {
|
||||||
|
height: 52px;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 24px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand {
|
||||||
|
font-weight: 600;
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version {
|
||||||
|
padding: 4px 10px;
|
||||||
|
background: var(--glass-bg-light);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-icon {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-status:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-status.latest {
|
||||||
|
color: var(--color-success);
|
||||||
|
background: rgba(16, 185, 129, 0.1);
|
||||||
|
border-color: rgba(16, 185, 129, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-status.has-update {
|
||||||
|
color: var(--color-warning);
|
||||||
|
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 {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link:hover {
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyright {
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.app-header {
|
||||||
|
padding: 0 12px;
|
||||||
|
}
|
||||||
|
.header-nav {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.app-footer {
|
||||||
|
padding: 0 12px;
|
||||||
|
}
|
||||||
|
.copyright {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update Modal - 毛玻璃效果 */
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 12px;
|
z-index: 1000;
|
||||||
border-bottom: 1px solid #efeff5;
|
}
|
||||||
|
|
||||||
|
.update-modal {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 16px;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 480px;
|
||||||
|
max-height: 80vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
|
||||||
|
|
||||||
.logo-text {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #18a058;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
height: 64px;
|
|
||||||
background: white;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
padding: 0 24px;
|
box-shadow: var(--shadow-lg), var(--shadow-glow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-content {
|
.modal-header {
|
||||||
width: 100%;
|
padding: 16px 20px;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
.server-status-card {
|
.modal-header h3 {
|
||||||
position: absolute;
|
margin: 0;
|
||||||
bottom: 0;
|
font-size: 16px;
|
||||||
width: 100%;
|
|
||||||
padding: 20px;
|
|
||||||
background: #f0fdf4;
|
|
||||||
border-top: 1px solid #d1fae5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-item {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-item .label {
|
|
||||||
color: #64748b;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-item .value {
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #0f172a;
|
color: var(--color-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-toggle {
|
.close-btn {
|
||||||
display: none;
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px;
|
||||||
|
display: flex;
|
||||||
|
transition: color 0.15s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
.close-btn:hover {
|
||||||
.mobile-toggle {
|
color: var(--color-text-primary);
|
||||||
display: inline-flex;
|
}
|
||||||
}
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 20px;
|
||||||
|
overflow-y: auto;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-info-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-label {
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-value {
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-value.highlight {
|
||||||
|
color: var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.release-note {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.release-note pre {
|
||||||
|
margin: 0;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
background: var(--color-bg-elevated);
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
max-height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn {
|
||||||
|
padding: 10px 18px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn:hover:not(:disabled) {
|
||||||
|
background: var(--glass-bg-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn.primary {
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
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 {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -180,3 +180,66 @@ export const createLogStream = (
|
|||||||
|
|
||||||
return eventSource
|
return eventSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 流量统计
|
||||||
|
export interface TrafficStats {
|
||||||
|
traffic_24h: { inbound: number; outbound: number }
|
||||||
|
traffic_total: { inbound: number; outbound: number }
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TrafficRecord {
|
||||||
|
timestamp: number
|
||||||
|
inbound: number
|
||||||
|
outbound: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getTrafficStats = () => get<TrafficStats>('/traffic/stats')
|
||||||
|
export const getTrafficHourly = () => get<{ records: TrafficRecord[] }>('/traffic/hourly')
|
||||||
|
|
||||||
|
// 客户端系统状态
|
||||||
|
export interface SystemStats {
|
||||||
|
cpu_usage: number
|
||||||
|
memory_total: number
|
||||||
|
memory_used: number
|
||||||
|
memory_usage: number
|
||||||
|
disk_total: number
|
||||||
|
disk_used: number
|
||||||
|
disk_usage: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getClientSystemStats = (clientId: string) => get<SystemStats>(`/client/${clientId}/system-stats`)
|
||||||
|
|
||||||
|
// 服务器配置
|
||||||
|
export interface ServerConfigInfo {
|
||||||
|
bind_addr: string
|
||||||
|
bind_port: number
|
||||||
|
token: string
|
||||||
|
heartbeat_sec: number
|
||||||
|
heartbeat_timeout: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebConfigInfo {
|
||||||
|
enabled: boolean
|
||||||
|
bind_port: number
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PluginStoreConfigInfo {
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServerConfigResponse {
|
||||||
|
server: ServerConfigInfo
|
||||||
|
web: WebConfigInfo
|
||||||
|
plugin_store: PluginStoreConfigInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateServerConfigRequest {
|
||||||
|
server?: Partial<ServerConfigInfo>
|
||||||
|
web?: Partial<WebConfigInfo>
|
||||||
|
plugin_store?: Partial<PluginStoreConfigInfo>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getServerConfig = () => get<ServerConfigResponse>('/config')
|
||||||
|
export const updateServerConfig = (config: UpdateServerConfigRequest) => put('/config', config)
|
||||||
|
|||||||
128
web/src/components/GlassModal.vue
Normal file
128
web/src/components/GlassModal.vue
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { CloseOutline } from '@vicons/ionicons5'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
show: boolean
|
||||||
|
title: string
|
||||||
|
width?: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'close'): void
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<div v-if="show" class="modal-overlay" @click.self="emit('close')">
|
||||||
|
<div class="modal-container" :style="{ maxWidth: width || '500px' }">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h3>{{ title }}</h3>
|
||||||
|
<button class="close-btn" @click="emit('close')">
|
||||||
|
<CloseOutline />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<slot name="footer" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-container {
|
||||||
|
width: 100%;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
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 {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid var(--color-border-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn {
|
||||||
|
background: var(--glass-bg-light);
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 6px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn:hover {
|
||||||
|
background: rgba(239, 68, 68, 0.15);
|
||||||
|
color: var(--color-error);
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn svg {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-top: 1px solid var(--color-border-light);
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer:empty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
85
web/src/components/GlassSwitch.vue
Normal file
85
web/src/components/GlassSwitch.vue
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue?: boolean
|
||||||
|
size?: 'small' | 'medium'
|
||||||
|
disabled?: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: boolean): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const toggle = () => {
|
||||||
|
if (!props.disabled) {
|
||||||
|
emit('update:modelValue', !props.modelValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<button
|
||||||
|
class="glass-switch"
|
||||||
|
:class="[size || 'small', { active: modelValue, disabled }]"
|
||||||
|
@click="toggle"
|
||||||
|
:disabled="disabled"
|
||||||
|
>
|
||||||
|
<span class="switch-thumb"></span>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.glass-switch {
|
||||||
|
position: relative;
|
||||||
|
width: 36px;
|
||||||
|
height: 20px;
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch.small {
|
||||||
|
width: 32px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch:hover:not(.disabled) {
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch.active {
|
||||||
|
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch.disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-thumb {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
transition: transform 0.2s;
|
||||||
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch.small .switch-thumb {
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch.active .switch-thumb {
|
||||||
|
transform: translateX(16px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-switch.small.active .switch-thumb {
|
||||||
|
transform: translateX(14px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
60
web/src/components/GlassTag.vue
Normal file
60
web/src/components/GlassTag.vue
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{
|
||||||
|
type?: 'default' | 'success' | 'warning' | 'error' | 'info'
|
||||||
|
size?: 'small' | 'medium'
|
||||||
|
round?: boolean
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<span class="glass-tag" :class="[type || 'default', size || 'small', { round }]">
|
||||||
|
<slot />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.glass-tag {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-tag.round {
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-tag.medium {
|
||||||
|
padding: 4px 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-tag.success {
|
||||||
|
background: rgba(52, 211, 153, 0.15);
|
||||||
|
border-color: rgba(52, 211, 153, 0.3);
|
||||||
|
color: #34d399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-tag.warning {
|
||||||
|
background: rgba(251, 191, 36, 0.15);
|
||||||
|
border-color: rgba(251, 191, 36, 0.3);
|
||||||
|
color: #fbbf24;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-tag.error {
|
||||||
|
background: rgba(239, 68, 68, 0.15);
|
||||||
|
border-color: rgba(239, 68, 68, 0.3);
|
||||||
|
color: #f87171;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-tag.info {
|
||||||
|
background: rgba(96, 165, 250, 0.15);
|
||||||
|
border-color: rgba(96, 165, 250, 0.3);
|
||||||
|
color: #60a5fa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
300
web/src/components/InlineLogPanel.vue
Normal file
300
web/src/components/InlineLogPanel.vue
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||||
|
import { PlayOutline, StopOutline, TrashOutline } from '@vicons/ionicons5'
|
||||||
|
import { createLogStream } from '../api'
|
||||||
|
import type { LogEntry } from '../types'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
clientId: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const logs = ref<LogEntry[]>([])
|
||||||
|
const isStreaming = ref(false)
|
||||||
|
const autoScroll = ref(true)
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
|
let eventSource: EventSource | null = null
|
||||||
|
const logContainer = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
|
const startStream = () => {
|
||||||
|
if (eventSource) {
|
||||||
|
eventSource.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
isStreaming.value = true
|
||||||
|
|
||||||
|
eventSource = createLogStream(
|
||||||
|
props.clientId,
|
||||||
|
{ lines: 100, follow: true, level: '' },
|
||||||
|
(entry) => {
|
||||||
|
logs.value.push(entry)
|
||||||
|
if (logs.value.length > 500) {
|
||||||
|
logs.value = logs.value.slice(-300)
|
||||||
|
}
|
||||||
|
if (autoScroll.value) {
|
||||||
|
nextTick(() => scrollToBottom())
|
||||||
|
}
|
||||||
|
loading.value = false
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
isStreaming.value = false
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopStream = () => {
|
||||||
|
if (eventSource) {
|
||||||
|
eventSource.close()
|
||||||
|
eventSource = null
|
||||||
|
}
|
||||||
|
isStreaming.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearLogs = () => {
|
||||||
|
logs.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollToBottom = () => {
|
||||||
|
if (logContainer.value) {
|
||||||
|
logContainer.value.scrollTop = logContainer.value.scrollHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getLevelColor = (level: string): string => {
|
||||||
|
switch (level) {
|
||||||
|
case 'error': return '#fca5a5'
|
||||||
|
case 'warn': return '#fcd34d'
|
||||||
|
case 'info': return '#60a5fa'
|
||||||
|
case 'debug': return '#9ca3af'
|
||||||
|
default: return 'rgba(255,255,255,0.7)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatTime = (ts: number): string => {
|
||||||
|
return new Date(ts).toLocaleTimeString('en-US', { hour12: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
startStream()
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
stopStream()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="inline-log-panel">
|
||||||
|
<div class="log-toolbar">
|
||||||
|
<div class="toolbar-left">
|
||||||
|
<span class="log-title">实时日志</span>
|
||||||
|
<span v-if="isStreaming" class="streaming-badge">
|
||||||
|
<span class="streaming-dot"></span>
|
||||||
|
实时
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="toolbar-right">
|
||||||
|
<button v-if="!isStreaming" class="tool-btn" @click="startStream" title="开始">
|
||||||
|
<PlayOutline class="tool-icon" />
|
||||||
|
</button>
|
||||||
|
<button v-else class="tool-btn" @click="stopStream" title="停止">
|
||||||
|
<StopOutline class="tool-icon" />
|
||||||
|
</button>
|
||||||
|
<button class="tool-btn" @click="clearLogs" title="清空">
|
||||||
|
<TrashOutline class="tool-icon" />
|
||||||
|
</button>
|
||||||
|
<label class="auto-scroll-toggle">
|
||||||
|
<input type="checkbox" v-model="autoScroll" />
|
||||||
|
<span>自动滚动</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ref="logContainer" class="log-content">
|
||||||
|
<div v-if="loading && logs.length === 0" class="log-loading">
|
||||||
|
连接中...
|
||||||
|
</div>
|
||||||
|
<div v-else-if="logs.length === 0" class="log-empty">
|
||||||
|
暂无日志
|
||||||
|
</div>
|
||||||
|
<div v-else class="log-lines">
|
||||||
|
<div v-for="(log, index) in logs" :key="index" class="log-line">
|
||||||
|
<span class="log-time">{{ formatTime(log.ts) }}</span>
|
||||||
|
<span class="log-level" :style="{ color: getLevelColor(log.level) }">
|
||||||
|
[{{ log.level.toUpperCase() }}]
|
||||||
|
</span>
|
||||||
|
<span class="log-src">[{{ log.src }}]</span>
|
||||||
|
<span class="log-msg">{{ log.msg }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.inline-log-panel {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-toolbar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
background: var(--glass-bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-title {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.streaming-badge {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--color-success);
|
||||||
|
background: rgba(16, 185, 129, 0.15);
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.streaming-dot {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--color-success);
|
||||||
|
animation: pulse 1.5s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0%, 100% { opacity: 1; }
|
||||||
|
50% { opacity: 0.4; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar-right {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-btn {
|
||||||
|
background: var(--color-border);
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 6px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-btn:hover {
|
||||||
|
background: var(--color-bg-elevated);
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auto-scroll-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.auto-scroll-toggle input {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
accent-color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-content {
|
||||||
|
height: 200px;
|
||||||
|
overflow-y: auto;
|
||||||
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.6;
|
||||||
|
background: var(--color-bg-elevated);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-loading,
|
||||||
|
.log-empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-lines {
|
||||||
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-line {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 2px 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-time {
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-level {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-src {
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-msg {
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollbar */
|
||||||
|
.log-content::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-content::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-content::-webkit-scrollbar-thumb {
|
||||||
|
background: var(--color-border);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-content::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
||||||
import { NCard, NSpace, NButton, NSelect, NSwitch, NInput, NIcon, NEmpty, NSpin } from 'naive-ui'
|
import {
|
||||||
import { PlayOutline, StopOutline, TrashOutline, DownloadOutline } from '@vicons/ionicons5'
|
PlayOutline, StopOutline, TrashOutline, DownloadOutline, CloseOutline
|
||||||
|
} from '@vicons/ionicons5'
|
||||||
import { createLogStream } from '../api'
|
import { createLogStream } from '../api'
|
||||||
import type { LogEntry } from '../types'
|
import type { LogEntry } from '../types'
|
||||||
|
|
||||||
@@ -24,14 +25,6 @@ const loading = ref(false)
|
|||||||
let eventSource: EventSource | null = null
|
let eventSource: EventSource | null = null
|
||||||
const logContainer = ref<HTMLElement | null>(null)
|
const logContainer = ref<HTMLElement | null>(null)
|
||||||
|
|
||||||
const levelOptions = [
|
|
||||||
{ label: '所有级别', value: '' },
|
|
||||||
{ label: 'Info', value: 'info' },
|
|
||||||
{ label: 'Warning', value: 'warn' },
|
|
||||||
{ label: 'Error', value: 'error' },
|
|
||||||
{ label: 'Debug', value: 'debug' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const startStream = () => {
|
const startStream = () => {
|
||||||
if (eventSource) {
|
if (eventSource) {
|
||||||
eventSource.close()
|
eventSource.close()
|
||||||
@@ -133,100 +126,354 @@ onUnmounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-card title="客户端日志" :closable="true" @close="emit('close')">
|
<div v-if="visible" class="log-overlay" @click.self="emit('close')">
|
||||||
<template #header-extra>
|
<div class="log-modal">
|
||||||
<n-space :size="8">
|
<!-- Header -->
|
||||||
<n-select
|
<div class="log-header">
|
||||||
v-model:value="levelFilter"
|
<h3>客户端日志</h3>
|
||||||
:options="levelOptions"
|
<div class="log-controls">
|
||||||
size="small"
|
<select v-model="levelFilter" class="log-select" @change="() => { stopStream(); logs = []; startStream(); }">
|
||||||
style="width: 110px;"
|
<option value="">所有级别</option>
|
||||||
@update:value="() => { stopStream(); logs = []; startStream(); }"
|
<option value="info">Info</option>
|
||||||
/>
|
<option value="warn">Warning</option>
|
||||||
<n-input
|
<option value="error">Error</option>
|
||||||
v-model:value="searchText"
|
<option value="debug">Debug</option>
|
||||||
placeholder="搜索..."
|
</select>
|
||||||
size="small"
|
<input v-model="searchText" type="text" class="log-input" placeholder="搜索..." />
|
||||||
style="width: 120px;"
|
<label class="log-toggle">
|
||||||
clearable
|
<input type="checkbox" v-model="autoScroll" />
|
||||||
/>
|
<span>自动滚动</span>
|
||||||
<n-switch v-model:value="autoScroll" size="small">
|
</label>
|
||||||
<template #checked>自动滚动</template>
|
<button class="icon-btn" @click="clearLogs" title="清空">
|
||||||
<template #unchecked>手动</template>
|
<TrashOutline />
|
||||||
</n-switch>
|
</button>
|
||||||
<n-button size="small" quaternary @click="clearLogs">
|
<button class="icon-btn" @click="downloadLogs" title="下载">
|
||||||
<template #icon><n-icon><TrashOutline /></n-icon></template>
|
<DownloadOutline />
|
||||||
</n-button>
|
</button>
|
||||||
<n-button size="small" quaternary @click="downloadLogs">
|
<button class="action-btn" :class="isStreaming ? 'danger' : 'success'" @click="isStreaming ? stopStream() : startStream()">
|
||||||
<template #icon><n-icon><DownloadOutline /></n-icon></template>
|
<StopOutline v-if="isStreaming" />
|
||||||
</n-button>
|
<PlayOutline v-else />
|
||||||
<n-button
|
<span>{{ isStreaming ? '停止' : '开始' }}</span>
|
||||||
size="small"
|
</button>
|
||||||
:type="isStreaming ? 'error' : 'success'"
|
</div>
|
||||||
@click="isStreaming ? stopStream() : startStream()"
|
<button class="close-btn" @click="emit('close')">
|
||||||
>
|
<CloseOutline />
|
||||||
<template #icon>
|
</button>
|
||||||
<n-icon><StopOutline v-if="isStreaming" /><PlayOutline v-else /></n-icon>
|
</div>
|
||||||
</template>
|
|
||||||
{{ isStreaming ? '停止' : '开始' }}
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<n-spin :show="loading && logs.length === 0">
|
<!-- Content -->
|
||||||
<div
|
<div class="log-body">
|
||||||
ref="logContainer"
|
<div v-if="loading && logs.length === 0" class="log-loading">加载中...</div>
|
||||||
class="log-container"
|
<div ref="logContainer" class="log-container">
|
||||||
>
|
<div v-if="filteredLogs.length === 0" class="log-empty">暂无日志</div>
|
||||||
<n-empty v-if="filteredLogs.length === 0" description="暂无日志" />
|
<div v-for="(log, i) in filteredLogs" :key="i" class="log-line">
|
||||||
<div
|
<span class="log-time">{{ formatTime(log.ts) }}</span>
|
||||||
v-for="(log, i) in filteredLogs"
|
<span class="log-level" :style="{ color: getLevelColor(log.level) }">[{{ log.level.toUpperCase() }}]</span>
|
||||||
:key="i"
|
<span class="log-src">[{{ log.src }}]</span>
|
||||||
class="log-line"
|
<span class="log-msg">{{ log.msg }}</span>
|
||||||
>
|
</div>
|
||||||
<span class="log-time">{{ formatTime(log.ts) }}</span>
|
|
||||||
<span class="log-level" :style="{ color: getLevelColor(log.level) }">[{{ log.level.toUpperCase() }}]</span>
|
|
||||||
<span class="log-src">[{{ log.src }}]</span>
|
|
||||||
<span class="log-msg">{{ log.msg }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</n-spin>
|
</div>
|
||||||
</n-card>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.log-container {
|
/* Overlay */
|
||||||
height: 400px;
|
.log-overlay {
|
||||||
overflow-y: auto;
|
position: fixed;
|
||||||
background: #1e1e1e;
|
inset: 0;
|
||||||
padding: 8px;
|
background: rgba(0, 0, 0, 0.6);
|
||||||
font-family: 'Consolas', 'Monaco', monospace;
|
backdrop-filter: blur(4px);
|
||||||
font-size: 12px;
|
display: flex;
|
||||||
border-radius: 4px;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
padding: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Modal */
|
||||||
|
.log-modal {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 900px;
|
||||||
|
max-height: 80vh;
|
||||||
|
background: rgba(30, 27, 75, 0.95);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
-webkit-backdrop-filter: blur(20px);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
.log-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-header h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: white;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-controls {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Select */
|
||||||
|
.log-select {
|
||||||
|
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: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-select option {
|
||||||
|
background: #1e1b4b;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Input */
|
||||||
|
.log-input {
|
||||||
|
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: 13px;
|
||||||
|
width: 150px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-input::placeholder {
|
||||||
|
color: rgba(255, 255, 255, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-input:focus {
|
||||||
|
border-color: rgba(167, 139, 250, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toggle */
|
||||||
|
.log-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-toggle input[type="checkbox"] {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
accent-color: #a78bfa;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Icon Button */
|
||||||
|
.icon-btn {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 6px;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-btn svg {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Action Button */
|
||||||
|
.action-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
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: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn.success {
|
||||||
|
background: rgba(52, 211, 153, 0.2);
|
||||||
|
border-color: rgba(52, 211, 153, 0.3);
|
||||||
|
color: #34d399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btn.danger {
|
||||||
|
background: rgba(239, 68, 68, 0.2);
|
||||||
|
border-color: rgba(239, 68, 68, 0.3);
|
||||||
|
color: #fca5a5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close Button */
|
||||||
|
.close-btn {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 6px;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn:hover {
|
||||||
|
background: rgba(239, 68, 68, 0.2);
|
||||||
|
color: #fca5a5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn svg {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Body */
|
||||||
|
.log-body {
|
||||||
|
flex: 1;
|
||||||
|
padding: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-loading {
|
||||||
|
text-align: center;
|
||||||
|
padding: 32px;
|
||||||
|
color: rgba(255, 255, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Container */
|
||||||
|
.log-container {
|
||||||
|
flex: 1;
|
||||||
|
height: 400px;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
padding: 12px;
|
||||||
|
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-empty {
|
||||||
|
text-align: center;
|
||||||
|
padding: 48px;
|
||||||
|
color: rgba(255, 255, 255, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Log Line */
|
||||||
.log-line {
|
.log-line {
|
||||||
line-height: 1.6;
|
line-height: 1.8;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
color: #d4d4d4;
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
padding: 2px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-time {
|
.log-time {
|
||||||
color: #808080;
|
color: rgba(255, 255, 255, 0.4);
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-level {
|
.log-level {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-src {
|
.log-src {
|
||||||
color: #a0a0a0;
|
color: rgba(167, 139, 250, 0.8);
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.log-msg {
|
.log-msg {
|
||||||
color: #d4d4d4;
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scrollbar */
|
||||||
|
.log-container::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-container::-webkit-scrollbar-track {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-container::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-container::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.log-overlay {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-modal {
|
||||||
|
max-height: 90vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-header {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-controls {
|
||||||
|
order: 1;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
129
web/src/composables/useConfirm.ts
Normal file
129
web/src/composables/useConfirm.ts
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
import { ref, createApp, h } from 'vue'
|
||||||
|
|
||||||
|
interface DialogOptions {
|
||||||
|
title: string
|
||||||
|
content: string
|
||||||
|
positiveText?: string
|
||||||
|
negativeText?: string
|
||||||
|
onPositiveClick?: () => void | Promise<void>
|
||||||
|
onNegativeClick?: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogOptions = ref<DialogOptions | null>(null)
|
||||||
|
|
||||||
|
const DialogComponent = {
|
||||||
|
setup() {
|
||||||
|
const handlePositive = async () => {
|
||||||
|
if (dialogOptions.value?.onPositiveClick) {
|
||||||
|
await dialogOptions.value.onPositiveClick()
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleNegative = () => {
|
||||||
|
dialogOptions.value?.onNegativeClick?.()
|
||||||
|
dialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (!dialogVisible.value || !dialogOptions.value) return null
|
||||||
|
|
||||||
|
return h('div', { class: 'dialog-overlay', onClick: handleNegative },
|
||||||
|
h('div', { class: 'dialog-container', onClick: (e: Event) => e.stopPropagation() }, [
|
||||||
|
h('h3', { class: 'dialog-title' }, dialogOptions.value.title),
|
||||||
|
h('p', { class: 'dialog-content' }, dialogOptions.value.content),
|
||||||
|
h('div', { class: 'dialog-footer' }, [
|
||||||
|
h('button', { class: 'dialog-btn', onClick: handleNegative },
|
||||||
|
dialogOptions.value.negativeText || '取消'),
|
||||||
|
h('button', { class: 'dialog-btn primary', onClick: handlePositive },
|
||||||
|
dialogOptions.value.positiveText || '确定')
|
||||||
|
])
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let containerMounted = false
|
||||||
|
|
||||||
|
function ensureContainer() {
|
||||||
|
if (containerMounted) return
|
||||||
|
|
||||||
|
const container = document.createElement('div')
|
||||||
|
container.id = 'dialog-root'
|
||||||
|
document.body.appendChild(container)
|
||||||
|
|
||||||
|
const app = createApp(DialogComponent)
|
||||||
|
app.mount(container)
|
||||||
|
containerMounted = true
|
||||||
|
|
||||||
|
// Add styles
|
||||||
|
const style = document.createElement('style')
|
||||||
|
style.textContent = `
|
||||||
|
.dialog-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 9998;
|
||||||
|
}
|
||||||
|
.dialog-container {
|
||||||
|
background: rgba(30, 27, 75, 0.95);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||||
|
padding: 24px;
|
||||||
|
max-width: 400px;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
.dialog-title {
|
||||||
|
margin: 0 0 12px 0;
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.dialog-content {
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
.dialog-btn {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
color: white;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
.dialog-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
.dialog-btn.primary {
|
||||||
|
background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
document.head.appendChild(style)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useConfirm() {
|
||||||
|
return {
|
||||||
|
warning: (options: DialogOptions) => {
|
||||||
|
ensureContainer()
|
||||||
|
dialogOptions.value = options
|
||||||
|
dialogVisible.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
47
web/src/composables/useTheme.ts
Normal file
47
web/src/composables/useTheme.ts
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
101
web/src/composables/useToast.ts
Normal file
101
web/src/composables/useToast.ts
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import { ref, createApp, h } from 'vue'
|
||||||
|
|
||||||
|
interface ToastOptions {
|
||||||
|
message: string
|
||||||
|
type: 'success' | 'error' | 'warning' | 'info'
|
||||||
|
duration?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const toasts = ref<Array<ToastOptions & { id: number }>>([])
|
||||||
|
let toastId = 0
|
||||||
|
|
||||||
|
const ToastContainer = {
|
||||||
|
setup() {
|
||||||
|
return () => h('div', { class: 'toast-container' },
|
||||||
|
toasts.value.map(toast =>
|
||||||
|
h('div', {
|
||||||
|
key: toast.id,
|
||||||
|
class: ['toast-item', toast.type]
|
||||||
|
}, toast.message)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let containerMounted = false
|
||||||
|
|
||||||
|
function ensureContainer() {
|
||||||
|
if (containerMounted) return
|
||||||
|
|
||||||
|
const container = document.createElement('div')
|
||||||
|
container.id = 'toast-root'
|
||||||
|
document.body.appendChild(container)
|
||||||
|
|
||||||
|
const app = createApp(ToastContainer)
|
||||||
|
app.mount(container)
|
||||||
|
containerMounted = true
|
||||||
|
|
||||||
|
// Add styles
|
||||||
|
const style = document.createElement('style')
|
||||||
|
style.textContent = `
|
||||||
|
.toast-container {
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 9999;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.toast-item {
|
||||||
|
padding: 12px 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: white;
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
animation: toast-in 0.3s ease;
|
||||||
|
max-width: 350px;
|
||||||
|
}
|
||||||
|
.toast-item.success {
|
||||||
|
background: rgba(52, 211, 153, 0.9);
|
||||||
|
}
|
||||||
|
.toast-item.error {
|
||||||
|
background: rgba(239, 68, 68, 0.9);
|
||||||
|
}
|
||||||
|
.toast-item.warning {
|
||||||
|
background: rgba(251, 191, 36, 0.9);
|
||||||
|
color: #1e1b4b;
|
||||||
|
}
|
||||||
|
.toast-item.info {
|
||||||
|
background: rgba(96, 165, 250, 0.9);
|
||||||
|
}
|
||||||
|
@keyframes toast-in {
|
||||||
|
from { opacity: 0; transform: translateX(20px); }
|
||||||
|
to { opacity: 1; transform: translateX(0); }
|
||||||
|
}
|
||||||
|
`
|
||||||
|
document.head.appendChild(style)
|
||||||
|
}
|
||||||
|
|
||||||
|
function showToast(options: ToastOptions) {
|
||||||
|
ensureContainer()
|
||||||
|
|
||||||
|
const id = ++toastId
|
||||||
|
toasts.value.push({ ...options, id })
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const index = toasts.value.findIndex(t => t.id === id)
|
||||||
|
if (index > -1) {
|
||||||
|
toasts.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
}, options.duration || 3000)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useToast() {
|
||||||
|
return {
|
||||||
|
success: (message: string) => showToast({ message, type: 'success' }),
|
||||||
|
error: (message: string) => showToast({ message, type: 'error' }),
|
||||||
|
warning: (message: string) => showToast({ message, type: 'warning' }),
|
||||||
|
info: (message: string) => showToast({ message, type: 'info' })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import naive from 'naive-ui'
|
|
||||||
import './style.css'
|
import './style.css'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(naive)
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -15,20 +15,20 @@ const router = createRouter({
|
|||||||
name: 'home',
|
name: 'home',
|
||||||
component: () => import('../views/HomeView.vue'),
|
component: () => import('../views/HomeView.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/clients',
|
||||||
|
name: 'clients',
|
||||||
|
component: () => import('../views/ClientsView.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/client/:id',
|
path: '/client/:id',
|
||||||
name: 'client',
|
name: 'client',
|
||||||
component: () => import('../views/ClientView.vue'),
|
component: () => import('../views/ClientView.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/plugins',
|
path: '/settings',
|
||||||
name: 'plugins',
|
name: 'settings',
|
||||||
component: () => import('../views/PluginsView.vue'),
|
component: () => import('../views/SettingsView.vue'),
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/update',
|
|
||||||
name: 'update',
|
|
||||||
component: () => import('../views/UpdateView.vue'),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,123 @@
|
|||||||
|
@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;
|
||||||
@@ -8,8 +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-card {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
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 {
|
||||||
|
background: var(--glass-bg-hover);
|
||||||
|
border-color: rgba(255, 255, 255, 0.12);
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ export interface ClientStatus {
|
|||||||
last_ping?: string
|
last_ping?: string
|
||||||
remote_addr?: string
|
remote_addr?: string
|
||||||
rule_count: number
|
rule_count: number
|
||||||
|
os?: string
|
||||||
|
arch?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 客户端详情
|
// 客户端详情
|
||||||
@@ -72,6 +74,9 @@ export interface ClientDetail {
|
|||||||
online: boolean
|
online: boolean
|
||||||
last_ping?: string
|
last_ping?: string
|
||||||
remote_addr?: string
|
remote_addr?: string
|
||||||
|
os?: string
|
||||||
|
arch?: string
|
||||||
|
version?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务器状态
|
// 服务器状态
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
430
web/src/views/ClientsView.vue
Normal file
430
web/src/views/ClientsView.vue
Normal file
@@ -0,0 +1,430 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, computed } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { getClients } from '../api'
|
||||||
|
import type { ClientStatus } from '../types'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const clients = ref<ClientStatus[]>([])
|
||||||
|
const loading = ref(true)
|
||||||
|
|
||||||
|
const loadClients = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const { data } = await getClients()
|
||||||
|
clients.value = data || []
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load clients', e)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onlineClients = computed(() => clients.value.filter(c => c.online).length)
|
||||||
|
|
||||||
|
const viewClient = (id: string) => {
|
||||||
|
router.push(`/client/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(loadClients)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="clients-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="clients-content">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="page-header">
|
||||||
|
<h1 class="page-title">客户端管理</h1>
|
||||||
|
<p class="page-subtitle">管理所有连接的客户端</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Stats Row -->
|
||||||
|
<div class="stats-row">
|
||||||
|
<div class="stat-card">
|
||||||
|
<span class="stat-value">{{ clients.length }}</span>
|
||||||
|
<span class="stat-label">总客户端</span>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<span class="stat-value online">{{ onlineClients }}</span>
|
||||||
|
<span class="stat-label">在线</span>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<span class="stat-value offline">{{ clients.length - onlineClients }}</span>
|
||||||
|
<span class="stat-label">离线</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Client List -->
|
||||||
|
<div class="glass-card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3>客户端列表</h3>
|
||||||
|
<button class="glass-btn small" @click="loadClients">刷新</button>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div v-if="loading" class="loading-state">加载中...</div>
|
||||||
|
<div v-else-if="clients.length === 0" class="empty-state">
|
||||||
|
<p>暂无客户端连接</p>
|
||||||
|
<p class="empty-hint">等待客户端连接...</p>
|
||||||
|
</div>
|
||||||
|
<div v-else class="clients-grid">
|
||||||
|
<div
|
||||||
|
v-for="client in clients"
|
||||||
|
:key="client.id"
|
||||||
|
class="client-card"
|
||||||
|
@click="viewClient(client.id)"
|
||||||
|
>
|
||||||
|
<div class="client-header">
|
||||||
|
<div class="client-status" :class="{ online: client.online }"></div>
|
||||||
|
<h4 class="client-name">{{ client.nickname || client.id }}</h4>
|
||||||
|
</div>
|
||||||
|
<p v-if="client.nickname" class="client-id">{{ client.id }}</p>
|
||||||
|
<div class="client-info">
|
||||||
|
<span v-if="client.remote_addr && client.online">{{ client.remote_addr }}</span>
|
||||||
|
<span>{{ client.rule_count || 0 }} 条规则</span>
|
||||||
|
</div>
|
||||||
|
<div class="client-tag" :class="client.online ? 'online' : 'offline'">
|
||||||
|
{{ client.online ? '在线' : '离线' }}
|
||||||
|
</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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.clients-page {
|
||||||
|
min-height: calc(100vh - 116px);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 动画背景粒子 */
|
||||||
|
.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: 350px;
|
||||||
|
height: 350px;
|
||||||
|
background: var(--color-accent);
|
||||||
|
top: -80px;
|
||||||
|
right: -80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.particle-2 {
|
||||||
|
width: 280px;
|
||||||
|
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 {
|
||||||
|
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: var(--color-text-primary);
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
}
|
||||||
|
.page-subtitle {
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stats */
|
||||||
|
.stats-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
padding: 20px;
|
||||||
|
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 {
|
||||||
|
display: block;
|
||||||
|
font-size: 32px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
.stat-value.online { color: var(--color-success); }
|
||||||
|
.stat-value.offline { color: var(--color-text-muted); }
|
||||||
|
.stat-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Glass Card */
|
||||||
|
.glass-card {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 16px;
|
||||||
|
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 {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid var(--color-border-light);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.card-header h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
.card-body { padding: 20px; }
|
||||||
|
|
||||||
|
.loading-state, .empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 48px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
.empty-hint {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clients Grid */
|
||||||
|
.clients-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.clients-grid { grid-template-columns: repeat(2, 1fr); }
|
||||||
|
.stats-row { grid-template-columns: 1fr; }
|
||||||
|
}
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.clients-grid { grid-template-columns: 1fr; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-card {
|
||||||
|
background: var(--glass-bg-light);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 18px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.client-card:hover {
|
||||||
|
background: var(--glass-bg-hover);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: var(--shadow-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-status {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
.client-status.online {
|
||||||
|
background: var(--color-success);
|
||||||
|
box-shadow: 0 0 10px var(--color-success-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-name {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-id {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.client-tag {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.client-tag.online {
|
||||||
|
background: rgba(16, 185, 129, 0.15);
|
||||||
|
color: var(--color-success);
|
||||||
|
border: 1px solid rgba(16, 185, 129, 0.2);
|
||||||
|
}
|
||||||
|
.client-tag.offline {
|
||||||
|
background: var(--glass-bg-light);
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button */
|
||||||
|
.glass-btn {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur-light);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
.glass-btn:hover {
|
||||||
|
background: var(--glass-bg-hover);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
.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>
|
||||||
@@ -1,14 +1,65 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { getClients, getTrafficStats, getTrafficHourly, type TrafficRecord } from '../api'
|
||||||
import { NCard, NButton, NSpace, NTag, NStatistic, NGrid, NGi, NEmpty, NIcon } from 'naive-ui'
|
|
||||||
import { ExtensionPuzzleOutline, CloudDownloadOutline } from '@vicons/ionicons5'
|
|
||||||
import { getClients } from '../api'
|
|
||||||
import type { ClientStatus } from '../types'
|
import type { ClientStatus } from '../types'
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const clients = ref<ClientStatus[]>([])
|
const clients = ref<ClientStatus[]>([])
|
||||||
|
|
||||||
|
// 流量统计数据
|
||||||
|
const traffic24h = ref({ inbound: 0, outbound: 0 })
|
||||||
|
const trafficTotal = ref({ inbound: 0, outbound: 0 })
|
||||||
|
const trafficHistory = ref<TrafficRecord[]>([])
|
||||||
|
|
||||||
|
// 格式化字节数
|
||||||
|
const formatBytes = (bytes: number): { value: string; unit: string } => {
|
||||||
|
if (bytes === 0) return { value: '0', unit: 'B' }
|
||||||
|
const k = 1024
|
||||||
|
const sizes: string[] = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||||
|
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), sizes.length - 1)
|
||||||
|
return {
|
||||||
|
value: parseFloat((bytes / Math.pow(k, i)).toFixed(2)).toString(),
|
||||||
|
unit: sizes[i] as string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载流量统计
|
||||||
|
const loadTrafficStats = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await getTrafficStats()
|
||||||
|
traffic24h.value = data.traffic_24h
|
||||||
|
trafficTotal.value = data.traffic_total
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load traffic stats', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载每小时流量
|
||||||
|
const loadTrafficHourly = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await getTrafficHourly()
|
||||||
|
const records = data.records || []
|
||||||
|
// 如果没有数据,生成从当前时间开始的24小时空数据
|
||||||
|
if (records.length === 0) {
|
||||||
|
const now = new Date()
|
||||||
|
const currentHour = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours())
|
||||||
|
const emptyRecords: TrafficRecord[] = []
|
||||||
|
for (let i = 23; i >= 0; i--) {
|
||||||
|
const ts = new Date(currentHour.getTime() - i * 3600 * 1000)
|
||||||
|
emptyRecords.push({
|
||||||
|
timestamp: Math.floor(ts.getTime() / 1000),
|
||||||
|
inbound: 0,
|
||||||
|
outbound: 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
trafficHistory.value = emptyRecords
|
||||||
|
} else {
|
||||||
|
trafficHistory.value = records
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load hourly traffic', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loadClients = async () => {
|
const loadClients = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await getClients()
|
const { data } = await getClients()
|
||||||
@@ -18,80 +69,585 @@ const loadClients = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const onlineClients = computed(() => {
|
const onlineClients = computed(() => {
|
||||||
return clients.value.filter(client => client.online).length
|
return clients.value.filter(client => client.online).length
|
||||||
})
|
})
|
||||||
|
|
||||||
const totalRules = computed(() => {
|
const totalRules = computed(() => {
|
||||||
return clients.value.reduce((sum, client) => sum + client.rule_count, 0)
|
return clients.value.reduce((sum, c) => sum + (c.rule_count || 0), 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(loadClients)
|
// 格式化后的流量统计
|
||||||
|
const formatted24hInbound = computed(() => formatBytes(traffic24h.value.inbound))
|
||||||
|
const formatted24hOutbound = computed(() => formatBytes(traffic24h.value.outbound))
|
||||||
|
const formattedTotalInbound = computed(() => formatBytes(trafficTotal.value.inbound))
|
||||||
|
const formattedTotalOutbound = computed(() => formatBytes(trafficTotal.value.outbound))
|
||||||
|
|
||||||
const viewClient = (id: string) => {
|
// Chart helpers
|
||||||
router.push(`/client/${id}`)
|
const maxTraffic = computed(() => {
|
||||||
|
const max = Math.max(
|
||||||
|
...trafficHistory.value.map(d => Math.max(d.inbound, d.outbound))
|
||||||
|
)
|
||||||
|
return max || 100
|
||||||
|
})
|
||||||
|
|
||||||
|
const getBarHeight = (value: number) => {
|
||||||
|
return (value / maxTraffic.value) * 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 格式化时间戳为小时
|
||||||
|
const formatHour = (timestamp: number) => {
|
||||||
|
const date = new Date(timestamp * 1000)
|
||||||
|
return date.getHours().toString().padStart(2, '0') + ':00'
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadClients()
|
||||||
|
loadTrafficStats()
|
||||||
|
loadTrafficHourly()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="home">
|
<div class="dashboard-container">
|
||||||
<n-space justify="space-between" align="center" style="margin-bottom: 24px;">
|
<!-- Animated background particles -->
|
||||||
<div>
|
<div class="particles">
|
||||||
<h2 style="margin: 0 0 8px 0;">客户端管理</h2>
|
<div class="particle particle-1"></div>
|
||||||
<p style="margin: 0; color: #666;">查看已连接的隧道客户端</p>
|
<div class="particle particle-2"></div>
|
||||||
|
<div class="particle particle-3"></div>
|
||||||
|
<div class="particle particle-4"></div>
|
||||||
|
<div class="particle particle-5"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Main content -->
|
||||||
|
<div class="dashboard-content">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="dashboard-header">
|
||||||
|
<h1 class="dashboard-title">仪表盘</h1>
|
||||||
|
<p class="dashboard-subtitle">监控隧道连接和流量状态</p>
|
||||||
</div>
|
</div>
|
||||||
<n-space>
|
|
||||||
<n-button @click="router.push('/plugins')">
|
|
||||||
<template #icon><n-icon><ExtensionPuzzleOutline /></n-icon></template>
|
|
||||||
扩展商店
|
|
||||||
</n-button>
|
|
||||||
<n-button @click="router.push('/update')">
|
|
||||||
<template #icon><n-icon><CloudDownloadOutline /></n-icon></template>
|
|
||||||
系统更新
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</n-space>
|
|
||||||
|
|
||||||
<n-grid :cols="3" :x-gap="16" :y-gap="16" style="margin-bottom: 24px;">
|
<!-- Stats Grid -->
|
||||||
<n-gi>
|
<div class="stats-grid">
|
||||||
<n-card>
|
<!-- 24H Traffic Combined -->
|
||||||
<n-statistic label="总客户端" :value="clients.length" />
|
<div class="stat-card glass-stat">
|
||||||
</n-card>
|
<div class="stat-icon-large traffic-24h">
|
||||||
</n-gi>
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon-lg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<n-gi>
|
<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" />
|
||||||
<n-card>
|
</svg>
|
||||||
<n-statistic label="在线客户端" :value="onlineClients" />
|
</div>
|
||||||
</n-card>
|
<div class="stat-details">
|
||||||
</n-gi>
|
<div class="stat-row">
|
||||||
<n-gi>
|
<span class="stat-title">24H 出站</span>
|
||||||
<n-card>
|
<div class="stat-data">
|
||||||
<n-statistic label="总规则数" :value="totalRules" />
|
<span class="stat-number">{{ formatted24hOutbound.value }}</span>
|
||||||
</n-card>
|
<span class="stat-unit">{{ formatted24hOutbound.unit }}</span>
|
||||||
</n-gi>
|
</div>
|
||||||
</n-grid>
|
|
||||||
|
|
||||||
<n-empty v-if="clients.length === 0" description="暂无客户端连接" />
|
|
||||||
|
|
||||||
<n-grid v-else :cols="3" :x-gap="16" :y-gap="16" responsive="screen" cols-s="1" cols-m="2">
|
|
||||||
<n-gi v-for="client in clients" :key="client.id">
|
|
||||||
<n-card hoverable style="cursor: pointer;" @click="viewClient(client.id)">
|
|
||||||
<n-space justify="space-between" align="center">
|
|
||||||
<div>
|
|
||||||
<h3 style="margin: 0 0 4px 0;">{{ client.nickname || client.id }}</h3>
|
|
||||||
<p v-if="client.nickname" style="margin: 0 0 4px 0; color: #999; font-size: 12px;">{{ client.id }}</p>
|
|
||||||
<p v-if="client.remote_addr && client.online" style="margin: 0 0 8px 0; color: #666; font-size: 12px;">IP: {{ client.remote_addr }}</p>
|
|
||||||
<n-space>
|
|
||||||
<n-tag :type="client.online ? 'success' : 'default'" size="small">
|
|
||||||
{{ client.online ? '在线' : '离线' }}
|
|
||||||
</n-tag>
|
|
||||||
<n-tag type="info" size="small">{{ client.rule_count }} 条规则</n-tag>
|
|
||||||
</n-space>
|
|
||||||
</div>
|
</div>
|
||||||
<n-button size="small" @click.stop="viewClient(client.id)">查看详情</n-button>
|
<div class="stat-row">
|
||||||
</n-space>
|
<span class="stat-title">24H 入站</span>
|
||||||
</n-card>
|
<div class="stat-data">
|
||||||
</n-gi>
|
<span class="stat-number">{{ formatted24hInbound.value }}</span>
|
||||||
</n-grid>
|
<span class="stat-unit">{{ formatted24hInbound.unit }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Total Traffic Combined -->
|
||||||
|
<div class="stat-card glass-stat">
|
||||||
|
<div class="stat-icon-large traffic-total">
|
||||||
|
<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 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>
|
||||||
|
</div>
|
||||||
|
<div class="stat-details">
|
||||||
|
<div class="stat-row">
|
||||||
|
<span class="stat-title">总出站</span>
|
||||||
|
<div class="stat-data">
|
||||||
|
<span class="stat-number">{{ formattedTotalOutbound.value }}</span>
|
||||||
|
<span class="stat-unit">{{ formattedTotalOutbound.unit }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-row">
|
||||||
|
<span class="stat-title">总入站</span>
|
||||||
|
<div class="stat-data">
|
||||||
|
<span class="stat-number">{{ formattedTotalInbound.value }}</span>
|
||||||
|
<span class="stat-unit">{{ formattedTotalInbound.unit }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Client Count -->
|
||||||
|
<div class="stat-card glass-stat">
|
||||||
|
<div class="stat-icon-large clients">
|
||||||
|
<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" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="stat-details">
|
||||||
|
<div class="stat-row">
|
||||||
|
<span class="stat-title">在线客户端</span>
|
||||||
|
<div class="stat-data">
|
||||||
|
<span class="stat-number online">{{ onlineClients }}</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>
|
||||||
|
<div class="online-indicator" :class="{ active: onlineClients > 0 }">
|
||||||
|
<span class="pulse"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Rules Count -->
|
||||||
|
<div class="stat-card glass-stat">
|
||||||
|
<div class="stat-icon-large rules">
|
||||||
|
<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" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="stat-details">
|
||||||
|
<div class="stat-row single">
|
||||||
|
<span class="stat-title">代理规则</span>
|
||||||
|
<div class="stat-data">
|
||||||
|
<span class="stat-number">{{ totalRules }}</span>
|
||||||
|
<span class="stat-unit">条</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Traffic Chart Section -->
|
||||||
|
<div class="chart-section">
|
||||||
|
<div class="section-header">
|
||||||
|
<h2 class="section-title">24小时流量趋势</h2>
|
||||||
|
<div class="chart-legend">
|
||||||
|
<span class="legend-item inbound"><span class="legend-dot"></span>入站</span>
|
||||||
|
<span class="legend-item outbound"><span class="legend-dot"></span>出站</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="chart-card glass-card">
|
||||||
|
<div class="chart-container">
|
||||||
|
<div class="chart-bars">
|
||||||
|
<div v-for="(data, index) in trafficHistory" :key="index" class="bar-group">
|
||||||
|
<div class="bar-wrapper">
|
||||||
|
<div class="bar inbound" :style="{ height: getBarHeight(data.inbound) + '%' }"></div>
|
||||||
|
<div class="bar outbound" :style="{ height: getBarHeight(data.outbound) + '%' }"></div>
|
||||||
|
</div>
|
||||||
|
<span class="bar-label">{{ formatHour(data.timestamp) }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* Container */
|
||||||
|
.dashboard-container {
|
||||||
|
min-height: calc(100vh - 116px);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 动画背景粒子 */
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main content */
|
||||||
|
.dashboard-content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dashboard-header {
|
||||||
|
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 {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
gap: 20px;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.stats-grid {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.stats-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Glass stat card - 毛玻璃效果 */
|
||||||
|
.glass-stat {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
position: relative;
|
||||||
|
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 {
|
||||||
|
background: var(--glass-bg-hover);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: var(--shadow-lg), var(--shadow-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Large Stat icon */
|
||||||
|
.stat-icon-large {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border-radius: 14px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon-large.traffic-24h {
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon-large.traffic-total {
|
||||||
|
background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon-large.clients {
|
||||||
|
background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-icon-large.rules {
|
||||||
|
background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-lg {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stat details */
|
||||||
|
.stat-details {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-row.single {
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-title {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-data {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-number {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-number.online {
|
||||||
|
color: var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-unit {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Online indicator with pulse */
|
||||||
|
.online-indicator {
|
||||||
|
position: absolute;
|
||||||
|
top: 16px;
|
||||||
|
right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.online-indicator .pulse {
|
||||||
|
display: block;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.online-indicator.active .pulse {
|
||||||
|
background: var(--color-success);
|
||||||
|
animation: pulse-animation 2s ease-in-out infinite;
|
||||||
|
box-shadow: 0 0 8px var(--color-success-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse-animation {
|
||||||
|
0%, 100% { box-shadow: 0 0 0 0 var(--color-success-glow); }
|
||||||
|
50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Chart Section */
|
||||||
|
.chart-section {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-legend {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-dot {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-item.inbound .legend-dot {
|
||||||
|
background: #8b5cf6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-item.outbound .legend-dot {
|
||||||
|
background: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Chart Card */
|
||||||
|
.chart-card {
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
height: 200px;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-bars {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
height: 100%;
|
||||||
|
min-width: 600px;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar-group {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar {
|
||||||
|
flex: 1;
|
||||||
|
border-radius: 3px 3px 0 0;
|
||||||
|
min-height: 2px;
|
||||||
|
transition: height 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar.inbound {
|
||||||
|
background: #8b5cf6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar.outbound {
|
||||||
|
background: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bar-label {
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-hint {
|
||||||
|
margin-top: 16px;
|
||||||
|
padding-top: 16px;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Glass card base - 毛玻璃效果 */
|
||||||
|
.glass-card {
|
||||||
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 16px;
|
||||||
|
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>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { NCard, NForm, NFormItem, NInput, NButton, NAlert } from 'naive-ui'
|
|
||||||
import { login, setToken } from '../api'
|
import { login, setToken } from '../api'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -33,51 +32,66 @@ const handleLogin = async () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="login-page">
|
<div class="login-page">
|
||||||
<n-card class="login-card" :bordered="false">
|
<!-- Animated particles -->
|
||||||
<template #header>
|
<div class="particles">
|
||||||
<div class="login-header">
|
<div class="particle particle-1"></div>
|
||||||
<h1 class="logo">GoTunnel</h1>
|
<div class="particle particle-2"></div>
|
||||||
<p class="subtitle">安全的内网穿透工具</p>
|
<div class="particle particle-3"></div>
|
||||||
</div>
|
<div class="particle particle-4"></div>
|
||||||
</template>
|
</div>
|
||||||
|
|
||||||
<n-form @submit.prevent="handleLogin">
|
<!-- Login card -->
|
||||||
<n-form-item label="用户名">
|
<div class="login-card">
|
||||||
<n-input
|
<div class="login-header">
|
||||||
v-model:value="username"
|
<div class="logo-icon">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-8 h-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<h1 class="logo-text">GoTunnel</h1>
|
||||||
|
<p class="subtitle">安全的内网穿透工具</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form @submit.prevent="handleLogin" class="login-form">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">用户名</label>
|
||||||
|
<input
|
||||||
|
v-model="username"
|
||||||
|
type="text"
|
||||||
|
class="glass-input"
|
||||||
placeholder="请输入用户名"
|
placeholder="请输入用户名"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
/>
|
/>
|
||||||
</n-form-item>
|
</div>
|
||||||
|
|
||||||
<n-form-item label="密码">
|
<div class="form-group">
|
||||||
<n-input
|
<label class="form-label">密码</label>
|
||||||
v-model:value="password"
|
<input
|
||||||
|
v-model="password"
|
||||||
type="password"
|
type="password"
|
||||||
|
class="glass-input"
|
||||||
placeholder="请输入密码"
|
placeholder="请输入密码"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
show-password-on="click"
|
|
||||||
/>
|
/>
|
||||||
</n-form-item>
|
</div>
|
||||||
|
|
||||||
<n-alert v-if="error" type="error" :show-icon="true" style="margin-bottom: 16px;">
|
<div v-if="error" class="error-alert">
|
||||||
{{ error }}
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
</n-alert>
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||||
|
</svg>
|
||||||
|
<span>{{ error }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<n-button
|
<button type="submit" class="glass-button" :disabled="loading">
|
||||||
type="primary"
|
<span v-if="loading" class="loading-spinner"></span>
|
||||||
block
|
|
||||||
:loading="loading"
|
|
||||||
attr-type="submit"
|
|
||||||
>
|
|
||||||
{{ loading ? '登录中...' : '登录' }}
|
{{ loading ? '登录中...' : '登录' }}
|
||||||
</n-button>
|
</button>
|
||||||
</n-form>
|
</form>
|
||||||
|
|
||||||
<template #footer>
|
<div class="login-footer">
|
||||||
<div class="login-footer">欢迎使用 GoTunnel</div>
|
<span>欢迎使用 GoTunnel</span>
|
||||||
</template>
|
</div>
|
||||||
</n-card>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -87,36 +101,258 @@ const handleLogin = async () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
|
background: var(--gradient-bg);
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 动画背景粒子 */
|
||||||
|
.particles {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.particle {
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 50%;
|
||||||
|
opacity: 0.2;
|
||||||
|
filter: blur(60px);
|
||||||
|
animation: float 20s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.particle-1 {
|
||||||
|
width: 400px;
|
||||||
|
height: 400px;
|
||||||
|
background: var(--color-accent);
|
||||||
|
top: -100px;
|
||||||
|
right: -100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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: 20%;
|
||||||
|
animation-delay: -10s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.particle-4 {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
background: #ec4899;
|
||||||
|
bottom: 30%;
|
||||||
|
right: 10%;
|
||||||
|
animation-delay: -15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Login card - 毛玻璃效果 */
|
||||||
.login-card {
|
.login-card {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
|
background: var(--glass-bg);
|
||||||
|
backdrop-filter: var(--glass-blur);
|
||||||
|
-webkit-backdrop-filter: var(--glass-blur);
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
padding: 48px 36px;
|
||||||
|
position: relative;
|
||||||
|
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 */
|
||||||
.login-header {
|
.login-header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: 36px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo-icon {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
margin: 0 auto 20px;
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
border-radius: 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-shadow: 0 8px 24px var(--color-accent-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-icon svg {
|
||||||
|
color: white;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-text {
|
||||||
font-size: 28px;
|
font-size: 28px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #18a058;
|
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: #666;
|
color: var(--color-text-secondary);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-footer {
|
/* Form */
|
||||||
text-align: center;
|
.login-form {
|
||||||
color: #999;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.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: 12px;
|
||||||
|
padding: 14px 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-input:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Error alert */
|
||||||
|
.error-alert {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--color-error);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-alert svg {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button */
|
||||||
|
.glass-button {
|
||||||
|
background: var(--gradient-accent);
|
||||||
|
border: none;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 14px 24px;
|
||||||
|
color: white;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
box-shadow: 0 4px 15px var(--color-accent-glow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-button:hover:not(:disabled) {
|
||||||
|
box-shadow: 0 6px 20px var(--color-accent-glow);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
filter: brightness(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-button:active:not(:disabled) {
|
||||||
|
transform: translateY(0) scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-button:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loading spinner */
|
||||||
|
.loading-spinner {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||||
|
border-top-color: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Footer */
|
||||||
|
.login-footer {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 28px;
|
||||||
|
padding-top: 24px;
|
||||||
|
border-top: 1px solid var(--color-border);
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,576 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref, onMounted, computed } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import {
|
|
||||||
NCard, NButton, NSpace, NTag, NStatistic, NGrid, NGi,
|
|
||||||
NEmpty, NSpin, NIcon, NSwitch, NTabs, NTabPane, useMessage,
|
|
||||||
NSelect, NModal, NInput, NInputNumber
|
|
||||||
} from 'naive-ui'
|
|
||||||
import { ArrowBackOutline, ExtensionPuzzleOutline, StorefrontOutline, CodeSlashOutline, SettingsOutline } from '@vicons/ionicons5'
|
|
||||||
import {
|
|
||||||
getPlugins, enablePlugin, disablePlugin, getStorePlugins, getJSPlugins,
|
|
||||||
pushJSPluginToClient, getClients, installStorePlugin, updateJSPluginConfig, setJSPluginEnabled
|
|
||||||
} from '../api'
|
|
||||||
import type { PluginInfo, StorePluginInfo, JSPlugin, ClientStatus } from '../types'
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const message = useMessage()
|
|
||||||
const plugins = ref<PluginInfo[]>([])
|
|
||||||
const storePlugins = ref<StorePluginInfo[]>([])
|
|
||||||
const jsPlugins = ref<JSPlugin[]>([])
|
|
||||||
const clients = ref<ClientStatus[]>([])
|
|
||||||
const loading = ref(true)
|
|
||||||
const storeLoading = ref(false)
|
|
||||||
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 loadStorePlugins = async () => {
|
|
||||||
storeLoading.value = true
|
|
||||||
try {
|
|
||||||
const { data } = await getStorePlugins()
|
|
||||||
storePlugins.value = data.plugins || []
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to load store plugins', e)
|
|
||||||
} finally {
|
|
||||||
storeLoading.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 getTypeColor = (type: string) => {
|
|
||||||
const colors: Record<string, 'info' | 'success' | 'warning' | 'error' | 'default'> = {
|
|
||||||
proxy: 'info',
|
|
||||||
app: 'success',
|
|
||||||
service: 'warning',
|
|
||||||
tool: 'default'
|
|
||||||
}
|
|
||||||
return colors[type] || 'default'
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleTabChange = (tab: string) => {
|
|
||||||
if (tab === 'store' && storePlugins.value.length === 0) {
|
|
||||||
loadStorePlugins()
|
|
||||||
}
|
|
||||||
if (tab === 'js' && jsPlugins.value.length === 0) {
|
|
||||||
loadJSPlugins()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// JS 插件相关
|
|
||||||
/* 安全加固:暂时禁用创建/删除功能
|
|
||||||
const showJSModal = ref(false)
|
|
||||||
const jsForm = ref<JSPlugin>({...})
|
|
||||||
const configItems = ref<Array<{ key: string; value: string }>>([])
|
|
||||||
const configToObject = () => {...}
|
|
||||||
const handleCreateJSPlugin = async () => {...}
|
|
||||||
const handleDeleteJSPlugin = async (name: string) => {...}
|
|
||||||
const resetJSForm = () => {...}
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 插件推送相关
|
|
||||||
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} 到 ${pushClientId.value},监听端口: ${pushRemotePort.value || '未指定'}`)
|
|
||||||
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 插件配置相关
|
|
||||||
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
|
|
||||||
// 将 config 转换为数组形式便于编辑
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 切换 JS 插件启用状态
|
|
||||||
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 || '操作失败')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 商店插件安装相关
|
|
||||||
const showInstallModal = ref(false)
|
|
||||||
const selectedStorePlugin = ref<StorePluginInfo | null>(null)
|
|
||||||
const selectedClientId = ref('')
|
|
||||||
const installing = ref(false)
|
|
||||||
const installRemotePort = ref<number | null>(8080)
|
|
||||||
const installAuthEnabled = ref(false)
|
|
||||||
const installAuthUsername = ref('')
|
|
||||||
const installAuthPassword = ref('')
|
|
||||||
|
|
||||||
const openInstallModal = (plugin: StorePluginInfo) => {
|
|
||||||
selectedStorePlugin.value = plugin
|
|
||||||
selectedClientId.value = ''
|
|
||||||
installRemotePort.value = 8080
|
|
||||||
installAuthEnabled.value = false
|
|
||||||
installAuthUsername.value = ''
|
|
||||||
installAuthPassword.value = ''
|
|
||||||
showInstallModal.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleInstallStorePlugin = async () => {
|
|
||||||
if (!selectedStorePlugin.value || !selectedClientId.value) {
|
|
||||||
message.warning('请选择要安装到的客户端')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!selectedStorePlugin.value.download_url) {
|
|
||||||
message.error('该插件没有下载地址')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!selectedStorePlugin.value.signature_url) {
|
|
||||||
message.error('该插件没有签名文件')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
installing.value = true
|
|
||||||
try {
|
|
||||||
await installStorePlugin(
|
|
||||||
selectedStorePlugin.value.name,
|
|
||||||
selectedStorePlugin.value.download_url,
|
|
||||||
selectedStorePlugin.value.signature_url,
|
|
||||||
selectedClientId.value,
|
|
||||||
installRemotePort.value || 8080,
|
|
||||||
selectedStorePlugin.value.version,
|
|
||||||
selectedStorePlugin.value.config_schema,
|
|
||||||
installAuthEnabled.value,
|
|
||||||
installAuthUsername.value,
|
|
||||||
installAuthPassword.value
|
|
||||||
)
|
|
||||||
message.success(`已安装 ${selectedStorePlugin.value.name}`)
|
|
||||||
showInstallModal.value = false
|
|
||||||
} catch (e: any) {
|
|
||||||
message.error(e.response?.data || '安装失败')
|
|
||||||
} finally {
|
|
||||||
installing.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
loadPlugins()
|
|
||||||
loadClients()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="plugins-view">
|
|
||||||
<n-space justify="space-between" align="center" style="margin-bottom: 24px;">
|
|
||||||
<div>
|
|
||||||
<h2 style="margin: 0 0 8px 0;">插件管理</h2>
|
|
||||||
<p style="margin: 0; color: #666;">管理已安装插件和浏览插件商店</p>
|
|
||||||
</div>
|
|
||||||
<n-button quaternary @click="router.push('/')">
|
|
||||||
<template #icon><n-icon><ArrowBackOutline /></n-icon></template>
|
|
||||||
返回首页
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
|
|
||||||
<n-tabs v-model:value="activeTab" type="line" @update:value="handleTabChange">
|
|
||||||
<!-- 已安装插件 -->
|
|
||||||
<n-tab-pane name="installed" tab="已安装插件">
|
|
||||||
<n-spin :show="loading">
|
|
||||||
<n-grid :cols="3" :x-gap="16" :y-gap="16" style="margin-bottom: 24px;">
|
|
||||||
<n-gi>
|
|
||||||
<n-card>
|
|
||||||
<n-statistic label="总插件数" :value="plugins.length" />
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<n-card>
|
|
||||||
<n-statistic label="协议插件" :value="proxyPlugins.length" />
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<n-card>
|
|
||||||
<n-statistic label="应用插件" :value="appPlugins.length" />
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
|
|
||||||
<n-empty v-if="!loading && plugins.length === 0" description="暂无已安装插件" />
|
|
||||||
|
|
||||||
<n-grid v-else :cols="3" :x-gap="16" :y-gap="16" responsive="screen" cols-s="1" cols-m="2">
|
|
||||||
<n-gi v-for="plugin in plugins" :key="plugin.name">
|
|
||||||
<n-card hoverable>
|
|
||||||
<template #header>
|
|
||||||
<n-space align="center">
|
|
||||||
<img v-if="plugin.icon" :src="plugin.icon" style="width: 24px; height: 24px;" />
|
|
||||||
<n-icon v-else size="24" color="#18a058"><ExtensionPuzzleOutline /></n-icon>
|
|
||||||
<span>{{ plugin.name }}</span>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
<template #header-extra>
|
|
||||||
<n-switch :value="plugin.enabled" @update:value="togglePlugin(plugin)" />
|
|
||||||
</template>
|
|
||||||
<n-space vertical :size="8">
|
|
||||||
<n-space>
|
|
||||||
<n-tag size="small">v{{ plugin.version }}</n-tag>
|
|
||||||
<n-tag size="small" :type="getTypeColor(plugin.type)">
|
|
||||||
{{ getTypeLabel(plugin.type) }}
|
|
||||||
</n-tag>
|
|
||||||
<n-tag size="small" :type="plugin.source === 'builtin' ? 'default' : 'info'">
|
|
||||||
{{ plugin.source === 'builtin' ? '内置' : 'JS' }}
|
|
||||||
</n-tag>
|
|
||||||
</n-space>
|
|
||||||
<p style="margin: 0; color: #666;">{{ plugin.description }}</p>
|
|
||||||
</n-space>
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
</n-spin>
|
|
||||||
</n-tab-pane>
|
|
||||||
|
|
||||||
<!-- 插件商店 -->
|
|
||||||
<n-tab-pane name="store" tab="插件商店">
|
|
||||||
<n-spin :show="storeLoading">
|
|
||||||
<n-empty v-if="!storeLoading && storePlugins.length === 0" description="插件商店暂无可用插件" />
|
|
||||||
|
|
||||||
<n-grid v-else :cols="3" :x-gap="16" :y-gap="16" responsive="screen" cols-s="1" cols-m="2">
|
|
||||||
<n-gi v-for="plugin in storePlugins" :key="plugin.name">
|
|
||||||
<n-card hoverable>
|
|
||||||
<template #header>
|
|
||||||
<n-space align="center">
|
|
||||||
<img v-if="plugin.icon" :src="plugin.icon" style="width: 24px; height: 24px;" />
|
|
||||||
<n-icon v-else size="24" color="#18a058"><StorefrontOutline /></n-icon>
|
|
||||||
<span>{{ plugin.name }}</span>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
<template #header-extra>
|
|
||||||
<n-button
|
|
||||||
v-if="plugin.download_url && plugin.signature_url && onlineClients.length > 0"
|
|
||||||
size="small"
|
|
||||||
type="primary"
|
|
||||||
@click="openInstallModal(plugin)"
|
|
||||||
>
|
|
||||||
安装
|
|
||||||
</n-button>
|
|
||||||
</template>
|
|
||||||
<n-space vertical :size="8">
|
|
||||||
<n-space>
|
|
||||||
<n-tag size="small">v{{ plugin.version }}</n-tag>
|
|
||||||
<n-tag size="small" :type="getTypeColor(plugin.type)">
|
|
||||||
{{ getTypeLabel(plugin.type) }}
|
|
||||||
</n-tag>
|
|
||||||
</n-space>
|
|
||||||
<p style="margin: 0; color: #666;">{{ plugin.description }}</p>
|
|
||||||
<p style="margin: 0; color: #999; font-size: 12px;">作者: {{ plugin.author }}</p>
|
|
||||||
</n-space>
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
</n-spin>
|
|
||||||
</n-tab-pane>
|
|
||||||
|
|
||||||
<!-- JS 插件 -->
|
|
||||||
<n-tab-pane name="js" tab="JS 插件">
|
|
||||||
<n-spin :show="jsLoading">
|
|
||||||
<n-empty v-if="!jsLoading && jsPlugins.length === 0" description="暂无 JS 插件" />
|
|
||||||
|
|
||||||
<n-grid v-else :cols="2" :x-gap="16" :y-gap="16" responsive="screen" cols-s="1">
|
|
||||||
<n-gi v-for="plugin in jsPlugins" :key="plugin.name">
|
|
||||||
<n-card hoverable>
|
|
||||||
<template #header>
|
|
||||||
<n-space align="center">
|
|
||||||
<n-icon size="24" color="#f0a020"><CodeSlashOutline /></n-icon>
|
|
||||||
<span>{{ plugin.name }}</span>
|
|
||||||
<n-tag v-if="plugin.version" size="small">v{{ plugin.version }}</n-tag>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
<template #header-extra>
|
|
||||||
<n-switch :value="plugin.enabled" @update:value="toggleJSPlugin(plugin)" />
|
|
||||||
</template>
|
|
||||||
<n-space vertical :size="8">
|
|
||||||
<n-space>
|
|
||||||
<n-tag size="small" type="warning">JS</n-tag>
|
|
||||||
<n-tag v-if="plugin.auto_start" size="small" type="success">自动启动</n-tag>
|
|
||||||
<n-tag v-if="plugin.signature" size="small" type="info">已签名</n-tag>
|
|
||||||
</n-space>
|
|
||||||
<p style="margin: 0; color: #666;">{{ plugin.description || '无描述' }}</p>
|
|
||||||
<p v-if="plugin.author" style="margin: 0; color: #999; font-size: 12px;">作者: {{ plugin.author }}</p>
|
|
||||||
|
|
||||||
<!-- 配置预览 -->
|
|
||||||
<div v-if="Object.keys(plugin.config || {}).length > 0" style="margin-top: 8px;">
|
|
||||||
<p style="margin: 0 0 4px 0; color: #999; font-size: 12px;">配置:</p>
|
|
||||||
<n-space :size="4" wrap>
|
|
||||||
<n-tag v-for="(value, key) in plugin.config" :key="key" size="small" type="default">
|
|
||||||
{{ key }}: {{ value.length > 10 ? value.slice(0, 10) + '...' : value }}
|
|
||||||
</n-tag>
|
|
||||||
</n-space>
|
|
||||||
</div>
|
|
||||||
</n-space>
|
|
||||||
<template #action>
|
|
||||||
<n-space justify="space-between">
|
|
||||||
<n-button size="small" quaternary @click="openJSConfigModal(plugin)">
|
|
||||||
<template #icon><n-icon><SettingsOutline /></n-icon></template>
|
|
||||||
配置
|
|
||||||
</n-button>
|
|
||||||
<n-button
|
|
||||||
v-if="onlineClients.length > 0"
|
|
||||||
size="small"
|
|
||||||
type="primary"
|
|
||||||
@click="openPushModal(plugin)"
|
|
||||||
>
|
|
||||||
推送到客户端
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
</n-spin>
|
|
||||||
</n-tab-pane>
|
|
||||||
</n-tabs>
|
|
||||||
|
|
||||||
<!-- 安全加固:暂时禁用创建 JS 插件 Modal
|
|
||||||
<n-modal v-model:show="showJSModal" preset="card" title="新建 JS 插件" style="width: 600px;">
|
|
||||||
... 已屏蔽 ...
|
|
||||||
</n-modal>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- 安装商店插件模态框 -->
|
|
||||||
<n-modal v-model:show="showInstallModal" preset="card" title="安装插件" style="width: 450px;">
|
|
||||||
<n-space vertical :size="16">
|
|
||||||
<div v-if="selectedStorePlugin">
|
|
||||||
<p style="margin: 0 0 8px 0;"><strong>插件:</strong> {{ selectedStorePlugin.name }}</p>
|
|
||||||
<p style="margin: 0; color: #666;">{{ selectedStorePlugin.description }}</p>
|
|
||||||
</div>
|
|
||||||
<n-select
|
|
||||||
v-model:value="selectedClientId"
|
|
||||||
placeholder="选择要安装到的客户端"
|
|
||||||
:options="onlineClients.map(c => ({ label: c.nickname || c.id, value: c.id }))"
|
|
||||||
/>
|
|
||||||
<div>
|
|
||||||
<p style="margin: 0 0 8px 0; color: #666; font-size: 13px;">远程端口:</p>
|
|
||||||
<n-input-number
|
|
||||||
v-model:value="installRemotePort"
|
|
||||||
:min="1"
|
|
||||||
:max="65535"
|
|
||||||
placeholder="输入端口号"
|
|
||||||
style="width: 100%;"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<n-space align="center" :size="8">
|
|
||||||
<n-switch v-model:value="installAuthEnabled" />
|
|
||||||
<span style="color: #666;">启用 HTTP Basic Auth</span>
|
|
||||||
</n-space>
|
|
||||||
</div>
|
|
||||||
<template v-if="installAuthEnabled">
|
|
||||||
<n-input v-model:value="installAuthUsername" placeholder="用户名" />
|
|
||||||
<n-input v-model:value="installAuthPassword" type="password" placeholder="密码" show-password-on="click" />
|
|
||||||
</template>
|
|
||||||
</n-space>
|
|
||||||
<template #footer>
|
|
||||||
<n-space justify="end">
|
|
||||||
<n-button @click="showInstallModal = false">取消</n-button>
|
|
||||||
<n-button
|
|
||||||
type="primary"
|
|
||||||
:loading="installing"
|
|
||||||
:disabled="!selectedClientId"
|
|
||||||
@click="handleInstallStorePlugin"
|
|
||||||
>
|
|
||||||
安装
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
</n-modal>
|
|
||||||
|
|
||||||
<!-- JS 插件配置模态框 -->
|
|
||||||
<n-modal v-model:show="showJSConfigModal" preset="card" :title="`${currentJSPlugin?.name || ''} 配置`" style="width: 500px;">
|
|
||||||
<n-space vertical :size="12">
|
|
||||||
<p style="margin: 0; color: #666; font-size: 13px;">编辑插件配置参数(键值对形式)</p>
|
|
||||||
<div v-for="(item, index) in jsConfigItems" :key="index">
|
|
||||||
<n-space :size="8" align="center">
|
|
||||||
<n-input v-model:value="item.key" placeholder="参数名" style="width: 150px;" />
|
|
||||||
<n-input v-model:value="item.value" placeholder="参数值" style="width: 200px;" />
|
|
||||||
<n-button v-if="jsConfigItems.length > 1" quaternary type="error" size="small" @click="removeJSConfigItem(index)">
|
|
||||||
删除
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</div>
|
|
||||||
<n-button dashed size="small" @click="addJSConfigItem">添加配置项</n-button>
|
|
||||||
</n-space>
|
|
||||||
<template #footer>
|
|
||||||
<n-space justify="end">
|
|
||||||
<n-button @click="showJSConfigModal = false">取消</n-button>
|
|
||||||
<n-button type="primary" :loading="jsConfigSaving" @click="saveJSPluginConfig">保存</n-button>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
</n-modal>
|
|
||||||
|
|
||||||
<!-- JS 插件推送模态框 -->
|
|
||||||
<n-modal v-model:show="showPushModal" preset="card" title="推送插件到客户端" style="width: 400px;">
|
|
||||||
<n-space vertical :size="16">
|
|
||||||
<div v-if="selectedJSPlugin">
|
|
||||||
<p style="margin: 0 0 8px 0;"><strong>插件:</strong> {{ selectedJSPlugin.name }}</p>
|
|
||||||
<p style="margin: 0; color: #666;">{{ selectedJSPlugin.description || '无描述' }}</p>
|
|
||||||
</div>
|
|
||||||
<n-select
|
|
||||||
v-model:value="pushClientId"
|
|
||||||
placeholder="选择要推送到的客户端"
|
|
||||||
:options="onlineClients.map(c => ({ label: c.nickname || c.id, value: c.id }))"
|
|
||||||
/>
|
|
||||||
<div>
|
|
||||||
<p style="margin: 0 0 8px 0; color: #666; font-size: 13px;">远程端口(服务端监听端口):</p>
|
|
||||||
<n-input-number
|
|
||||||
v-model:value="pushRemotePort"
|
|
||||||
:min="1"
|
|
||||||
:max="65535"
|
|
||||||
placeholder="输入端口号"
|
|
||||||
style="width: 100%;"
|
|
||||||
/>
|
|
||||||
<p style="margin: 8px 0 0 0; color: #999; font-size: 12px;">用户可以通过 服务端IP:端口 访问此插件提供的服务</p>
|
|
||||||
</div>
|
|
||||||
</n-space>
|
|
||||||
<template #footer>
|
|
||||||
<n-space justify="end">
|
|
||||||
<n-button @click="showPushModal = false">取消</n-button>
|
|
||||||
<n-button
|
|
||||||
type="primary"
|
|
||||||
:loading="pushing"
|
|
||||||
:disabled="!pushClientId"
|
|
||||||
@click="handlePushJSPlugin"
|
|
||||||
>
|
|
||||||
推送
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
</n-modal>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
550
web/src/views/SettingsView.vue
Normal file
550
web/src/views/SettingsView.vue
Normal file
@@ -0,0 +1,550 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { ServerOutline, SettingsOutline, SaveOutline } from '@vicons/ionicons5'
|
||||||
|
import { useToast } from '../composables/useToast'
|
||||||
|
import {
|
||||||
|
getVersionInfo, getServerConfig, updateServerConfig,
|
||||||
|
type VersionInfo, type ServerConfigResponse
|
||||||
|
} from '../api'
|
||||||
|
|
||||||
|
const message = useToast()
|
||||||
|
|
||||||
|
const versionInfo = ref<VersionInfo | null>(null)
|
||||||
|
const loading = ref(true)
|
||||||
|
|
||||||
|
// 服务器配置
|
||||||
|
const serverConfig = ref<ServerConfigResponse | null>(null)
|
||||||
|
const configLoading = ref(false)
|
||||||
|
const savingConfig = ref(false)
|
||||||
|
|
||||||
|
// 配置表单
|
||||||
|
const configForm = ref({
|
||||||
|
heartbeat_sec: 30,
|
||||||
|
heartbeat_timeout: 90,
|
||||||
|
web_username: '',
|
||||||
|
web_password: '',
|
||||||
|
plugin_store_url: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const loadVersionInfo = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await getVersionInfo()
|
||||||
|
versionInfo.value = data
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load version info', e)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadServerConfig = async () => {
|
||||||
|
configLoading.value = true
|
||||||
|
try {
|
||||||
|
const { data } = await getServerConfig()
|
||||||
|
serverConfig.value = data
|
||||||
|
// 填充表单
|
||||||
|
configForm.value = {
|
||||||
|
heartbeat_sec: data.server.heartbeat_sec,
|
||||||
|
heartbeat_timeout: data.server.heartbeat_timeout,
|
||||||
|
web_username: data.web.username,
|
||||||
|
web_password: '',
|
||||||
|
plugin_store_url: data.plugin_store.url
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load server config', e)
|
||||||
|
} finally {
|
||||||
|
configLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSaveConfig = async () => {
|
||||||
|
savingConfig.value = true
|
||||||
|
try {
|
||||||
|
const updateReq: any = {
|
||||||
|
server: {
|
||||||
|
heartbeat_sec: configForm.value.heartbeat_sec,
|
||||||
|
heartbeat_timeout: configForm.value.heartbeat_timeout
|
||||||
|
},
|
||||||
|
web: {
|
||||||
|
username: configForm.value.web_username
|
||||||
|
},
|
||||||
|
plugin_store: {
|
||||||
|
url: configForm.value.plugin_store_url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 只有填写了密码才更新
|
||||||
|
if (configForm.value.web_password) {
|
||||||
|
updateReq.web.password = configForm.value.web_password
|
||||||
|
}
|
||||||
|
await updateServerConfig(updateReq)
|
||||||
|
message.success('配置已保存,部分配置需要重启服务后生效')
|
||||||
|
configForm.value.web_password = ''
|
||||||
|
} catch (e: any) {
|
||||||
|
message.error(e.response?.data || '保存配置失败')
|
||||||
|
} finally {
|
||||||
|
savingConfig.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadVersionInfo()
|
||||||
|
loadServerConfig()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="settings-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="settings-content">
|
||||||
|
<!-- Header -->
|
||||||
|
<div class="page-header">
|
||||||
|
<h1 class="page-title">系统设置</h1>
|
||||||
|
<p class="page-subtitle">管理服务端配置和系统更新</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Version Info Card -->
|
||||||
|
<div class="glass-card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3>版本信息</h3>
|
||||||
|
<ServerOutline class="header-icon" />
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div v-if="loading" class="loading-state">加载中...</div>
|
||||||
|
<div v-else-if="versionInfo" class="info-grid">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-label">版本号</span>
|
||||||
|
<span class="info-value">{{ versionInfo.version }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-label">Git 提交</span>
|
||||||
|
<span class="info-value mono">{{ versionInfo.git_commit?.slice(0, 8) || 'N/A' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-label">构建时间</span>
|
||||||
|
<span class="info-value">{{ versionInfo.build_time || 'N/A' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-label">Go 版本</span>
|
||||||
|
<span class="info-value">{{ versionInfo.go_version }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-label">操作系统</span>
|
||||||
|
<span class="info-value">{{ versionInfo.os }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-label">架构</span>
|
||||||
|
<span class="info-value">{{ versionInfo.arch }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="empty-state">无法加载版本信息</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Server Config Card -->
|
||||||
|
<div class="glass-card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3>服务器配置</h3>
|
||||||
|
<SettingsOutline class="header-icon" />
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div v-if="configLoading" class="loading-state">加载中...</div>
|
||||||
|
<div v-else-if="serverConfig" class="config-form">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">心跳间隔 (秒)</label>
|
||||||
|
<input
|
||||||
|
v-model.number="configForm.heartbeat_sec"
|
||||||
|
type="number"
|
||||||
|
class="glass-input"
|
||||||
|
min="1"
|
||||||
|
max="300"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">心跳超时 (秒)</label>
|
||||||
|
<input
|
||||||
|
v-model.number="configForm.heartbeat_timeout"
|
||||||
|
type="number"
|
||||||
|
class="glass-input"
|
||||||
|
min="1"
|
||||||
|
max="600"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-divider"></div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Web 用户名</label>
|
||||||
|
<input
|
||||||
|
v-model="configForm.web_username"
|
||||||
|
type="text"
|
||||||
|
class="glass-input"
|
||||||
|
placeholder="admin"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Web 密码</label>
|
||||||
|
<input
|
||||||
|
v-model="configForm.web_password"
|
||||||
|
type="password"
|
||||||
|
class="glass-input"
|
||||||
|
placeholder="留空则不修改"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-divider"></div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">插件商店地址</label>
|
||||||
|
<input
|
||||||
|
v-model="configForm.plugin_store_url"
|
||||||
|
type="text"
|
||||||
|
class="glass-input"
|
||||||
|
placeholder="https://git.92coco.cn/flik/GoTunnel-Plugins/raw/branch/main/store.json"
|
||||||
|
/>
|
||||||
|
<span class="form-hint">插件商店的 API 地址,留空使用默认地址</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<button
|
||||||
|
class="glass-btn primary"
|
||||||
|
:disabled="savingConfig"
|
||||||
|
@click="handleSaveConfig"
|
||||||
|
>
|
||||||
|
<SaveOutline class="btn-icon" />
|
||||||
|
保存配置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="empty-state">无法加载配置信息</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.settings-page {
|
||||||
|
min-height: calc(100vh - 108px);
|
||||||
|
background: transparent;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide particles */
|
||||||
|
.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: 350px;
|
||||||
|
height: 350px;
|
||||||
|
background: var(--color-accent);
|
||||||
|
top: -80px;
|
||||||
|
right: -80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.particle-2 {
|
||||||
|
width: 280px;
|
||||||
|
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 {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
max-width: 900px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
margin: 0 0 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-subtitle {
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Glass Card */
|
||||||
|
.glass-card {
|
||||||
|
background: var(--color-bg-tertiary);
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid var(--color-border-light);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-body {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Info Grid */
|
||||||
|
.info-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.info-grid { grid-template-columns: repeat(2, 1fr); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-value {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-value.mono {
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* States */
|
||||||
|
.loading-state, .empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 32px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update Alert */
|
||||||
|
.update-alert {
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-alert.success {
|
||||||
|
background: rgba(0, 186, 124, 0.15);
|
||||||
|
border: 1px solid rgba(0, 186, 124, 0.3);
|
||||||
|
color: var(--color-success);
|
||||||
|
}
|
||||||
|
|
||||||
|
.update-alert.info {
|
||||||
|
background: rgba(29, 155, 240, 0.15);
|
||||||
|
border: 1px solid rgba(29, 155, 240, 0.3);
|
||||||
|
color: var(--color-info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Download Info */
|
||||||
|
.download-info {
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release Note */
|
||||||
|
.release-note {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.release-note pre {
|
||||||
|
margin: 0;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
background: var(--color-bg-elevated);
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
max-height: 150px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Glass Button */
|
||||||
|
.glass-btn {
|
||||||
|
background: var(--color-bg-elevated);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-btn:hover:not(:disabled) {
|
||||||
|
background: var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-btn.small {
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-btn.primary {
|
||||||
|
background: var(--color-accent);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-btn.primary:hover:not(:disabled) {
|
||||||
|
background: var(--color-accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Icon styles */
|
||||||
|
.header-icon {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-icon {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Config Form */
|
||||||
|
.config-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-hint {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 500px) {
|
||||||
|
.form-row {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--color-border-light);
|
||||||
|
margin: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Glass Input */
|
||||||
|
.glass-input {
|
||||||
|
background: var(--color-bg-elevated);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
font-size: 14px;
|
||||||
|
outline: none;
|
||||||
|
transition: all 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-input:focus {
|
||||||
|
border-color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-input::placeholder {
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,328 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref, onMounted, computed } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import {
|
|
||||||
NCard, NButton, NSpace, NTag, NGrid, NGi, NEmpty, NSpin, NIcon,
|
|
||||||
NAlert, NSelect, useMessage, useDialog
|
|
||||||
} from 'naive-ui'
|
|
||||||
import { ArrowBackOutline, CloudDownloadOutline, RefreshOutline, RocketOutline } from '@vicons/ionicons5'
|
|
||||||
import {
|
|
||||||
getVersionInfo, checkServerUpdate, checkClientUpdate, applyServerUpdate, applyClientUpdate,
|
|
||||||
getClients, type UpdateInfo, type VersionInfo
|
|
||||||
} from '../api'
|
|
||||||
import type { ClientStatus } from '../types'
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const message = useMessage()
|
|
||||||
const dialog = useDialog()
|
|
||||||
|
|
||||||
const versionInfo = ref<VersionInfo | null>(null)
|
|
||||||
const serverUpdate = ref<UpdateInfo | null>(null)
|
|
||||||
const clientUpdate = ref<UpdateInfo | null>(null)
|
|
||||||
const clients = ref<ClientStatus[]>([])
|
|
||||||
const loading = ref(true)
|
|
||||||
const checkingServer = ref(false)
|
|
||||||
const checkingClient = ref(false)
|
|
||||||
const updatingServer = ref(false)
|
|
||||||
const selectedClientId = ref('')
|
|
||||||
|
|
||||||
const onlineClients = computed(() => clients.value.filter(c => c.online))
|
|
||||||
|
|
||||||
const loadVersionInfo = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await getVersionInfo()
|
|
||||||
versionInfo.value = data
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to load version info', e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const loadClients = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await getClients()
|
|
||||||
clients.value = data || []
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to load clients', e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCheckServerUpdate = async () => {
|
|
||||||
checkingServer.value = true
|
|
||||||
try {
|
|
||||||
const { data } = await checkServerUpdate()
|
|
||||||
serverUpdate.value = data
|
|
||||||
if (data.available) {
|
|
||||||
message.success('发现新版本: ' + data.latest)
|
|
||||||
} else {
|
|
||||||
message.info('已是最新版本')
|
|
||||||
}
|
|
||||||
} catch (e: any) {
|
|
||||||
message.error(e.response?.data || '检查更新失败')
|
|
||||||
} finally {
|
|
||||||
checkingServer.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleCheckClientUpdate = async () => {
|
|
||||||
checkingClient.value = true
|
|
||||||
try {
|
|
||||||
const { data } = await checkClientUpdate()
|
|
||||||
clientUpdate.value = data
|
|
||||||
if (data.download_url) {
|
|
||||||
message.success('找到客户端更新包: ' + data.latest)
|
|
||||||
} else {
|
|
||||||
message.warning('未找到对应平台的更新包')
|
|
||||||
}
|
|
||||||
} catch (e: any) {
|
|
||||||
message.error(e.response?.data || '检查更新失败')
|
|
||||||
} finally {
|
|
||||||
checkingClient.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleApplyServerUpdate = () => {
|
|
||||||
if (!serverUpdate.value?.download_url) {
|
|
||||||
message.error('没有可用的下载链接')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.warning({
|
|
||||||
title: '确认更新服务端',
|
|
||||||
content: `即将更新服务端到 ${serverUpdate.value.latest},更新后服务器将自动重启。确定要继续吗?`,
|
|
||||||
positiveText: '更新并重启',
|
|
||||||
negativeText: '取消',
|
|
||||||
onPositiveClick: async () => {
|
|
||||||
updatingServer.value = true
|
|
||||||
try {
|
|
||||||
await applyServerUpdate(serverUpdate.value!.download_url)
|
|
||||||
message.success('更新已开始,服务器将在几秒后重启')
|
|
||||||
// 显示倒计时或等待
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload()
|
|
||||||
}, 5000)
|
|
||||||
} catch (e: any) {
|
|
||||||
message.error(e.response?.data || '更新失败')
|
|
||||||
updatingServer.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleApplyClientUpdate = async () => {
|
|
||||||
if (!selectedClientId.value) {
|
|
||||||
message.warning('请选择要更新的客户端')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clientUpdate.value?.download_url) {
|
|
||||||
message.error('没有可用的下载链接')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const clientName = onlineClients.value.find(c => c.id === selectedClientId.value)?.nickname || selectedClientId.value
|
|
||||||
|
|
||||||
dialog.warning({
|
|
||||||
title: '确认更新客户端',
|
|
||||||
content: `即将更新客户端 "${clientName}" 到 ${clientUpdate.value.latest},更新后客户端将自动重启。确定要继续吗?`,
|
|
||||||
positiveText: '更新',
|
|
||||||
negativeText: '取消',
|
|
||||||
onPositiveClick: async () => {
|
|
||||||
try {
|
|
||||||
await applyClientUpdate(selectedClientId.value, clientUpdate.value!.download_url)
|
|
||||||
message.success(`更新命令已发送到客户端 ${clientName}`)
|
|
||||||
} catch (e: any) {
|
|
||||||
message.error(e.response?.data || '更新失败')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatBytes = (bytes: number): string => {
|
|
||||||
if (bytes === 0) return '0 B'
|
|
||||||
const k = 1024
|
|
||||||
const sizes = ['B', 'KB', 'MB', 'GB']
|
|
||||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
||||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
await Promise.all([loadVersionInfo(), loadClients()])
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="update-view">
|
|
||||||
<n-space justify="space-between" align="center" style="margin-bottom: 24px;">
|
|
||||||
<div>
|
|
||||||
<h2 style="margin: 0 0 8px 0;">系统更新</h2>
|
|
||||||
<p style="margin: 0; color: #666;">检查并应用服务端和客户端更新</p>
|
|
||||||
</div>
|
|
||||||
<n-button quaternary @click="router.push('/')">
|
|
||||||
<template #icon><n-icon><ArrowBackOutline /></n-icon></template>
|
|
||||||
返回首页
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
|
|
||||||
<n-spin :show="loading">
|
|
||||||
<!-- 当前版本信息 -->
|
|
||||||
<n-card title="当前版本" style="margin-bottom: 16px;">
|
|
||||||
<n-grid v-if="versionInfo" :cols="6" :x-gap="16" responsive="screen" cols-s="2" cols-m="3">
|
|
||||||
<n-gi>
|
|
||||||
<div class="info-item">
|
|
||||||
<span class="label">版本号</span>
|
|
||||||
<span class="value">{{ versionInfo.version }}</span>
|
|
||||||
</div>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<div class="info-item">
|
|
||||||
<span class="label">Git 提交</span>
|
|
||||||
<span class="value">{{ versionInfo.git_commit?.slice(0, 8) || 'N/A' }}</span>
|
|
||||||
</div>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<div class="info-item">
|
|
||||||
<span class="label">构建时间</span>
|
|
||||||
<span class="value">{{ versionInfo.build_time || 'N/A' }}</span>
|
|
||||||
</div>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<div class="info-item">
|
|
||||||
<span class="label">Go 版本</span>
|
|
||||||
<span class="value">{{ versionInfo.go_version }}</span>
|
|
||||||
</div>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<div class="info-item">
|
|
||||||
<span class="label">操作系统</span>
|
|
||||||
<span class="value">{{ versionInfo.os }}</span>
|
|
||||||
</div>
|
|
||||||
</n-gi>
|
|
||||||
<n-gi>
|
|
||||||
<div class="info-item">
|
|
||||||
<span class="label">架构</span>
|
|
||||||
<span class="value">{{ versionInfo.arch }}</span>
|
|
||||||
</div>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
<n-empty v-else description="加载中..." />
|
|
||||||
</n-card>
|
|
||||||
|
|
||||||
<n-grid :cols="2" :x-gap="16" responsive="screen" cols-s="1">
|
|
||||||
<!-- 服务端更新 -->
|
|
||||||
<n-gi>
|
|
||||||
<n-card title="服务端更新">
|
|
||||||
<template #header-extra>
|
|
||||||
<n-button size="small" :loading="checkingServer" @click="handleCheckServerUpdate">
|
|
||||||
<template #icon><n-icon><RefreshOutline /></n-icon></template>
|
|
||||||
检查更新
|
|
||||||
</n-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<n-empty v-if="!serverUpdate" description="点击检查更新按钮查看是否有新版本" />
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
<n-alert v-if="serverUpdate.available" type="success" style="margin-bottom: 16px;">
|
|
||||||
发现新版本 {{ serverUpdate.latest }},当前版本 {{ serverUpdate.current }}
|
|
||||||
</n-alert>
|
|
||||||
<n-alert v-else type="info" style="margin-bottom: 16px;">
|
|
||||||
当前已是最新版本 {{ serverUpdate.current }}
|
|
||||||
</n-alert>
|
|
||||||
|
|
||||||
<n-space vertical :size="12">
|
|
||||||
<div v-if="serverUpdate.download_url">
|
|
||||||
<p style="margin: 0 0 8px 0; color: #666;">
|
|
||||||
下载文件: {{ serverUpdate.asset_name }}
|
|
||||||
<n-tag size="small" style="margin-left: 8px;">{{ formatBytes(serverUpdate.asset_size) }}</n-tag>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="serverUpdate.release_note" style="max-height: 150px; overflow-y: auto;">
|
|
||||||
<p style="margin: 0 0 4px 0; color: #666; font-size: 12px;">更新日志:</p>
|
|
||||||
<pre style="margin: 0; white-space: pre-wrap; font-size: 12px; color: #333;">{{ serverUpdate.release_note }}</pre>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<n-button
|
|
||||||
v-if="serverUpdate.available && serverUpdate.download_url"
|
|
||||||
type="primary"
|
|
||||||
:loading="updatingServer"
|
|
||||||
@click="handleApplyServerUpdate"
|
|
||||||
>
|
|
||||||
<template #icon><n-icon><CloudDownloadOutline /></n-icon></template>
|
|
||||||
下载并更新服务端
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
|
|
||||||
<!-- 客户端更新 -->
|
|
||||||
<n-gi>
|
|
||||||
<n-card title="客户端更新">
|
|
||||||
<template #header-extra>
|
|
||||||
<n-button size="small" :loading="checkingClient" @click="handleCheckClientUpdate">
|
|
||||||
<template #icon><n-icon><RefreshOutline /></n-icon></template>
|
|
||||||
检查更新
|
|
||||||
</n-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<n-empty v-if="!clientUpdate" description="点击检查更新按钮查看客户端更新" />
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
<n-space vertical :size="12">
|
|
||||||
<div v-if="clientUpdate.download_url">
|
|
||||||
<p style="margin: 0 0 8px 0; color: #666;">
|
|
||||||
最新版本: {{ clientUpdate.latest }}
|
|
||||||
</p>
|
|
||||||
<p style="margin: 0 0 8px 0; color: #666;">
|
|
||||||
下载文件: {{ clientUpdate.asset_name }}
|
|
||||||
<n-tag size="small" style="margin-left: 8px;">{{ formatBytes(clientUpdate.asset_size) }}</n-tag>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<n-empty v-if="onlineClients.length === 0" description="没有在线的客户端" />
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
<n-select
|
|
||||||
v-model:value="selectedClientId"
|
|
||||||
placeholder="选择要更新的客户端"
|
|
||||||
:options="onlineClients.map(c => ({ label: c.nickname || c.id, value: c.id }))"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<n-button
|
|
||||||
type="primary"
|
|
||||||
:disabled="!selectedClientId || !clientUpdate.download_url"
|
|
||||||
@click="handleApplyClientUpdate"
|
|
||||||
>
|
|
||||||
<template #icon><n-icon><RocketOutline /></n-icon></template>
|
|
||||||
推送更新到客户端
|
|
||||||
</n-button>
|
|
||||||
</template>
|
|
||||||
</n-space>
|
|
||||||
</template>
|
|
||||||
</n-card>
|
|
||||||
</n-gi>
|
|
||||||
</n-grid>
|
|
||||||
</n-spin>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.info-item {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 8px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item .label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #999;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-item .value {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #333;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,24 +1,10 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import AutoImport from 'unplugin-auto-import/vite'
|
|
||||||
import Components from 'unplugin-vue-components/vite'
|
|
||||||
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
|
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue()
|
||||||
AutoImport({
|
|
||||||
imports: [
|
|
||||||
'vue',
|
|
||||||
{
|
|
||||||
'naive-ui': ['useDialog', 'useMessage', 'useNotification', 'useLoadingBar']
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
Components({
|
|
||||||
resolvers: [NaiveUiResolver()]
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
build: {
|
build: {
|
||||||
chunkSizeWarningLimit: 1500,
|
chunkSizeWarningLimit: 1500,
|
||||||
|
|||||||
Reference in New Issue
Block a user