Skip to content

Commit d82a571

Browse files
committed
chore: 优化代码
1 parent 4de33ac commit d82a571

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
AppName = "QuarkGo"
2424

2525
// 版本号
26-
Version = "3.9.5"
26+
Version = "3.9.6"
2727

2828
// 包名
2929
PkgName = "github.com/quarkcloudio/quark-go/v3"

template/admin/resource/resolves_searches.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package resource
22

33
import (
4+
"reflect"
45
"strings"
56

67
"github.com/quarkcloudio/quark-go/v3"
@@ -28,9 +29,14 @@ func (p *Template) IndexSearches(ctx *quark.Context) interface{} {
2829
export := template.GetExport()
2930
if export {
3031
exportText := template.GetExportText() // 导出按钮文字内容
32+
exportPath := reflect.
33+
ValueOf(ctx.Template).
34+
Elem().
35+
FieldByName("ExportPath").
36+
String()
3137
search = search.
3238
SetExportText(exportText).
33-
SetExportApi(strings.Replace(p.ExportPath, ":resource", ctx.Param("resource"), -1))
39+
SetExportApi(strings.Replace(exportPath, ":resource", ctx.Param("resource"), -1))
3440
}
3541

3642
// 解析搜索项

template/admin/resource/resource.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package resource
22

33
import (
4+
"reflect"
5+
46
"github.com/quarkcloudio/quark-go/v3"
57
"github.com/quarkcloudio/quark-go/v3/dal/db"
68
"github.com/quarkcloudio/quark-go/v3/template/admin/component/form"
@@ -415,7 +417,13 @@ func (p *Template) ExportRender(ctx *quark.Context) error {
415417

416418
// 导入数据
417419
func (p *Template) ImportRender(ctx *quark.Context) error {
418-
return (&requests.ImportRequest{}).Handle(ctx, p.IndexPath)
420+
indexPath := reflect.
421+
ValueOf(ctx.Template).
422+
Elem().
423+
FieldByName("IndexPath").
424+
String()
425+
426+
return (&requests.ImportRequest{}).Handle(ctx, indexPath)
419427
}
420428

421429
// 导入数据模板

template/admin/resource/resource_form.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,12 @@ func (p *Template) AfterSavedRedirectTo(ctx *quark.Context, id int, data map[str
154154
if err != nil {
155155
return ctx.CJSONError(err.Error())
156156
}
157-
return ctx.CJSONRedirectTo("操作成功", strings.Replace("/layout/index?api="+p.IndexPath, ":resource", ctx.Param("resource"), -1))
157+
158+
indexPath := reflect.
159+
ValueOf(ctx.Template).
160+
Elem().
161+
FieldByName("IndexPath").
162+
String()
163+
164+
return ctx.CJSONRedirectTo("操作成功", strings.Replace("/layout/index?api="+indexPath, ":resource", ctx.Param("resource"), -1))
158165
}

0 commit comments

Comments
 (0)