2023-11-28 10:01:37 -05:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
2024-10-09 12:08:16 -04:00
|
|
|
|
|
|
|
"github.com/naiba/nezha/pkg/utils"
|
2023-11-28 10:01:37 -05:00
|
|
|
)
|
|
|
|
|
2024-10-09 12:08:16 -04:00
|
|
|
var StaticFS *utils.HybridFS
|
|
|
|
|
2023-11-28 10:01:37 -05:00
|
|
|
//go:embed static
|
2024-10-09 12:08:16 -04:00
|
|
|
var staticFS embed.FS
|
2023-11-28 10:01:37 -05:00
|
|
|
|
|
|
|
//go:embed template
|
|
|
|
var TemplateFS embed.FS
|
|
|
|
|
|
|
|
//go:embed l10n
|
|
|
|
var I18nFS embed.FS
|
|
|
|
|
2024-10-09 12:08:16 -04:00
|
|
|
func init() {
|
|
|
|
var err error
|
|
|
|
StaticFS, err = utils.NewHybridFS(staticFS, "static", "resource/static/custom")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-28 10:01:37 -05:00
|
|
|
func IsTemplateFileExist(name string) bool {
|
|
|
|
_, err := TemplateFS.Open(name)
|
|
|
|
return err == nil
|
|
|
|
}
|