解决自适应BUG

This commit is contained in:
JackLee 2025-03-04 22:39:15 +08:00
parent 966a57302c
commit 982b11b396
4 changed files with 20 additions and 19 deletions

View File

@ -27,12 +27,12 @@ typedef struct curl_opts
} curl_opts;
typedef struct model_data{
//std::string api_url = "https://api.deepseek.com/chat/completions";
//std::string api_key = "Authorization: Bearer sk-7e6932ed45674c389dea1cd3481e0ec2";
//std::string user_model = "deepseek-chat";
std::string api_url="https://api.siliconflow.cn/v1/chat/completions";
std::string api_key="Authorization: Bearer sk-oiphigpzqtmkkcoucyakrfevcvndroywvxhprvscjqhdykdb";
std::string user_model = "deepseek-ai/DeepSeek-V3";
std::string api_url = "https://api.deepseek.com/chat/completions";
std::string api_key = "Authorization: Bearer sk-7e6932ed45674c389dea1cd3481e0ec2";
std::string user_model = "deepseek-chat";
//std::string api_url="https://api.siliconflow.cn/v1/chat/completions";
//std::string api_key="Authorization: Bearer sk-oiphigpzqtmkkcoucyakrfevcvndroywvxhprvscjqhdykdb";
//std::string user_model = "deepseek-ai/DeepSeek-V3";
std::string send_content_header = "Content-Type: application/json";
std::string send_accept_header = "Accept: application/json";
std::string send_user_data;

View File

@ -230,15 +230,11 @@ void ctai_history_textedit::on_text_height()
static const int HEIGHT_THRESHOLD = 5; // 5像素的阈值
if (abs(m_msg_history->height() - newHeight) > HEIGHT_THRESHOLD)
{
m_original_height = newHeight+15;
// 批量更新布局
m_original_height = newHeight;
bool wasBlocked = m_msg_history->signalsBlocked();
m_msg_history->blockSignals(true);
m_msg_history->setFixedHeight(newHeight);
updateGeometry();
m_msg_history->blockSignals(wasBlocked);
emit current_row_height_changed();

View File

@ -17,7 +17,7 @@ void ctai_history_widget::setup_table()
// 设置自动滚动属性
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
// 滚动步长
verticalScrollBar()->setSingleStep(10);
verticalScrollBar()->setSingleStep(5);
}
ctai_history_widget::~ctai_history_widget()
@ -108,7 +108,7 @@ void ctai_history_widget::add_message(const model_data &message)
void ctai_history_widget::on_rows_height_changed()
{
//全部行高自适应
for (int row = 0; row < rowCount(); ++row) {
for (int row = 0; row < rowCount()-1; ++row) {
resizeRowToContents(row);
}
scrollToBottom();
@ -116,9 +116,14 @@ void ctai_history_widget::on_rows_height_changed()
//适合自适应流式输出内容
void ctai_history_widget::on_current_rows_height_changed()
{
// 当前行高自适应
resizeRowToContents(rowCount());
scrollToBottom();
int row = rowCount()-1;
if (row >= 0 && row < rowCount()) {
int currentHeight = rowHeight(row);
setRowHeight(row, currentHeight + 100);
resizeRowToContents(row);
}
//resizeRowToContents(rowCount()-1);
//scrollToBottom();
}
void ctai_history_widget::on_msg_remove(QString send_id)
{

View File

@ -137,8 +137,8 @@ void ctai_session_info::ctai_session_postback_info(model_data resp_data)
if (QSL(resp_data.postback_model_data).contains("[DONE]"))
{
current_info_id = {};
btn_disable_enable(true);
}
btn_disable_enable(true);
ctai_session_curl_state_tips("");
}
void ctai_session_info::ctai_session_curl_state_tips(std::string state_str)