feat: 侧边栏分组图标与导航样式优化

- 分组支持 icon 字段,可按名称自动匹配或手动选择
- 左侧导航与总览卡片显示彩色 SVG 图标
- 优化侧栏链接圆角与选中态样式

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-05-30 18:06:42 +08:00
parent 11129cc3a0
commit f7ce6f1058
8 changed files with 250 additions and 24 deletions
+13
View File
@@ -479,6 +479,7 @@ def create_app() -> Flask:
if form.validate_on_submit():
g = ServiceGroup(
name=form.name.data.strip(),
icon=(form.icon.data or "").strip(),
sort_order=form.sort_order.data or 0,
)
db.session.add(g)
@@ -497,6 +498,7 @@ def create_app() -> Flask:
form = GroupForm(obj=g)
if form.validate_on_submit():
g.name = form.name.data.strip()
g.icon = (form.icon.data or "").strip()
g.sort_order = form.sort_order.data or 0
db.session.commit()
flash("分组已更新", "success")
@@ -666,6 +668,17 @@ def _migrate_schema() -> None:
)
)
print("[nav] 已为 services 表添加 embed_kind 列。", flush=True)
if "service_groups" in insp.get_table_names():
gcols = {c["name"] for c in insp.get_columns("service_groups")}
if "icon" not in gcols:
with db.engine.begin() as conn:
conn.execute(
text(
"ALTER TABLE service_groups ADD COLUMN icon VARCHAR(16) "
"NOT NULL DEFAULT ''"
)
)
print("[nav] 已为 service_groups 表添加 icon 列。", flush=True)
except Exception as exc:
print(f"[nav] 数据库结构迁移跳过或失败: {exc}", flush=True)