File tree Expand file tree Collapse file tree 1 file changed +19
-17
lines changed
Expand file tree Collapse file tree 1 file changed +19
-17
lines changed Original file line number Diff line number Diff line change 11package resource
22
33import (
4- "net/http"
5- "os"
6-
7- "github.com/xos/serverstatus/pkg/utils"
4+ "github.com/xos/serverstatus/pkg/utils"
85)
96
107var StaticFS * utils.HybridFS
118
12- func init () {
13- var err error
14- localStaticPath := "./static" // 静态资源的本地路径
15- if _ , err := os .Stat (localStaticPath ); os .IsNotExist (err ) {
16- panic ("Static files directory does not exist: " + localStaticPath )
17- }
9+ // 不再 embed 静态资源
10+ // var staticFS embed.FS
1811
19- StaticFS , err = utils .NewHybridFS (nil , localStaticPath )
20- if err != nil {
21- panic (err )
22- }
23- }
12+ // 不再 embed 模板和本地化文件
13+ // var TemplateFS embed.FS
14+ // var I18nFS embed.FS
2415
25- func ServeStaticFiles () http.Handler {
26- return http .FileServer (http .Dir ("./static" ))
16+ func init () {
17+ var err error
18+ // 只用本地目录,不用 embed.FS
19+ StaticFS , err = utils .NewHybridFS (nil , "" , "resource/static/custom" )
20+ if err != nil {
21+ panic (err )
22+ }
2723}
24+
25+ // 如果需要模板和本地化文件,也请用本地文件系统方式加载
26+ // func IsTemplateFileExist(name string) bool {
27+ // _, err := os.Open("resource/template/" + name)
28+ // return err == nil
29+ // }
You can’t perform that action at this time.
0 commit comments