feat: 添加盒子排序功能,优化盒子列表和卡片样式

This commit is contained in:
2026-03-08 03:20:37 +08:00
parent eff4eb19e4
commit 59bcd69bb1
2 changed files with 26 additions and 2 deletions

11
app.py
View File

@@ -261,6 +261,14 @@ def make_overview_rows(box: Box):
return rows return rows
def box_sort_key(box: Box):
return (
(box.slot_prefix or "").upper(),
box.start_number if box.start_number is not None else 0,
box.name or "",
)
def render_box_page(box: Box, error: str = "", notice: str = ""): def render_box_page(box: Box, error: str = "", notice: str = ""):
slots = slot_data_for_box(box) slots = slot_data_for_box(box)
bag_rows = bag_rows_for_box(box) if box.box_type == "bag" else [] bag_rows = bag_rows_for_box(box) if box.box_type == "bag" else []
@@ -278,7 +286,8 @@ def render_box_page(box: Box, error: str = "", notice: str = ""):
@app.route("/") @app.route("/")
def index(): def index():
boxes = Box.query.order_by(Box.id.asc()).all() boxes = Box.query.all()
boxes.sort(key=box_sort_key)
groups = {key: [] for key in BOX_TYPES.keys()} groups = {key: [] for key in BOX_TYPES.keys()}
for box in boxes: for box in boxes:

View File

@@ -72,8 +72,9 @@ body {
.box-list { .box-list {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); grid-template-columns: repeat(auto-fill, 300px);
gap: 14px; gap: 14px;
justify-content: start;
} }
.group-panel { .group-panel {
@@ -118,6 +119,11 @@ body {
box-shadow: 0 3px 12px rgba(17, 32, 49, 0.05); box-shadow: 0 3px 12px rgba(17, 32, 49, 0.05);
} }
.box-card {
width: 300px;
min-height: 260px;
}
.box-card h3 { .box-card h3 {
margin: 0 0 6px; margin: 0 0 6px;
} }
@@ -280,6 +286,15 @@ td {
align-items: flex-start; align-items: flex-start;
} }
.box-list {
grid-template-columns: 1fr;
}
.box-card {
width: 100%;
min-height: auto;
}
.slot-grid, .slot-grid,
.slot-grid-14, .slot-grid-14,
.slot-grid-bag { .slot-grid-bag {