Files
vsix-hpl-toolbox/standalone/home.go
2026-06-22 15:10:22 +08:00

57 lines
1.9 KiB
Go

package main
import (
"net/http"
"strings"
)
func HomePage(w http.ResponseWriter, r *http.Request) {
cfg := LoadConfig()
var items strings.Builder
for _, n := range visibleNavItems(cfg.BetaToolsEnabled) {
if n.Path == "/" {
continue
}
badge := ""
if n.Beta {
badge = ` <span class="beta-pill">Beta</span>`
}
items.WriteString(`<button type="button" class="home-tool" draggable="true" data-path="` + n.Path + `"><span class="home-tool-title">` + n.Label + badge + `</span><span class="home-tool-desc">` + n.Description + `</span></button>`)
}
body := `
<header class="tool-header" style="display:flex;align-items:flex-start;justify-content:space-between;gap:8px;">
<div>
<h2 class="tool-title">HPL Toolbox</h2>
<p class="tool-description">Standalone build. Pick a tool to open.</p>
</div>
<button type="button" onclick="openSettingsModal()" title="Settings" aria-label="Settings" style="flex-shrink:0;width:32px;height:32px;padding:0;display:grid;place-items:center;font-size:18px;background:#3a3d41;color:#ddd;border:1px solid #444;border-radius:4px;cursor:pointer;">&#9881;</button>
</header>
<div class="home-tools">
` + items.String() + `
</div>
<style>
.home-tools { display:flex; flex-direction:column; gap:8px; max-width:620px; }
.home-tool {
display:block;
width:100%;
min-height:52px;
padding:9px 11px;
color:#ddd;
text-align:left;
background:#2a2d2e;
border:1px solid #333;
border-radius:5px;
cursor:pointer;
font:inherit;
}
.home-tool:hover { background:#33373a; border-color:#007fd4; }
.home-tool.dragging { opacity:0.55; }
.home-tool-title { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px; font-weight:600; }
.home-tool-desc { display:block; margin-top:4px; color:#a7a7a7; font-size:11px; line-height:1.35; }
</style>
`
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = w.Write([]byte(Page("/", "Home", body)))
}