refactor(app): 移除 naive-ui 依赖并优化配置结构
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 31s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m30s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m39s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m19s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m43s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m18s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m38s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 1m50s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 2m6s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m18s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m57s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m25s
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 31s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m30s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m39s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m19s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m43s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m18s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m38s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 1m50s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 2m6s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m18s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m57s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m25s
- 从 App.vue 中移除 naive-ui 组件及其主题配置 - 从组件声明中移除 NIcon 和 NTag 组件引用 - 将 JSPluginConfig 从 ServerConfig 中分离 - 在 ServerSettings 中整合 PluginStore 配置 - 更新配置 DTO 结构以支持 PluginStore 配置 - 移除 JS 插件加载和签名验证相关代码 - 从 main.ts 中移除 naive-ui 的引入和使用 - 从 package.json 中移除 naive-ui 和相关自动导入插件依赖 - 在设置页面添加插件商店 URL 配置字段 - 更新 StoreHandler 中插件商店 URL 的获取方式 - 移除 Vite 配置中的自动导入和组件解析插件
This commit is contained in:
@@ -27,7 +27,6 @@ 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"
|
"github.com/gotunnel/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -83,12 +82,6 @@ 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.Server.Web.Enabled {
|
if cfg.Server.Web.Enabled {
|
||||||
// 强制生成 Web 凭据(如果未配置)
|
// 强制生成 Web 凭据(如果未配置)
|
||||||
@@ -128,69 +121,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)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,19 +10,7 @@ import (
|
|||||||
|
|
||||||
// ServerConfig 服务端配置
|
// ServerConfig 服务端配置
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
Server ServerSettings `yaml:"server"`
|
Server ServerSettings `yaml:"server"`
|
||||||
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 插件仓库设置
|
||||||
@@ -43,14 +31,15 @@ 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"`
|
TLSDisabled bool `yaml:"tls_disabled"`
|
||||||
Web WebSettings `yaml:"web"`
|
Web WebSettings `yaml:"web"`
|
||||||
|
PluginStore PluginStoreSettings `yaml:"plugin_store"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebSettings Web控制台设置
|
// WebSettings Web控制台设置
|
||||||
|
|||||||
@@ -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 服务器配置部分
|
||||||
@@ -29,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 服务器配置信息
|
||||||
@@ -49,3 +51,13 @@ type WebConfigInfo struct {
|
|||||||
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"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ func (h *ConfigHandler) Get(c *gin.Context) {
|
|||||||
Username: cfg.Server.Web.Username,
|
Username: cfg.Server.Web.Username,
|
||||||
Password: "****",
|
Password: "****",
|
||||||
},
|
},
|
||||||
|
PluginStore: dto.PluginStoreConfigInfo{
|
||||||
|
URL: cfg.Server.PluginStore.URL,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Success(c, resp)
|
Success(c, resp)
|
||||||
@@ -100,6 +103,11 @@ func (h *ConfigHandler) Update(c *gin.Context) {
|
|||||||
cfg.Server.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 {
|
||||||
InternalError(c, err.Error())
|
InternalError(c, err.Error())
|
||||||
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}
|
||||||
|
|||||||
2
web/components.d.ts
vendored
2
web/components.d.ts
vendored
@@ -17,8 +17,6 @@ declare module 'vue' {
|
|||||||
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
|
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
|
||||||
InlineLogPanel: typeof import('./src/components/InlineLogPanel.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']
|
||||||
NIcon: typeof import('naive-ui')['NIcon']
|
|
||||||
NTag: typeof import('naive-ui')['NTag']
|
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
}
|
}
|
||||||
|
|||||||
974
web/package-lock.json
generated
974
web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,6 @@
|
|||||||
"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"
|
||||||
},
|
},
|
||||||
@@ -24,8 +23,6 @@
|
|||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"tailwindcss": "^4.1.18",
|
"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"
|
||||||
}
|
}
|
||||||
|
|||||||
151
web/src/App.vue
151
web/src/App.vue
@@ -1,10 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed, 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 {
|
|
||||||
NConfigProvider, NMessageProvider, NDialogProvider, NGlobalStyle,
|
|
||||||
type GlobalThemeOverrides
|
|
||||||
} from 'naive-ui'
|
|
||||||
import {
|
import {
|
||||||
HomeOutline, DesktopOutline, SettingsOutline,
|
HomeOutline, DesktopOutline, SettingsOutline,
|
||||||
PersonCircleOutline, LogOutOutline, LogoGithub, ServerOutline, CheckmarkCircleOutline, ArrowUpCircleOutline
|
PersonCircleOutline, LogOutOutline, LogoGithub, ServerOutline, CheckmarkCircleOutline, ArrowUpCircleOutline
|
||||||
@@ -88,95 +84,72 @@ const logout = () => {
|
|||||||
const toggleUserMenu = () => {
|
const toggleUserMenu = () => {
|
||||||
showUserMenu.value = !showUserMenu.value
|
showUserMenu.value = !showUserMenu.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// 紫色渐变主题
|
|
||||||
const themeOverrides: GlobalThemeOverrides = {
|
|
||||||
common: {
|
|
||||||
primaryColor: '#6366f1',
|
|
||||||
primaryColorHover: '#818cf8',
|
|
||||||
primaryColorPressed: '#4f46e5',
|
|
||||||
},
|
|
||||||
Layout: {
|
|
||||||
headerColor: '#ffffff'
|
|
||||||
},
|
|
||||||
Tabs: {
|
|
||||||
tabTextColorActiveLine: '#6366f1',
|
|
||||||
barColor: '#6366f1'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</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">
|
||||||
<div v-if="!isLoginPage" class="app-layout">
|
<span class="logo">GoTunnel</span>
|
||||||
<!-- Header -->
|
</div>
|
||||||
<header class="app-header">
|
<nav class="header-nav">
|
||||||
<div class="header-left">
|
<router-link
|
||||||
<span class="logo">GoTunnel</span>
|
v-for="item in navItems"
|
||||||
</div>
|
:key="item.key"
|
||||||
<nav class="header-nav">
|
:to="item.path"
|
||||||
<router-link
|
class="nav-item"
|
||||||
v-for="item in navItems"
|
:class="{ active: activeNav === item.key }"
|
||||||
:key="item.key"
|
>
|
||||||
:to="item.path"
|
<component :is="item.icon" class="nav-icon" />
|
||||||
class="nav-item"
|
<span>{{ item.label }}</span>
|
||||||
:class="{ active: activeNav === item.key }"
|
</router-link>
|
||||||
>
|
</nav>
|
||||||
<component :is="item.icon" class="nav-icon" />
|
<div class="header-right">
|
||||||
<span>{{ item.label }}</span>
|
<div class="user-menu" @click="toggleUserMenu">
|
||||||
</router-link>
|
<PersonCircleOutline class="user-icon" />
|
||||||
</nav>
|
<div v-if="showUserMenu" class="user-dropdown" @click.stop>
|
||||||
<div class="header-right">
|
<button class="dropdown-item" @click="logout">
|
||||||
<div class="user-menu" @click="toggleUserMenu">
|
<LogOutOutline class="dropdown-icon" />
|
||||||
<PersonCircleOutline class="user-icon" />
|
<span>退出登录</span>
|
||||||
<div v-if="showUserMenu" class="user-dropdown" @click.stop>
|
</button>
|
||||||
<button class="dropdown-item" @click="logout">
|
</div>
|
||||||
<LogOutOutline class="dropdown-icon" />
|
|
||||||
<span>退出登录</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Main Content -->
|
|
||||||
<main class="main-content">
|
|
||||||
<RouterView />
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<!-- Footer -->
|
|
||||||
<footer class="app-footer">
|
|
||||||
<div class="footer-left">
|
|
||||||
<span class="brand">GoTunnel</span>
|
|
||||||
<div v-if="version" class="version-info">
|
|
||||||
<ServerOutline class="version-icon" />
|
|
||||||
<span class="version">v{{ version }}</span>
|
|
||||||
<span v-if="updateInfo" class="update-status" :class="{ latest: !updateInfo.available, 'has-update': updateInfo.available }">
|
|
||||||
<template v-if="updateInfo.available">
|
|
||||||
<ArrowUpCircleOutline class="status-icon" />
|
|
||||||
<span>新版本 ({{ updateInfo.latest }})</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<CheckmarkCircleOutline class="status-icon" />
|
|
||||||
<span>最新版本</span>
|
|
||||||
</template>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a href="https://github.com/user/gotunnel" target="_blank" class="footer-link">
|
|
||||||
<LogoGithub class="footer-icon" />
|
|
||||||
<span>GitHub</span>
|
|
||||||
</a>
|
|
||||||
<span class="copyright">© 2024 Flik. MIT License</span>
|
|
||||||
</footer>
|
|
||||||
</div>
|
</div>
|
||||||
<RouterView v-else />
|
</div>
|
||||||
</n-message-provider>
|
</header>
|
||||||
</n-dialog-provider>
|
|
||||||
</n-config-provider>
|
<!-- Main Content -->
|
||||||
|
<main class="main-content">
|
||||||
|
<RouterView />
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="app-footer">
|
||||||
|
<div class="footer-left">
|
||||||
|
<span class="brand">GoTunnel</span>
|
||||||
|
<div v-if="version" class="version-info">
|
||||||
|
<ServerOutline class="version-icon" />
|
||||||
|
<span class="version">v{{ version }}</span>
|
||||||
|
<span v-if="updateInfo" class="update-status" :class="{ latest: !updateInfo.available, 'has-update': updateInfo.available }">
|
||||||
|
<template v-if="updateInfo.available">
|
||||||
|
<ArrowUpCircleOutline class="status-icon" />
|
||||||
|
<span>新版本 ({{ updateInfo.latest }})</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<CheckmarkCircleOutline class="status-icon" />
|
||||||
|
<span>最新版本</span>
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a href="https://github.com/user/gotunnel" target="_blank" class="footer-link">
|
||||||
|
<LogoGithub class="footer-icon" />
|
||||||
|
<span>GitHub</span>
|
||||||
|
</a>
|
||||||
|
<span class="copyright">© 2024 Flik. MIT License</span>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
<RouterView v-else />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -212,14 +212,20 @@ export interface WebConfigInfo {
|
|||||||
password: string
|
password: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PluginStoreConfigInfo {
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface ServerConfigResponse {
|
export interface ServerConfigResponse {
|
||||||
server: ServerConfigInfo
|
server: ServerConfigInfo
|
||||||
web: WebConfigInfo
|
web: WebConfigInfo
|
||||||
|
plugin_store: PluginStoreConfigInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateServerConfigRequest {
|
export interface UpdateServerConfigRequest {
|
||||||
server?: Partial<ServerConfigInfo>
|
server?: Partial<ServerConfigInfo>
|
||||||
web?: Partial<WebConfigInfo>
|
web?: Partial<WebConfigInfo>
|
||||||
|
plugin_store?: Partial<PluginStoreConfigInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServerConfig = () => get<ServerConfigResponse>('/config')
|
export const getServerConfig = () => get<ServerConfigResponse>('/config')
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ const configForm = ref({
|
|||||||
heartbeat_sec: 30,
|
heartbeat_sec: 30,
|
||||||
heartbeat_timeout: 90,
|
heartbeat_timeout: 90,
|
||||||
web_username: '',
|
web_username: '',
|
||||||
web_password: ''
|
web_password: '',
|
||||||
|
plugin_store_url: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const loadVersionInfo = async () => {
|
const loadVersionInfo = async () => {
|
||||||
@@ -55,7 +56,8 @@ const loadServerConfig = async () => {
|
|||||||
heartbeat_sec: data.server.heartbeat_sec,
|
heartbeat_sec: data.server.heartbeat_sec,
|
||||||
heartbeat_timeout: data.server.heartbeat_timeout,
|
heartbeat_timeout: data.server.heartbeat_timeout,
|
||||||
web_username: data.web.username,
|
web_username: data.web.username,
|
||||||
web_password: ''
|
web_password: '',
|
||||||
|
plugin_store_url: data.plugin_store.url
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to load server config', e)
|
console.error('Failed to load server config', e)
|
||||||
@@ -75,6 +77,9 @@ const handleSaveConfig = async () => {
|
|||||||
},
|
},
|
||||||
web: {
|
web: {
|
||||||
username: configForm.value.web_username
|
username: configForm.value.web_username
|
||||||
|
},
|
||||||
|
plugin_store: {
|
||||||
|
url: configForm.value.plugin_store_url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 只有填写了密码才更新
|
// 只有填写了密码才更新
|
||||||
@@ -269,6 +274,19 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</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://example.com/plugins"
|
||||||
|
/>
|
||||||
|
<span class="form-hint">插件商店的 API 地址</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button
|
<button
|
||||||
class="glass-btn primary"
|
class="glass-btn primary"
|
||||||
|
|||||||
@@ -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