diff --git a/static/app.js b/static/app.js index 7361314..f9a1341 100644 --- a/static/app.js +++ b/static/app.js @@ -204,6 +204,8 @@ async function bootstrapApp() { settingsOpen: false, quickMenuOpen: false, inputLineCount: 1, + inputIsMultiline: false, + inputIsFocused: false, // 思考块滚动锁 thinkingScrollLocks: new Map(), @@ -1327,6 +1329,7 @@ async function bootstrapApp() { this.toolMenuOpen = false; this.quickMenuOpen = false; this.inputLineCount = 1; + this.inputIsMultiline = false; this.toolSettingsLoading = false; this.toolSettings = []; @@ -2458,19 +2461,37 @@ async function bootstrapApp() { this.autoResizeInput(); }, + handleInputFocus() { + this.inputIsFocused = true; + }, + + handleInputBlur() { + this.inputIsFocused = false; + }, + autoResizeInput() { this.$nextTick(() => { const textarea = this.$refs.stadiumInput; if (!textarea) { return; } + const previousHeight = textarea.offsetHeight; textarea.style.height = 'auto'; const computedStyle = window.getComputedStyle(textarea); const lineHeight = parseFloat(computedStyle.lineHeight || '20') || 20; const maxHeight = lineHeight * 6; - const newHeight = Math.min(textarea.scrollHeight, maxHeight); - textarea.style.height = `${newHeight}px`; - this.inputLineCount = Math.max(1, Math.round(newHeight / lineHeight)); + const targetHeight = Math.min(textarea.scrollHeight, maxHeight); + this.inputLineCount = Math.max(1, Math.round(targetHeight / lineHeight)); + this.inputIsMultiline = targetHeight > lineHeight * 1.4; + if (Math.abs(targetHeight - previousHeight) <= 0.5) { + textarea.style.height = `${targetHeight}px`; + return; + } + textarea.style.height = `${previousHeight}px`; + void textarea.offsetHeight; + requestAnimationFrame(() => { + textarea.style.height = `${targetHeight}px`; + }); }); }, @@ -2478,7 +2499,7 @@ async function bootstrapApp() { if (!this.quickMenuOpen) { return; } - const shell = this.$refs.compactInputShell; + const shell = this.$refs.stadiumShellOuter || this.$refs.compactInputShell; if (shell && shell.contains(event.target)) { return; } diff --git a/static/index.html b/static/index.html index ee92ad0..86f0f3e 100644 --- a/static/index.html +++ b/static/index.html @@ -488,35 +488,45 @@