custon dashboard template [no ci]

This commit is contained in:
naiba
2022-06-03 09:45:11 +08:00
parent eb0501ad97
commit 2ab7a5fdd8
20 changed files with 95 additions and 37 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/naiba/nezha/model"
"github.com/naiba/nezha/service/singleton"
)
type ErrInfo struct {
@@ -18,7 +19,7 @@ type ErrInfo struct {
func ShowErrorPage(c *gin.Context, i ErrInfo, isPage bool) {
if isPage {
c.HTML(i.Code, "dashboard/error", CommonEnvironment(c, gin.H{
c.HTML(i.Code, "dashboard-"+singleton.Conf.Site.DashboardTheme+"/error", CommonEnvironment(c, gin.H{
"Code": i.Code,
"Title": i.Title,
"Msg": i.Msg,

View File

@@ -3,6 +3,7 @@ package utils
import (
"crypto/md5" // #nosec
"encoding/hex"
"io"
"math/rand"
"os"
"regexp"
@@ -93,3 +94,17 @@ func SplitIPAddr(v4v6Bundle string) (string, string, string) {
}
return ipv4, ipv6, validIP
}
func IsDirEmpty(name string) (bool, error) {
f, err := os.Open(name)
if err != nil {
return false, err
}
defer f.Close()
_, err = f.Readdirnames(1)
if err == io.EOF {
return true, nil
}
return false, err
}