[fix] sui page remove api

This commit is contained in:
Max 2023-12-12 17:48:36 +08:00
parent b81e4f2003
commit b2f0f9e5e9
2 changed files with 6 additions and 0 deletions

View file

@ -583,6 +583,10 @@ func PageRemove(process *process.Process) interface{} {
exception.New(err.Error(), 500).Throw()
}
if !tmpl.PageExist(route) {
exception.New("page does not exists!", 400).Throw()
}
err = tmpl.RemovePage(route)
if err != nil {
exception.New(err.Error(), 500).Throw()

View file

@ -186,6 +186,8 @@ func (tmpl *Template) RemovePage(route string) error {
path := filepath.Join(tmpl.Root, route)
name := filepath.Base(path) + ".*"
name = strings.ReplaceAll(name, "[", "\\[")
name = strings.ReplaceAll(name, "]", "\\]")
err := tmpl.local.fs.Walk(path, func(root, file string, isdir bool) error {
if isdir {
return nil