Skip to content

Commit

Permalink
print viewpath error
Browse files Browse the repository at this point in the history
  • Loading branch information
han2015 committed Jun 18, 2021
1 parent 7ccf680 commit e665b4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 8 additions & 3 deletions admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"html/template"
"log"
"path/filepath"
"reflect"

Expand Down Expand Up @@ -108,17 +109,21 @@ func (admin *Admin) SetAssetFS(assetFS assetfs.Interface) {

// RegisterViewPath register view path for admin
func (admin *Admin) RegisterViewPath(pth string) {
if admin.AssetFS.RegisterPath(filepath.Join(utils.AppRoot, "vendor", pth)) != nil {
var err error
if err = admin.AssetFS.RegisterPath(filepath.Join(utils.AppRoot, "vendor", pth)); err != nil {
for _, gopath := range utils.GOPATH() {
if admin.AssetFS.RegisterPath(filepath.Join(gopath, getDepVersionFromMod(pth))) == nil {
if err = admin.AssetFS.RegisterPath(filepath.Join(gopath, getDepVersionFromMod(pth))); err == nil {
break
}

if admin.AssetFS.RegisterPath(filepath.Join(gopath, "src", pth)) == nil {
if err = admin.AssetFS.RegisterPath(filepath.Join(gopath, "src", pth)); err == nil {
break
}
}
}
if err != nil {
log.Printf("RegisterViewPathError: %s %s!", pth, err.Error())
}
}

// RegisterMetaConfigor register configor for a kind, it will be called when register those kind of metas
Expand Down
12 changes: 8 additions & 4 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package admin
import (
"html/template"
"io/ioutil"
"log"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -40,20 +41,23 @@ type I18n interface {
// RegisterViewPath register view path for all assetfs
func RegisterViewPath(pth string) {
globalViewPaths = append(globalViewPaths, pth)

var err error
for _, assetFS := range globalAssetFSes {
if assetFS.RegisterPath(filepath.Join(utils.AppRoot, "vendor", pth)) != nil {
if err = assetFS.RegisterPath(filepath.Join(utils.AppRoot, "vendor", pth)); err != nil {
for _, gopath := range utils.GOPATH() {
if assetFS.RegisterPath(filepath.Join(gopath, getDepVersionFromMod(pth))) == nil {
if err = assetFS.RegisterPath(filepath.Join(gopath, getDepVersionFromMod(pth))); err == nil {
break
}

if assetFS.RegisterPath(filepath.Join(gopath, "src", pth)) == nil {
if err = assetFS.RegisterPath(filepath.Join(gopath, "src", pth)); err == nil {
break
}
}
}
}
if err != nil {
log.Printf("RegisterViewPathError: %s %s!", pth, err.Error())
}
}

func equal(a, b interface{}) bool {
Expand Down

0 comments on commit e665b4f

Please sign in to comment.