feat(前端增强): 支持离线阅读与手动刷新,优化资源校验和字体加载
build.yaml / build (push) Successful in 41s

This commit is contained in:
xiaoqidun committed 2026-09-08 17:43:17 +08:00
1 parent 7ee1052c8b
commit 080985caec
7 files changed
+348 -93

No files matched your search

+13 -5
View File
@@ -17,12 +17,14 @@
package main
import (
"bytes"
"flag"
"fmt"
"net/http"
"os"
"strings"
"time"
webuiassets "github.com/xiaoqidun/ofdgo/assets/webui"
"github.com/xiaoqidun/ofdgo/assets/webui"
)
func main() {
@@ -36,10 +38,16 @@ func main() {
// serveWebUI 创建WebUI静态文件处理器
// 返回: http.Handler HTTP处理器
func serveWebUI() http.Handler {
files := http.FileServer(http.FS(webuiassets.FS))
files := http.FileServerFS(webuiassets.FS)
checksum := webuiassets.Checksum()
serviceWorker, _ := webuiassets.FS.ReadFile("ofdgo.sw.js")
serviceWorker = append([]byte(fmt.Sprintf("const BUNDLE_CHECKSUM = %q;\n", checksum)), serviceWorker...)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, ".wasm") {
w.Header().Set("Content-Type", "application/wasm")
w.Header().Set("Cache-Control", "no-store")
w.Header().Set("X-OFDGo-Checksum", checksum)
if r.URL.Path == "/ofdgo.sw.js" {
http.ServeContent(w, r, "ofdgo.sw.js", time.Time{}, bytes.NewReader(serviceWorker))
return
}
files.ServeHTTP(w, r)
})