refactor: 前端架构重构 - 提取 CSS 和逻辑到独立模块
前端重构: - 删除旧的大体积 Vue 组件(HomeView, FileManage, TextSplit 等) - 删除旧的 composables(useFormatters, useModels, useProjects) - 新增 core/, page-logic/, pages/, shared/ 模块化目录结构 - 提取 CSS 到 styles/pages/ 目录 - 添加全局样式 variables.css 和 common.css 后端 API 更新: - chunks: 语义分割 API 增强 - files: 文件处理 API 更新 - models: 模型管理 API 更新 - questions: 问答管理 API 更新 - database: 数据库连接优化 - semantic_embedding: 语义嵌入服务优化 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from contextlib import asynccontextmanager
|
||||
from typing import AsyncGenerator
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
from sqlalchemy import create_engine, event
|
||||
from sqlalchemy import create_engine, event, inspect, text
|
||||
from sqlalchemy.pool import NullPool
|
||||
|
||||
from app.core.config import get_settings
|
||||
@@ -65,9 +65,28 @@ async def init_db():
|
||||
logger.info("Initializing database...")
|
||||
async with async_engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
await conn.run_sync(_ensure_legacy_columns)
|
||||
logger.info("Database initialized successfully")
|
||||
|
||||
|
||||
def _ensure_legacy_columns(sync_conn):
|
||||
"""Patch legacy tables with newly introduced columns."""
|
||||
inspector = inspect(sync_conn)
|
||||
if "model_configs" not in inspector.get_table_names():
|
||||
return
|
||||
|
||||
columns = {column["name"] for column in inspector.get_columns("model_configs")}
|
||||
if "model_type" in columns:
|
||||
return
|
||||
|
||||
logger.info("Adding missing model_type column to model_configs table")
|
||||
dialect = sync_conn.dialect.name
|
||||
if dialect == "postgresql":
|
||||
sync_conn.execute(text("ALTER TABLE model_configs ADD COLUMN model_type VARCHAR(50) NOT NULL DEFAULT 'chat'"))
|
||||
else:
|
||||
sync_conn.execute(text("ALTER TABLE model_configs ADD COLUMN model_type VARCHAR(50) NOT NULL DEFAULT 'chat'"))
|
||||
|
||||
|
||||
async def close_db():
|
||||
"""Close database connections"""
|
||||
logger.info("Closing database connections...")
|
||||
|
||||
Reference in New Issue
Block a user