feat: batch download

This commit is contained in:
tao.chen
2026-08-27 19:35:30 +08:00
parent 7225b72906
commit a897a08534
10 changed files with 443 additions and 77 deletions
+10 -1
View File
@@ -17,6 +17,12 @@ 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
@@ -24,6 +30,9 @@ var pageHTML []byte
func init() {
s := string(indexTpl)
s = strings.Replace(s, "/*EMBED_CSS*/", string(appCSS), 1)
s = strings.Replace(s, "/*EMBED_JS*/", string(appJS), 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)
}