feat(plugins): Cookie 管理插件(账号/站点 + 刷新记录)
以插件方式新增 Cookie 管理模块,不改动 framework 业务逻辑。
数据层
- CookieUser / CookieSite 两个模型(applications/models/admin_cookie.py)
- 对应 ManageSchema(applications/schemas/admin_cookie.py)
- 模型与 schema 在 applications/{models,schemas}/__init__.py 中注册,便于 Alembic 跟踪
- 新增两个迁移脚本(cookie_site / cookie_user + cookie 站点表)
插件
- plugins/cookieManager/:入口 __init__.py + 三个视图(概览 / 账号 / 站点)
- 后台模板:cookie_user 与 cookie_site 各自的 main/add/edit
- 路由前缀 /system/cookie-user/*、/system/cookie-site/*
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
"""add cookie_user and cookie_site tables
|
||||
|
||||
Revision ID: 1230ff234df9
|
||||
Revises: 9ae98ba6025b
|
||||
Create Date: 2026-09-08 16:51:22.296613
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1230ff234df9'
|
||||
down_revision = '9ae98ba6025b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('admin_cookie_site',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('name', sa.String(length=100), nullable=False, comment='网站名称'),
|
||||
sa.Column('url', sa.String(length=255), nullable=False, comment='网站URL'),
|
||||
sa.Column('cookie_value', sa.Text(), nullable=False, comment='Cookie值'),
|
||||
sa.Column('domain', sa.String(length=255), nullable=True, comment='Cookie域名'),
|
||||
sa.Column('path', sa.String(length=255), nullable=True, comment='Cookie路径'),
|
||||
sa.Column('expiry', sa.DateTime(), nullable=True, comment='过期时间'),
|
||||
sa.Column('secure', sa.Integer(), nullable=True, comment='是否安全'),
|
||||
sa.Column('http_only', sa.Integer(), nullable=True, comment='是否HTTPOnly'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='状态(1启用,0禁用)'),
|
||||
sa.Column('create_by', sa.String(length=50), nullable=True, comment='创建者'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_cookie_user',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column('username', sa.String(length=100), nullable=False, comment='用户名'),
|
||||
sa.Column('nickname', sa.String(length=100), nullable=True, comment='昵称'),
|
||||
sa.Column('website_url', sa.String(length=255), nullable=False, comment='网站URL'),
|
||||
sa.Column('website_name', sa.String(length=100), nullable=True, comment='网站名称'),
|
||||
sa.Column('cookie_value', sa.Text(), nullable=False, comment='Cookie值'),
|
||||
sa.Column('domain', sa.String(length=255), nullable=True, comment='Cookie域名'),
|
||||
sa.Column('expiry', sa.DateTime(), nullable=True, comment='过期时间'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='状态(1启用,0禁用)'),
|
||||
sa.Column('create_by', sa.String(length=50), nullable=True, comment='创建者'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.drop_table('admin_cookie_manager')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('admin_cookie_manager',
|
||||
sa.Column('id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('website_id', sa.INTEGER(), nullable=False),
|
||||
sa.Column('website_name', sa.VARCHAR(length=100), nullable=True),
|
||||
sa.Column('website_url', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('name', sa.VARCHAR(length=100), nullable=False),
|
||||
sa.Column('value', sa.TEXT(), nullable=False),
|
||||
sa.Column('domain', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('path', sa.VARCHAR(length=255), nullable=True),
|
||||
sa.Column('expiry', sa.DATETIME(), nullable=True),
|
||||
sa.Column('secure', sa.INTEGER(), nullable=True),
|
||||
sa.Column('http_only', sa.INTEGER(), nullable=True),
|
||||
sa.Column('enable', sa.INTEGER(), nullable=True),
|
||||
sa.Column('create_by', sa.VARCHAR(length=50), nullable=True),
|
||||
sa.Column('create_at', sa.DATETIME(), nullable=True),
|
||||
sa.Column('update_at', sa.DATETIME(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.drop_table('admin_cookie_user')
|
||||
op.drop_table('admin_cookie_site')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,45 @@
|
||||
"""add cookie_manager table
|
||||
|
||||
Revision ID: 9ae98ba6025b
|
||||
Revises: a47a5d2a3f1b
|
||||
Create Date: 2026-09-08 15:23:56.125419
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9ae98ba6025b'
|
||||
down_revision = 'a47a5d2a3f1b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('admin_cookie_manager',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='主键ID'),
|
||||
sa.Column('website_id', sa.Integer(), nullable=False, comment='网站ID'),
|
||||
sa.Column('website_name', sa.String(length=100), nullable=True, comment='网站名称'),
|
||||
sa.Column('website_url', sa.String(length=255), nullable=True, comment='网站URL'),
|
||||
sa.Column('name', sa.String(length=100), nullable=False, comment='Cookie名称'),
|
||||
sa.Column('value', sa.Text(), nullable=False, comment='Cookie值'),
|
||||
sa.Column('domain', sa.String(length=255), nullable=True, comment='Cookie域名'),
|
||||
sa.Column('path', sa.String(length=255), nullable=True, comment='Cookie路径'),
|
||||
sa.Column('expiry', sa.DateTime(), nullable=True, comment='过期时间'),
|
||||
sa.Column('secure', sa.Integer(), nullable=True, comment='是否安全'),
|
||||
sa.Column('http_only', sa.Integer(), nullable=True, comment='是否HTTPOnly'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='状态(1启用,0禁用)'),
|
||||
sa.Column('create_by', sa.String(length=50), nullable=True, comment='创建者'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('admin_cookie_manager')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user