fix: 新建会话时强制中断生成并恢复发送按钮
- startNewSession() 中 abort 正在进行的流式请求 - 重置 IS_STREAMING = false, ABORT_CONTROLLER = null - 强制恢复发送按钮图标和状态
This commit is contained in:
@@ -128,6 +128,23 @@ async function startNewSession(): Promise<void> {
|
||||
const session = createNewSession();
|
||||
state.set(KEYS.CURRENT_SESSION, session);
|
||||
logInfo('新建会话');
|
||||
|
||||
// ── 强制中断正在进行的生成 ──
|
||||
const abortController = state.get<AbortController | null>(KEYS.ABORT_CONTROLLER);
|
||||
if (abortController) {
|
||||
abortController.abort();
|
||||
}
|
||||
state.set(KEYS.IS_STREAMING, false);
|
||||
state.set(KEYS.ABORT_CONTROLLER, null);
|
||||
|
||||
// ── 恢复发送按钮 ──
|
||||
const btnSend = document.querySelector('#btnSend') as HTMLButtonElement;
|
||||
if (btnSend) {
|
||||
btnSend.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>`;
|
||||
btnSend.classList.remove('stop-btn', 'disabled');
|
||||
btnSend.title = '发送';
|
||||
}
|
||||
|
||||
state.set(KEYS.IS_HISTORY_VIEW, false);
|
||||
|
||||
(document.querySelector('#historyBar') as HTMLElement).style.display = 'none';
|
||||
|
||||
Reference in New Issue
Block a user