1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

feat: 网站已安装页面增加分页 (#1707)

This commit is contained in:
zhengkunwang 2023-07-18 14:22:36 +08:00 committed by GitHub
parent 920f1112fa
commit aa8816f3ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 12 deletions

View File

@ -61,7 +61,12 @@ func NewIAppInstalledService() IAppInstallService {
} }
func (a *AppInstallService) Page(req request.AppInstalledSearch) (int64, []response.AppInstalledDTO, error) { func (a *AppInstallService) Page(req request.AppInstalledSearch) (int64, []response.AppInstalledDTO, error) {
var opts []repo.DBOption var (
opts []repo.DBOption
total int64
installs []model.AppInstall
err error
)
if req.Name != "" { if req.Name != "" {
opts = append(opts, commonRepo.WithLikeName(req.Name)) opts = append(opts, commonRepo.WithLikeName(req.Name))
@ -87,15 +92,25 @@ func (a *AppInstallService) Page(req request.AppInstalledSearch) (int64, []respo
opts = append(opts, appInstallRepo.WithAppIdsIn(appIds)) opts = append(opts, appInstallRepo.WithAppIdsIn(appIds))
} }
total, installs, err := appInstallRepo.Page(req.Page, req.PageSize, opts...) if req.Update {
installs, err = appInstallRepo.ListBy(opts...)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
} else {
total, installs, err = appInstallRepo.Page(req.Page, req.PageSize, opts...)
if err != nil {
return 0, nil, err
}
}
installDTOs, err := handleInstalled(installs, req.Update) installDTOs, err := handleInstalled(installs, req.Update)
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
if req.Update {
total = int64(len(installDTOs))
}
return total, installDTOs, nil return total, installDTOs, nil
} }

View File

@ -287,13 +287,6 @@ onMounted(() => {
border: none; border: none;
} }
} }
.page-button {
float: right;
margin-bottom: 10px;
margin-top: 10px;
}
@media only screen and (min-width: 768px) and (max-width: 1200px) { @media only screen and (min-width: 768px) and (max-width: 1200px) {
.app-col-12 { .app-col-12 {
max-width: 50%; max-width: 50%;

View File

@ -91,3 +91,9 @@
border: none; border: none;
} }
} }
.page-button {
float: right;
margin-bottom: 10px;
margin-top: 10px;
}

View File

@ -234,6 +234,15 @@
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<div class="page-button" v-if="mode === 'installed'">
<fu-table-pagination
v-model:current-page="paginationConfig.currentPage"
v-model:page-size="paginationConfig.pageSize"
v-bind="paginationConfig"
@change="search"
:layout="'total, sizes, prev, pager, next, jumper'"
/>
</div>
</template> </template>
</LayoutContent> </LayoutContent>
<Backups ref="backupRef" @close="search" /> <Backups ref="backupRef" @close="search" />
@ -300,7 +309,7 @@ const tags = ref<App.Tag[]>([]);
const activeTag = ref('all'); const activeTag = ref('all');
const searchReq = reactive({ const searchReq = reactive({
page: 1, page: 1,
pageSize: 15, pageSize: 20,
name: '', name: '',
tags: [], tags: [],
update: false, update: false,