feat: batch delete
This commit is contained in:
@@ -1,38 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
_ "embed"
|
||||
"embed"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// 嵌入式静态页面 (单文件部署, 把 HTML/CSS/JS 编译进二进制, 无需运行时外部文件)
|
||||
// 嵌入式静态资源: HTML 骨架单独 embed, CSS/JS 经 /static 路由对外提供.
|
||||
// 所有资源仍编译进单个二进制, 部署无需运行时外部文件.
|
||||
|
||||
//go:embed static/app.css static/app.js static/helpers.js static/batch.js
|
||||
var staticEmbed embed.FS
|
||||
|
||||
//go:embed static/index.html.tpl
|
||||
var indexTpl []byte
|
||||
|
||||
//go:embed static/app.css
|
||||
var appCSS []byte
|
||||
|
||||
//go:embed static/app.js
|
||||
var appJS []byte
|
||||
|
||||
//go:embed static/helpers.js
|
||||
var helpersJS []byte
|
||||
|
||||
//go:embed static/batch.js
|
||||
var batchJS []byte
|
||||
|
||||
// pageHTML is the assembled single-file deployment response.
|
||||
// Computed once at startup; same bytes served on every GET /.
|
||||
var pageHTML []byte
|
||||
// staticFS 是 static/ 目录的子文件系统, 供 /static 路由对外提供资源.
|
||||
var staticFS fs.FS
|
||||
|
||||
func init() {
|
||||
s := string(indexTpl)
|
||||
s = strings.Replace(s, "/*EMBED_CSS*/", string(appCSS), 1)
|
||||
// JS 顺序敏感: app 先声明 consts / 注册 handlers; helpers 后注入纯函数;
|
||||
// batch 最后使用 consts 并启动 boot. 同 <script> 内共享顶层 var.
|
||||
combined := string(appJS) + "\n" + string(helpersJS) + "\n" + string(batchJS)
|
||||
s = strings.Replace(s, "/*EMBED_JS*/", combined, 1)
|
||||
pageHTML = []byte(s)
|
||||
var err error
|
||||
staticFS, err = fs.Sub(staticEmbed, "static")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user