feat: 顶栏显示后端应用版本号

后端 /api/health 返回 BuildVersion(由 ldflags 注入的 main.version),
前端顶栏设置按钮左侧展示 v<版本>。
This commit is contained in:
Autumn-27 committed 2026-08-18 11:27:01 -04:00
1 parent ff3d41ea35
commit 82c6d4a06b
4 files changed
+26 -2

No files matched your search

+6 -1
View File
@@ -27,6 +27,11 @@ import (
"github.com/Autumn-27/norma/transcript"
)
// BuildVersion is the backend application version, injected from cmd/artex at
// startup (which in turn gets it from -ldflags "-X main.version=<tag>").
// Defaults to "dev" for local builds. Exposed to the frontend via GET /api/health.
var BuildVersion = "dev"
// Server exposes the ARTEX backend over a JSON HTTP API for the shadcn/ui
// frontend.
type Server struct {
@@ -741,7 +746,7 @@ func (s *Server) Handler() http.Handler {
// --- handlers ---
func (s *Server) health(w http.ResponseWriter, r *http.Request) {
writeJSON(w, 200, map[string]any{"ok": true, "service": "artex"})
writeJSON(w, 200, map[string]any{"ok": true, "service": "artex", "version": BuildVersion})
}
func (s *Server) stats(w http.ResponseWriter, r *http.Request) {