chore: directory migration - gateway→server, web→client/electron

This commit is contained in:
2026-09-08 19:16:35 +08:00
parent fd9f99a3f9
commit f9d757b5e5
243 changed files with 5095 additions and 228 deletions

View File

@ -0,0 +1,37 @@
package static
import (
"embed"
"io/fs"
"net/http"
"sync"
)
//go:embed static
var staticFS embed.FS
var (
indexHTML []byte
once sync.Once
)
// GetIndex 返回入口页。
//
// index.html 缺失时回退到 placeholder.html前端产物不进版本库
// 新克隆里只有占位页。回退而不是报错是故意的 ——
// 只改后端的人应当能直接 go run 起来调 API而不必先装 node。
func GetIndex() []byte {
once.Do(func() {
if data, err := fs.ReadFile(staticFS, "static/index.html"); err == nil {
indexHTML = data
return
}
indexHTML, _ = fs.ReadFile(staticFS, "static/placeholder.html")
})
return indexHTML
}
func Handler() http.Handler {
sub, _ := fs.Sub(staticFS, "static")
return http.FileServer(http.FS(sub))
}