fix: 优化 FTP 列表分页样式 (#5283)

pull/5285/head
ssongliu 2024-06-04 22:03:06 +08:00 committed by GitHub
parent 62beecf337
commit 0afc6242a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package service
import ( import (
"os" "os"
"sort"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
@ -48,6 +49,9 @@ func (f *FtpService) LoadLog(req dto.FtpLogSearch) (int64, interface{}, error) {
if err != nil { if err != nil {
return 0, nil, err return 0, nil, err
} }
sort.Slice(logItem, func(i, j int) bool {
return logItem[i].Time > logItem[j].Time
})
var logs []toolbox.FtpLog var logs []toolbox.FtpLog
total, start, end := len(logItem), (req.Page-1)*req.PageSize, req.Page*req.PageSize total, start, end := len(logItem), (req.Page-1)*req.PageSize, req.Page*req.PageSize
if start > total { if start > total {

View File

@ -18,10 +18,11 @@
<div class="complex-table__pagination" v-if="props.paginationConfig"> <div class="complex-table__pagination" v-if="props.paginationConfig">
<slot name="pagination"> <slot name="pagination">
<fu-table-pagination <el-pagination
v-model:current-page="paginationConfig.currentPage" v-model:current-page="paginationConfig.currentPage"
v-model:page-size="paginationConfig.pageSize" v-model:page-size="paginationConfig.pageSize"
:total="paginationConfig.total" :total="paginationConfig.total"
:page-sizes="[5, 10, 20, 50, 100]"
@size-change="sizeChange" @size-change="sizeChange"
@current-change="currentChange" @current-change="currentChange"
:small="mobile" :small="mobile"

View File

@ -184,7 +184,7 @@ const data = ref();
const paginationConfig = reactive({ const paginationConfig = reactive({
cacheSizeKey: 'ftp-page-size', cacheSizeKey: 'ftp-page-size',
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: Number(localStorage.getItem('ftp-page-size')) || 10,
total: 0, total: 0,
orderBy: 'created_at', orderBy: 'created_at',
order: 'null', order: 'null',

View File

@ -17,13 +17,13 @@
<ComplexTable class="mt-2" :pagination-config="paginationConfig" :data="data" @search="search"> <ComplexTable class="mt-2" :pagination-config="paginationConfig" :data="data" @search="search">
<el-table-column label="ip" prop="ip" show-overflow-tooltip /> <el-table-column label="ip" prop="ip" show-overflow-tooltip />
<el-table-column :label="$t('commons.table.status')" show-overflow-tooltip prop="status"> <el-table-column :label="$t('commons.table.status')" min-width="50" show-overflow-tooltip prop="status">
<template #default="{ row }"> <template #default="{ row }">
<el-tag v-if="row.status === '200'">{{ $t('commons.status.success') }}</el-tag> <el-tag v-if="row.status === '200'">{{ $t('commons.status.success') }}</el-tag>
<el-tag v-else type="danger">{{ $t('commons.status.failed') }}</el-tag> <el-tag v-else type="danger">{{ $t('commons.status.failed') }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.table.operate')" show-overflow-tooltip> <el-table-column :label="$t('commons.table.operate')" min-width="40" show-overflow-tooltip>
<template #default="{ row }"> <template #default="{ row }">
{{ loadOperation(row.operation) }} {{ loadOperation(row.operation) }}
</template> </template>
@ -33,12 +33,12 @@
{{ loadFileName(row.operation) }} {{ loadFileName(row.operation) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('file.size')" show-overflow-tooltip prop="size"> <el-table-column :label="$t('file.size')" show-overflow-tooltip prop="size" min-width="60">
<template #default="{ row }"> <template #default="{ row }">
{{ computeSizeFromByte(Number(row.size)) }} {{ computeSizeFromByte(Number(row.size)) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.table.date')" prop="time" show-overflow-tooltip /> <el-table-column :label="$t('commons.table.date')" prop="time" show-overflow-tooltip min-width="100" />
</ComplexTable> </ComplexTable>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">