聊天样式微调

This commit is contained in:
super committed 2026-03-29 11:45:36 +08:00
1 parent fafcdfe742
commit efae286f5c
12 files changed
+442 -293

No files matched your search

+2 -2
View File
@@ -10,8 +10,8 @@
<meta name="apple-mobile-web-app-title" content="hxai" />
<link rel="manifest" href="/manifest.webmanifest" />
<title>hxai</title>
<script type="module" crossorigin src="/assets/index-BeNIRipD.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-H6QPki_i.css">
<script type="module" crossorigin src="/assets/index-CevSaenJ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CqpZrvvZ.css">
</head>
<body>
<div id="app"></div>
-1
View File
@@ -1 +0,0 @@
Single-database configuration for Flask.
-50
View File
@@ -1,50 +0,0 @@
# A generic, single database configuration.
[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic,flask_migrate
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[logger_flask_migrate]
level = INFO
handlers =
qualname = flask_migrate
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
-113
View File
@@ -1,113 +0,0 @@
import logging
from logging.config import fileConfig
from flask import current_app
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env')
def get_engine():
try:
# this works with Flask-SQLAlchemy<3 and Alchemical
return current_app.extensions['migrate'].db.get_engine()
except (TypeError, AttributeError):
# this works with Flask-SQLAlchemy>=3
return current_app.extensions['migrate'].db.engine
def get_engine_url():
try:
return get_engine().url.render_as_string(hide_password=False).replace(
'%', '%%')
except AttributeError:
return str(get_engine().url).replace('%', '%%')
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
config.set_main_option('sqlalchemy.url', get_engine_url())
target_db = current_app.extensions['migrate'].db
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def get_metadata():
if hasattr(target_db, 'metadatas'):
return target_db.metadatas[None]
return target_db.metadata
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=get_metadata(), literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
conf_args = current_app.extensions['migrate'].configure_args
if conf_args.get("process_revision_directives") is None:
conf_args["process_revision_directives"] = process_revision_directives
connectable = get_engine()
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=get_metadata(),
**conf_args
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
-24
View File
@@ -1,24 +0,0 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}
@@ -1,101 +0,0 @@
"""Initial migration
Revision ID: 7e0f9be4da73
Revises:
Create Date: 2026-02-22 22:06:59.375138
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7e0f9be4da73'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('agents',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('icon_url', sa.String(length=255), nullable=True),
sa.Column('dify_app_id', sa.String(length=100), nullable=False),
sa.Column('dify_api_key', sa.String(length=100), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('dify_app_id')
)
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=50), nullable=False),
sa.Column('email', sa.String(length=100), nullable=False),
sa.Column('department', sa.String(length=100), nullable=True),
sa.Column('role', sa.String(length=20), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email')
)
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_users_username'), ['username'], unique=True)
op.create_table('chat_logs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('conversation_id', sa.String(length=100), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('agent_id', sa.Integer(), nullable=False),
sa.Column('query', sa.Text(), nullable=False),
sa.Column('answer', sa.Text(), nullable=True),
sa.Column('tokens_used', sa.Integer(), nullable=False),
sa.Column('latency_ms', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('chat_logs', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_chat_logs_agent_id'), ['agent_id'], unique=False)
batch_op.create_index(batch_op.f('ix_chat_logs_conversation_id'), ['conversation_id'], unique=False)
batch_op.create_index(batch_op.f('ix_chat_logs_created_at'), ['created_at'], unique=False)
batch_op.create_index(batch_op.f('ix_chat_logs_user_id'), ['user_id'], unique=False)
op.create_table('user_agent_permissions',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('agent_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['agent_id'], ['agents.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('user_id', 'agent_id')
)
op.create_table('feedbacks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('chat_log_id', sa.Integer(), nullable=False),
sa.Column('score', sa.Integer(), nullable=False),
sa.Column('tags', sa.JSON(), nullable=True),
sa.Column('comment', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['chat_log_id'], ['chat_logs.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('chat_log_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('feedbacks')
op.drop_table('user_agent_permissions')
with op.batch_alter_table('chat_logs', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_chat_logs_user_id'))
batch_op.drop_index(batch_op.f('ix_chat_logs_created_at'))
batch_op.drop_index(batch_op.f('ix_chat_logs_conversation_id'))
batch_op.drop_index(batch_op.f('ix_chat_logs_agent_id'))
op.drop_table('chat_logs')
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_users_username'))
op.drop_table('users')
op.drop_table('agents')
# ### end Alembic commands ###
+37
View File
@@ -113,6 +113,29 @@
border-color: rgba(148, 163, 184, 0.26);
box-shadow: var(--glow-accent);
}
/* Keep chat composer border and fill visually consistent in light/dark themes. */
.chat-composer-shell {
background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.97) 100%);
box-shadow: 0 14px 28px -20px rgba(15, 23, 42, 0.38);
background-clip: padding-box;
}
.chat-composer-shell:focus-within {
transform: translateY(-1px);
box-shadow: 0 16px 34px -22px rgba(14, 165, 233, 0.45);
}
.chat-composer-textarea {
background-color: transparent !important;
border: 0 !important;
text-decoration: none;
caret-color: #0891b2;
}
.chat-composer-textarea::selection {
background-color: rgba(14, 165, 233, 0.2);
}
}
@layer components {
@@ -150,6 +173,20 @@ html.dark .glass-panel {
background: rgba(2, 6, 23, 0.66);
border-color: rgba(71, 85, 105, 0.5);
}
html.dark .chat-composer-shell {
background-image: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(10, 16, 30, 0.92) 100%);
box-shadow: 0 18px 36px -28px rgba(2, 6, 23, 0.96);
}
html.dark .chat-composer-textarea {
background-color: transparent !important;
caret-color: #67e8f9;
}
html.dark .chat-composer-textarea::selection {
background-color: rgba(56, 189, 248, 0.25);
}
}
/* Custom Scrollbar */
+5 -2
View File
@@ -743,15 +743,18 @@ const submitFeedback = async () => {
<footer class="safe-bottom-lg sticky bottom-0 z-20 border-t border-slate-200/80 bg-white/70 p-4 backdrop-blur-xl dark:border-slate-700/70 dark:bg-slate-950/65 md:p-6">
<div class="relative mx-auto max-w-5xl">
<div class="relative rounded-2xl border border-slate-200 bg-white/95 shadow-xl shadow-slate-300/25 transition-all duration-300 focus-within:border-cyan-500 focus-within:ring-2 focus-within:ring-cyan-500/25 dark:border-slate-700 dark:bg-slate-900/88 dark:shadow-none">
<div class="chat-composer-shell relative overflow-hidden rounded-2xl border border-slate-200 bg-white/95 shadow-xl shadow-slate-300/25 transition-all duration-300 focus-within:border-cyan-500 focus-within:ring-2 focus-within:ring-cyan-500/25 dark:border-slate-700 dark:bg-slate-900/88 dark:shadow-none">
<textarea
v-model="input"
@keydown.enter.prevent="handleSend"
rows="1"
:placeholder="$t('chat.placeholder')"
class="w-full resize-none bg-transparent py-4 pl-5 pr-14 text-[15px] leading-relaxed text-slate-800 placeholder-slate-400 focus:outline-none dark:text-slate-100 dark:placeholder-slate-500"
class="chat-composer-textarea w-full resize-none bg-transparent py-4 pl-5 pr-14 text-[15px] leading-relaxed text-slate-800 placeholder-slate-400 focus:outline-none dark:text-slate-100 dark:placeholder-slate-500"
style="min-height: 56px; max-height: 220px;"
:disabled="isThinking"
spellcheck="false"
autocorrect="off"
autocapitalize="off"
></textarea>
<button
@click="handleSend"