diff --git a/backend/internal/api/handlers.go b/backend/internal/api/handlers.go index 67ef5cc..8cb6bbc 100644 --- a/backend/internal/api/handlers.go +++ b/backend/internal/api/handlers.go @@ -9,6 +9,7 @@ import ( "clicd/internal/config" "clicd/internal/lxc" + "clicd/internal/version" ) var lxcManager = lxc.NewManager() @@ -451,3 +452,14 @@ func deletePortMapping(w http.ResponseWriter, r *http.Request, id int, indexStr } jsonResponse(w, http.StatusOK, APIResponse{Success: true, Data: mappings}) } + +// HandleVersion returns the current CLICD version. +func HandleVersion(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + jsonResponse(w, http.StatusMethodNotAllowed, APIResponse{Success: false, Message: "Method not allowed"}) + return + } + jsonResponse(w, http.StatusOK, APIResponse{Success: true, Data: map[string]string{ + "version": version.Current(), + }}) +} diff --git a/backend/internal/server/server.go b/backend/internal/server/server.go index c061335..e5255a4 100644 --- a/backend/internal/server/server.go +++ b/backend/internal/server/server.go @@ -112,6 +112,9 @@ func setupRoutes(mux *http.ServeMux) { mux.HandleFunc("/api/api-keys", corsMiddleware(api.AdminMiddleware(api.HandleApiKeys))) mux.HandleFunc("/api/api-keys/", corsMiddleware(api.AdminMiddleware(api.HandleApiKeyDelete))) + // Version (public) + mux.HandleFunc("/api/version", corsMiddleware(api.HandleVersion)) + // Static files if webFS != nil { fs := http.FileServer(webFS) diff --git a/backend/internal/server/web/.gitkeep b/backend/internal/server/web/.gitkeep index 8b13789..e69de29 100644 --- a/backend/internal/server/web/.gitkeep +++ b/backend/internal/server/web/.gitkeep @@ -1 +0,0 @@ - diff --git a/backend/internal/version/version.go b/backend/internal/version/version.go index 9df621c..111c2e9 100644 --- a/backend/internal/version/version.go +++ b/backend/internal/version/version.go @@ -1,7 +1,7 @@ package version var ( - Version = "1.0.6" + Version = "1.0.7" Repo = "MengMengCode/CLICD" ) @@ -12,3 +12,4 @@ func Current() string { return Version } + diff --git a/frontend/index.html b/frontend/index.html index 8942472..5c1f271 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,8 +5,16 @@ CLICD - LXC Container Manager + - +
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5aa9904..df9e9a4 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -19,8 +19,8 @@ function ProtectedRoute({ children }: { children: React.ReactNode }) { if (isLoading) { return ( -
-
+
+
) } diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx index 002ce71..c50ac87 100644 --- a/frontend/src/components/Layout.tsx +++ b/frontend/src/components/Layout.tsx @@ -6,7 +6,7 @@ export default function Layout() { const [sidebarCollapsed, setSidebarCollapsed] = useState(false) return ( -
+
setSidebarCollapsed(!sidebarCollapsed)} />
diff --git a/frontend/src/components/ResourceStatsPanel.tsx b/frontend/src/components/ResourceStatsPanel.tsx index 6e461c7..0fd9f47 100644 --- a/frontend/src/components/ResourceStatsPanel.tsx +++ b/frontend/src/components/ResourceStatsPanel.tsx @@ -1,5 +1,6 @@ import { ReactNode } from 'react' import { RefreshCw } from 'lucide-react' +import { useTheme } from '../contexts/ThemeContext' export type StatsRangeKey = '30m' | '1h' | '1d' | '1w' @@ -45,17 +46,19 @@ export default function ResourceStatsPanel({ charts: ResourceChartConfig[] }) { return ( -
-
-

统计信息

+
+
+

统计信息

-
+
{(Object.keys(rangeLabels) as StatsRangeKey[]).map((item) => (
+ + {/* Version */} + {version && ( +
+ {collapsed ? ( + v{version.split('.').slice(0, 2).join('.')} + ) : ( + v{version} + )} +
+ )} + + {/* Logout */}