可以在管理界面设置里设置默认每页显示数

This commit is contained in:
GoEdgeLab
2022-02-24 20:52:47 +08:00
parent 3796b25676
commit 64668f8e66
4 changed files with 35 additions and 2 deletions

View File

@@ -94,5 +94,6 @@ func defaultAdminUIConfig() *systemconfigs.AdminUIConfig {
ShowOpenSourceInfo: true,
ShowVersion: true,
ShowFinance: true,
DefaultPageSize: 10,
}
}

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
@@ -55,7 +56,14 @@ func (this *ParentAction) NewPage(total int64, size ...int64) *Page {
if len(size) > 0 {
return NewActionPage(this, total, size[0])
}
return NewActionPage(this, total, 10)
var pageSize int64 = 10
adminConfig, err := configloaders.LoadAdminUIConfig()
if err == nil && adminConfig.DefaultPageSize > 0 {
pageSize = int64(adminConfig.DefaultPageSize)
}
return NewActionPage(this, total, pageSize)
}
func (this *ParentAction) Nav(mainMenu string, tab string, firstMenu string) {

View File

@@ -22,6 +22,9 @@ func (this *IndexAction) RunGet(params struct{}) {
this.ErrorPage(err)
return
}
if config.DefaultPageSize == 0 {
config.DefaultPageSize = 10
}
this.Data["config"] = config
this.Show()
@@ -36,6 +39,7 @@ func (this *IndexAction) RunPost(params struct {
Version string
FaviconFile *actions.File
LogoFile *actions.File
DefaultPageSize int
Must *actions.Must
CSRF *actionutils.CSRF
@@ -46,7 +50,10 @@ func (this *IndexAction) RunPost(params struct {
Field("productName", params.ProductName).
Require("请输入产品名称").
Field("adminSystemName", params.AdminSystemName).
Require("请输入管理员系统名称")
Require("请输入管理员系统名称").
Field("defaultPageSize", params.DefaultPageSize).
Gte(0, "默认每页显示数不能小于0").
Lte(100, "默认每页显示数不能大于100")
config, err := configloaders.LoadAdminUIConfig()
if err != nil {
@@ -60,6 +67,12 @@ func (this *IndexAction) RunPost(params struct {
config.ShowVersion = params.ShowVersion
config.Version = params.Version
if params.DefaultPageSize > 0 {
config.DefaultPageSize = params.DefaultPageSize
} else {
config.DefaultPageSize = 10
}
// 上传Favicon文件
if params.FaviconFile != nil {
createResp, err := this.RPC().FileRPC().CreateFile(this.AdminContext(), &pb.CreateFileRequest{

View File

@@ -76,5 +76,16 @@
</tr>
</table>
<h4>其他</h4>
<table class="ui table definition selectable">
<tr>
<td class="title">每页显示数</td>
<td>
<input type="text" name="defaultPageSize" v-model="config.defaultPageSize" maxlength="3" style="width: 4em"/>
<p class="comment">在有分页的地方每页显示数量不能超过100。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>