feat: 简介模式菜单按类型 A/B 分套,兼容未配置的旧部署

两套网页可通过 runtime-config.js 的 VITE_COMPACT_MENU_TYPE 加载各自左侧菜单;缺省或旧页面不传参数时仍读取原来的类型 A 数据。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
董宏凯andCursor committed 2026-08-19 16:59:34 +08:00
1 parent 5e1765d889
commit acf538ac01
21 files changed
+610 -103

No files matched your search

@@ -0,0 +1,52 @@
"""Add compact_menu_overrides.menu_type (简介模式菜单分套).
Two website deployments keep independent compact/sidebar-summary left menus.
Type ``A`` is the historical default; type ``B`` is stored under a prefixed
``node_id`` so it never collides on databases that still use ``node_id`` as
the sole primary key.
ORM: ``CompactMenuOverrideRow.menu_type = String(32), NOT NULL, default A``.
``create_all`` gives new DBs the column; existing DBs are patched by this
revision and by startup ``_ensure_orm_columns_sync``.
Revision ID: 20260819_01
Revises: 20260816_01
Create Date: 2026-08-19
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
revision = "20260819_01"
down_revision = "20260816_01"
branch_labels = None
depends_on = None
def _has_table(table_name: str) -> bool:
inspector = inspect(op.get_bind())
return table_name in inspector.get_table_names()
def _has_column(table_name: str, column_name: str) -> bool:
if not _has_table(table_name):
return False
inspector = inspect(op.get_bind())
return any(col["name"] == column_name for col in inspector.get_columns(table_name))
def upgrade() -> None:
if _has_table("compact_menu_overrides") and not _has_column("compact_menu_overrides", "menu_type"):
op.add_column(
"compact_menu_overrides",
sa.Column("menu_type", sa.String(length=32), nullable=False, server_default="A"),
)
def downgrade() -> None:
if _has_column("compact_menu_overrides", "menu_type"):
op.drop_column("compact_menu_overrides", "menu_type")