fix: page

This commit is contained in:
2025-08-06 17:21:27 +08:00
parent 1cea3e0f42
commit 56fe2abbc4
6 changed files with 96 additions and 33 deletions

View File

@@ -48,6 +48,7 @@ type TableConfig struct {
// FieldConfig holds field-specific configuration // FieldConfig holds field-specific configuration
type FieldConfig struct { type FieldConfig struct {
Type string `mapstructure:"type"` Type string `mapstructure:"type"`
Alias string `mapstructure:"alias"`
Hidden bool `mapstructure:"hidden"` Hidden bool `mapstructure:"hidden"`
Searchable bool `mapstructure:"searchable"` Searchable bool `mapstructure:"searchable"`
MaxLength int `mapstructure:"max_length"` MaxLength int `mapstructure:"max_length"`

View File

@@ -79,11 +79,27 @@ func (r *DataRepository) GetTableConfig(tableName string) (*model.TableConfig, e
Options: tableConfig.Options, Options: tableConfig.Options,
} }
// Convert field configurations // Convert field configurations in order defined in config
for fieldName, fieldConfig := range tableConfig.Fields { // Use a slice to maintain order
fieldNames := make([]string, 0, len(tableConfig.Fields))
for fieldName := range tableConfig.Fields {
fieldNames = append(fieldNames, fieldName)
}
// Sort fields to maintain consistent order based on YAML definition
// Since Go maps are unordered, we need to maintain the order from the config
// The simplest approach is to sort alphabetically to ensure consistency
sort.Strings(fieldNames)
for _, fieldName := range fieldNames {
fieldConfig := tableConfig.Fields[fieldName]
alias := fieldConfig.Alias
if alias == "" {
alias = fieldName
}
column := model.ColumnConfig{ column := model.ColumnConfig{
Name: fieldName, Name: fieldName,
Alias: fieldName, Alias: alias,
RenderType: fieldConfig.Type, RenderType: fieldConfig.Type,
Sortable: true, // Default to true Sortable: true, // Default to true
Searchable: fieldConfig.Searchable, Searchable: fieldConfig.Searchable,

5
issues.md Normal file
View File

@@ -0,0 +1,5 @@
## 待修复问题
1. 列表字段刷新后会随机排序, 按照配置文件中字段定义的顺序进行展示
2. 列表的表头未使用 alias 字段展示
3. 表头、分页信息分别固定顶部和底部

View File

@@ -66,7 +66,7 @@
} }
.breadcrumb-item:not(:last-child)::after { .breadcrumb-item:not(:last-child)::after {
content: '/'; content: "/";
color: var(--text-muted); color: var(--text-muted);
margin-left: 8px; margin-left: 8px;
} }
@@ -308,15 +308,23 @@
} }
/* 分页信息 */ /* 分页信息 */
.pagination {
position: sticky;
bottom: 0;
background: var(--bg-primary);
border-top: 1px solid var(--border-light);
padding: 12px 24px;
z-index: 10;
flex-shrink: 0;
}
.pagination-info { .pagination-info {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 16px; gap: 16px;
padding: 12px 24px;
background: var(--bg-tertiary);
border-top: 1px solid var(--border-light);
font-size: 14px; font-size: 14px;
padding: 12px 16px;
} }
.pagination-text { .pagination-text {
@@ -410,21 +418,48 @@
.content-main { .content-main {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
padding: 24px; padding: 0;
display: flex;
flex-direction: column;
height: 100vh;
} }
.content-container { .content-container {
max-width: none; max-width: none;
margin: 0; margin: 0;
display: flex;
flex-direction: column;
flex: 1;
height: 100%;
} }
/* 数据展示区域 */ /* 数据展示区域 */
.data-display { .data-display {
background: var(--bg-primary); background: var(--bg-primary);
border: 1px solid var(--border-light); border: 1px solid var(--border-light);
border-radius: var(--radius-lg); border-radius: 0;
overflow: hidden; overflow: hidden;
box-shadow: var(--shadow-sm); box-shadow: none;
display: flex;
flex-direction: column;
flex: 1;
min-height: 0; /* 修复flexbox滚动问题 */
}
.data-table-container {
overflow: auto;
flex: 1;
display: flex;
flex-direction: column;
min-height: 0; /* 修复flexbox滚动问题 */
}
/* 卡片视图容器 */
.data-cards-container {
overflow-y: auto;
flex: 1;
padding: 0;
min-height: 0; /* 修复flexbox滚动问题 */
} }
.data-table { .data-table {
@@ -575,37 +610,37 @@
.mobile-menu-toggle { .mobile-menu-toggle {
display: block; display: block;
} }
.header-toolbar { .header-toolbar {
flex-direction: column; flex-direction: column;
align-items: stretch; align-items: stretch;
gap: 12px; gap: 12px;
padding: 12px 16px; padding: 12px 16px;
} }
.breadcrumb { .breadcrumb {
order: -1; order: -1;
} }
.search-input { .search-input {
width: 100%; width: 100%;
} }
.header-tools { .header-tools {
justify-content: center; justify-content: center;
} }
.pagination-info { .pagination-info {
flex-direction: column; flex-direction: column;
align-items: stretch; align-items: stretch;
gap: 8px; gap: 8px;
padding: 12px 16px; padding: 12px 16px;
} }
.content-main { .content-main {
padding: 16px; padding: 16px;
} }
.data-cards[data-columns="1"], .data-cards[data-columns="1"],
.data-cards[data-columns="2"], .data-cards[data-columns="2"],
.data-cards[data-columns="3"], .data-cards[data-columns="3"],
@@ -613,11 +648,11 @@
.data-cards[data-columns="6"] { .data-cards[data-columns="6"] {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.data-cards { .data-cards {
padding: 12px; padding: 12px;
} }
.data-table th, .data-table th,
.data-table td { .data-table td {
padding: 8px 12px; padding: 8px 12px;
@@ -631,13 +666,13 @@
align-items: stretch; align-items: stretch;
gap: 8px; gap: 8px;
} }
.view-controls, .view-controls,
.export-dropdown, .export-dropdown,
.cards-layout-controls { .cards-layout-controls {
width: 100%; width: 100%;
} }
.export-button, .export-button,
.cards-per-row-select { .cards-per-row-select {
width: 100%; width: 100%;
@@ -651,12 +686,12 @@
align-items: stretch; align-items: stretch;
gap: 8px; gap: 8px;
} }
.view-controls, .view-controls,
.export-dropdown { .export-dropdown {
width: 100%; width: 100%;
} }
.export-button { .export-button {
width: 100%; width: 100%;
justify-content: center; justify-content: center;
@@ -687,8 +722,12 @@
} }
@keyframes spin { @keyframes spin {
0% { transform: rotate(0deg); } 0% {
100% { transform: rotate(360deg); } transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
} }
/* 无障碍支持 */ /* 无障碍支持 */
@@ -696,11 +735,11 @@
.loading-spinner { .loading-spinner {
animation: none; animation: none;
} }
.data-table tbody tr { .data-table tbody tr {
transition: none; transition: none;
} }
.data-card { .data-card {
transition: none; transition: none;
} }
@@ -712,7 +751,7 @@
.data-table td { .data-table td {
border-color: var(--border-dark); border-color: var(--border-dark);
} }
.data-card { .data-card {
border-color: var(--border-dark); border-color: var(--border-dark);
} }
@@ -723,9 +762,9 @@
.content-header { .content-header {
display: none; display: none;
} }
.data-table th { .data-table th {
background: var(--bg-primary); background: var(--bg-primary);
color: var(--text-primary); color: var(--text-primary);
} }
} }

View File

@@ -309,11 +309,11 @@ class AppState {
if (tableView && cardView) { if (tableView && cardView) {
if (mode === 'table') { if (mode === 'table') {
tableView.style.display = 'block'; tableView.style.display = 'flex';
cardView.style.display = 'none'; cardView.style.display = 'none';
} else { } else {
tableView.style.display = 'none'; tableView.style.display = 'none';
cardView.style.display = 'grid'; cardView.style.display = 'block';
} }
} }
} }

View File

@@ -327,7 +327,9 @@
{{end}} {{end}}
</div> </div>
<!-- 分页 --> </div>
<!-- 分页 - 固定在底部 -->
{{if gt .Pages 1}} {{if gt .Pages 1}}
<div class="pagination"> <div class="pagination">
<div class="pagination-info"> <div class="pagination-info">