Skip to content

Commit 4f0abf8

Browse files
committed
chore: 调整分页参数为PageSize
1 parent 17ff209 commit 4f0abf8

File tree

17 files changed

+52
-37
lines changed

17 files changed

+52
-37
lines changed

app/admin/resources/action_log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (p *ActionLog) Init(ctx *quark.Context) interface{} {
2323
p.Model = &model.ActionLog{}
2424

2525
// 分页
26-
p.PerPage = 10
26+
p.PageSize = 10
2727

2828
// 是否具有导出功能
2929
p.WithExport = true

app/admin/resources/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (p *Config) Init(ctx *quark.Context) interface{} {
2424
p.Model = &model.Config{}
2525

2626
// 分页
27-
p.PerPage = 10
27+
p.PageSize = 10
2828

2929
return p
3030
}

app/admin/resources/department.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (p *Department) Init(ctx *quark.Context) interface{} {
3636
p.IndexQueryOrder = "sort asc, id asc"
3737

3838
// 分页
39-
p.PerPage = false
39+
p.PageSize = false
4040

4141
return p
4242
}

app/admin/resources/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (p *File) Init(ctx *quark.Context) interface{} {
2222
p.Model = &model.File{}
2323

2424
// 分页
25-
p.PerPage = 10
25+
p.PageSize = 10
2626

2727
return p
2828
}

app/admin/resources/menu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (p *Menu) Init(ctx *quark.Context) interface{} {
3434
p.QueryOrder = "sort asc"
3535

3636
// 分页
37-
p.PerPage = false
37+
p.PageSize = false
3838

3939
return p
4040
}

app/admin/resources/permission.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (p *Permission) Init(ctx *quark.Context) interface{} {
2424
p.Model = &model.Permission{}
2525

2626
// 分页
27-
p.PerPage = 10
27+
p.PageSize = 10
2828

2929
return p
3030
}

app/admin/resources/picture.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (p *Picture) Init(ctx *quark.Context) interface{} {
2323
p.Model = &model.Picture{}
2424

2525
// 分页
26-
p.PerPage = 10
26+
p.PageSize = 10
2727

2828
return p
2929
}

app/admin/resources/position.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (p *Position) Init(ctx *quark.Context) interface{} {
2323
p.Model = &model.Position{}
2424

2525
// 分页
26-
p.PerPage = 10
26+
p.PageSize = 10
2727

2828
// 默认排序
2929
p.IndexQueryOrder = "sort asc, id asc"

app/admin/resources/role.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (p *Role) Init(ctx *quark.Context) interface{} {
2727
p.Model = &model.Role{}
2828

2929
// 分页
30-
p.PerPage = 10
30+
p.PageSize = 10
3131

3232
// 默认排序
3333
p.IndexQueryOrder = "id asc"

app/admin/resources/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (p *User) Init(ctx *quark.Context) interface{} {
3838
p.Model = &model.User{}
3939

4040
// 分页
41-
p.PerPage = 10
41+
p.PageSize = 10
4242

4343
// 是否具有导出功能
4444
p.WithExport = true

engine.go

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

2424
// 版本号
25-
Version = "3.5.10"
25+
Version = "3.6.0"
2626

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

template/admin/component/table/table.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,13 @@ func (p *Component) SetDatasource(datasource interface{}) *Component {
243243
}
244244

245245
// 表格分页
246-
func (p *Component) SetPagination(current int, pageSize int, total int, defaultCurrent int) *Component {
247-
p.Pagination = map[string]int{
248-
"current": current,
249-
"pageSize": pageSize,
250-
"total": total,
251-
"defaultCurrent": defaultCurrent,
246+
func (p *Component) SetPagination(current int, pageSize int, total int, defaultCurrent int, pageSizeOptions []int) *Component {
247+
p.Pagination = map[string]interface{}{
248+
"current": current,
249+
"pageSize": pageSize,
250+
"total": total,
251+
"defaultCurrent": defaultCurrent,
252+
"pageSizeOptions": pageSizeOptions,
252253
}
253254

254255
return p

template/admin/resource/requests/index.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ func (p *IndexRequest) QueryData(ctx *quark.Context) interface{} {
3232
query := template.BuildIndexQuery(ctx, model, searches, filters, p.columnFilters(ctx), p.orderings(ctx))
3333

3434
// 获取分页
35-
perPage := template.GetPerPage()
36-
if perPage == nil {
35+
pageSize := template.GetPageSize()
36+
37+
// 指定每页可以显示多少条,[10, 20, 50, 100]
38+
pageSizeOptions := template.GetPageSizeOptions()
39+
if pageSize == nil {
3740
query.Find(&lists)
3841

3942
// 返回解析列表
4043
return p.performsList(ctx, lists)
4144
}
4245

4346
// 不分页,直接返回lists
44-
if reflect.TypeOf(perPage).String() != "int" {
47+
if reflect.TypeOf(pageSize).String() != "int" {
4548
query.Find(&lists)
4649

4750
// 返回解析列表
@@ -59,7 +62,7 @@ func (p *IndexRequest) QueryData(ctx *quark.Context) interface{} {
5962
page = int(data["current"].(float64))
6063
}
6164
if data["pageSize"] != nil {
62-
perPage = int(data["pageSize"].(float64))
65+
pageSize = int(data["pageSize"].(float64))
6366
}
6467
}
6568
}
@@ -68,16 +71,17 @@ func (p *IndexRequest) QueryData(ctx *quark.Context) interface{} {
6871
query.Count(&total)
6972

7073
// 获取列表
71-
query.Limit(perPage.(int)).Offset((page - 1) * perPage.(int)).Find(&lists)
74+
query.Limit(pageSize.(int)).Offset((page - 1) * pageSize.(int)).Find(&lists)
7275

7376
// 解析列表
7477
result := p.performsList(ctx, lists)
7578

7679
return map[string]interface{}{
77-
"currentPage": page,
78-
"perPage": perPage,
79-
"total": total,
80-
"items": result,
80+
"page": page,
81+
"pageSize": pageSize,
82+
"pageSizeOptions": pageSizeOptions,
83+
"total": total,
84+
"items": result,
8185
}
8286
}
8387

template/admin/resource/resource.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ type Template struct {
4646
TableActionColumnWidth int // 列表页表格行为列的宽度
4747
TablePolling int // 列表页表格是否轮询数据
4848
TableListToTree interface{} // 列表页数据转换为树形结构, true 或者 map[string]interface{}{"pkName": "id",""pidName": "pid","childrenName": "children","rootId":0}
49-
PerPage interface{} // 列表页分页配置
49+
PageSize interface{} // 列表页分页配置
50+
PageSizeOptions []int // 指定每页可以显示多少条,[10, 20, 50, 100]
5051
QueryOrder string // 全局排序规则
5152
IndexQueryOrder string // 列表页排序规则
5253
ExportQueryOrder string // 导出数据排序规则
@@ -193,8 +194,13 @@ func (p *Template) GetTablePolling() int {
193194
}
194195

195196
// 获取分页配置
196-
func (p *Template) GetPerPage() interface{} {
197-
return p.PerPage
197+
func (p *Template) GetPageSize() interface{} {
198+
return p.PageSize
199+
}
200+
201+
// 指定每页可以显示多少条,[10, 20, 50, 100]
202+
func (p *Template) GetPageSizeOptions() []int {
203+
return p.PageSizeOptions
198204
}
199205

200206
// 列表页列表数据转换为树形结构

template/admin/resource/resource_index.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,22 @@ func (p *Template) IndexComponentRender(ctx *quark.Context, data interface{}) in
114114
SetSearches(indexSearches)
115115

116116
// 获取分页
117-
perPage := template.GetPerPage()
118-
if perPage == nil {
117+
pageSize := template.GetPageSize()
118+
if pageSize == nil {
119119
return table.SetDatasource(data)
120120
}
121121

122122
// 不分页,直接返回数据
123-
if reflect.TypeOf(perPage).String() != "int" {
123+
if reflect.TypeOf(pageSize).String() != "int" {
124124
return table.SetDatasource(data)
125125
} else {
126-
current := data.(map[string]interface{})["currentPage"]
127-
perPage := data.(map[string]interface{})["perPage"]
126+
current := data.(map[string]interface{})["page"]
127+
pageSize := data.(map[string]interface{})["pageSize"]
128+
pageSizeOptions := data.(map[string]interface{})["pageSizeOptions"]
128129
total := data.(map[string]interface{})["total"]
129130
items := data.(map[string]interface{})["items"]
130131
component = table.
131-
SetPagination(current.(int), perPage.(int), int(total.(int64)), 1).
132+
SetPagination(current.(int), pageSize.(int), int(total.(int64)), 1, pageSizeOptions.([]int)).
132133
SetDatasource(items)
133134
}
134135

template/admin/resource/types/resourcer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ type Resourcer interface {
5858
GetTableListToTree() interface{}
5959

6060
// 获取分页配置
61-
GetPerPage() interface{}
61+
GetPageSize() interface{}
62+
63+
// 指定每页可以显示多少条,[10, 20, 50, 100]
64+
GetPageSizeOptions() []int
6265

6366
// 获取全局排序规则
6467
GetQueryOrder() string

web/app/admin/491.async.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)