feature: 新增小说封面图片生成功能

This commit is contained in:
xiamuceer
2026-03-16 11:34:07 +08:00
parent 2ca4c9cd27
commit 411f906545
22 changed files with 1516 additions and 205 deletions
@@ -0,0 +1,48 @@
"""添加小说封面生成配置
Revision ID: 8e3ac0236b27
Revises: d4d253e3f4c6
Create Date: 2026-03-16 10:56:31.489936
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '8e3ac0236b27'
down_revision: Union[str, None] = 'd4d253e3f4c6'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('projects', sa.Column('cover_image_url', sa.String(length=1000), nullable=True, comment='封面图片访问地址'))
op.add_column('projects', sa.Column('cover_prompt', sa.Text(), nullable=True, comment='最近一次生成封面使用的提示词'))
op.add_column('projects', sa.Column('cover_status', sa.String(length=20), nullable=False, server_default='none', comment='封面状态: none/generating/ready/failed'))
op.add_column('projects', sa.Column('cover_error', sa.Text(), nullable=True, comment='最近一次封面生成失败原因'))
op.add_column('projects', sa.Column('cover_updated_at', sa.DateTime(), nullable=True, comment='最近一次封面生成成功时间'))
op.add_column('settings', sa.Column('cover_api_provider', sa.String(length=50), nullable=True, comment='封面图片API提供商'))
op.add_column('settings', sa.Column('cover_api_key', sa.String(length=500), nullable=True, comment='封面图片API密钥'))
op.add_column('settings', sa.Column('cover_api_base_url', sa.String(length=500), nullable=True, comment='封面图片自定义API地址'))
op.add_column('settings', sa.Column('cover_image_model', sa.String(length=100), nullable=True, comment='封面图片模型名称'))
op.add_column('settings', sa.Column('cover_enabled', sa.Boolean(), nullable=False, server_default=sa.text('false'), comment='是否启用封面图片生成'))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('settings', 'cover_enabled')
op.drop_column('settings', 'cover_image_model')
op.drop_column('settings', 'cover_api_base_url')
op.drop_column('settings', 'cover_api_key')
op.drop_column('settings', 'cover_api_provider')
op.drop_column('projects', 'cover_updated_at')
op.drop_column('projects', 'cover_error')
op.drop_column('projects', 'cover_status')
op.drop_column('projects', 'cover_prompt')
op.drop_column('projects', 'cover_image_url')
# ### end Alembic commands ###