Added plugin dir parameter

- Added plugin dir parameter
- Fixed critical architectural bug that effects plugin UI in production mode
- Updated implementation of embed FS routing
- Minor dark theme update
- Fixed ztnc UI bug for msgbox and confirm box
This commit is contained in:
Toby Chui
2025-03-28 21:24:18 +08:00
parent 3e031605fc
commit 136989f2ea
18 changed files with 152 additions and 126 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"io/fs"
"net/http"
"net/http/pprof"
@@ -315,13 +316,20 @@ func initAPIs(targetMux *http.ServeMux) {
},
})
//Register the standard web services urls
fs := http.FileServer(http.FS(webres))
// Register the standard web services URLs
var staticWebRes http.Handler
if DEVELOPMENT_BUILD {
fs = http.FileServer(http.Dir("web/"))
staticWebRes = http.FileServer(http.Dir("web/"))
} else {
subFS, err := fs.Sub(webres, "web")
if err != nil {
panic("Failed to strip 'web/' from embedded resources: " + err.Error())
}
staticWebRes = http.FileServer(http.FS(subFS))
}
//Add a layer of middleware for advance control
advHandler := FSHandler(fs)
advHandler := FSHandler(staticWebRes)
targetMux.Handle("/", advHandler)
//Register the APIs