From b2f0f9e5e982107a562ebd74a415f17914e733a4 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 12 Dec 2023 17:48:36 +0800 Subject: [PATCH] [fix] sui page remove api --- sui/api/process.go | 4 ++++ sui/storages/local/page.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/sui/api/process.go b/sui/api/process.go index db435dcc..6aadf3e7 100644 --- a/sui/api/process.go +++ b/sui/api/process.go @@ -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() diff --git a/sui/storages/local/page.go b/sui/storages/local/page.go index 390cfbdc..3de35b80 100644 --- a/sui/storages/local/page.go +++ b/sui/storages/local/page.go @@ -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