修复:桌面端缩放窗口不自适应、出现横竖滚动条

整站是视口锁定的 app shell(html/body/#app 都 height:100%,滚动交给内部容器),
但桌面端 @media 只补了侧栏偏移:
1)文档自身没锁滚动 → 内部只要有一行没收缩下(nowrap 胶囊/代码块/宽表格)就把内容顶出视口,
   浏览器给窗口加横向滚动条;横向条吃掉一屏高度,而 #app 死守 height:100% → 竖向条跟着冒出来,
   表现为缩窗口页面不动、只多滚动条。
2)#app 桌面宽度靠 max-width:none + margin auto 推导,不给显式宽度 → 补 width:calc(100% - 侧栏)。

改动:html/body 加 overflow:hidden(所有滚动都在内部容器,文档从不需要滚动);
#app 桌面端显式算宽度并随之收缩;#chat-view/#welcome-view/.set-scroll 显式 overflow-x:hidden
(overflow-y:auto 会把 visible 的 overflow-x 算成 auto,宽代码块/表格自带横向滚动,不该让整体溢出)。
移动端行为不变。

顺带修 index.html 里被误写坏的 welcome-slogan class 名(标语样式此前一直没生效)。
This commit is contained in:
2026-09-09 12:17:57 +08:00
parent 7420dcbcf6
commit 8602e2968f
2 changed files with 22 additions and 8 deletions
+21 -7
View File
@@ -13,7 +13,12 @@
--radius-lg: 24px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
/* 整站是视口锁定的 app shell:文档本身永不滚动,滚动只发生在内部容器
(消息流 #chat-view / 抽屉列表 .drawer-list / 设置页 .set-scroll,均已 overflow-y:auto)。
不写 overflow:hidden 时,桌面端只要有一行内容没收缩下(nowrap 胶囊/代码块/宽表格),
浏览器就给窗口加横向滚动条;横向条又吃掉一屏高度,而 #app 死守 height:100%,
于是竖横向滚动条一起出现、缩窗口页面不动。 */
html, body { height: 100%; overflow: hidden; }
body {
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Microsoft YaHei", sans-serif;
color: var(--ink);
@@ -82,7 +87,7 @@ main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* ---------- 未对话状态:模式选择 ---------- */
#welcome-view {
flex: 1; overflow-y: auto;
flex: 1; overflow-y: auto; overflow-x: hidden;
display: flex; flex-direction: column; align-items: center;
padding: max(48px, 10vh) 24px 24px;
}
@@ -123,7 +128,9 @@ main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mode-hint { margin-top: 14px; font-size: 13px; color: var(--gray); min-height: 20px; text-align: center; }
/* ---------- 对话状态:对话内容区 ---------- */
#chat-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 8px; }
/* overflow-x 显式 hidden:overflow-y:auto 会把 visible 的 overflow-x 计算成 auto,
宽代码块/表格自带横向滚动,不该再让消息流整体横向溢出 */
#chat-view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 16px 16px 8px; }
.msg { display: flex; flex-direction: column; margin-bottom: 18px; max-width: 100%; }
.msg.me { align-items: flex-end; }
.msg.other { align-items: flex-start; }
@@ -821,7 +828,7 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0
.header-right .icon-btn:active, .header-right label.icon-btn:active { background: var(--surface); }
label.icon-btn { cursor: pointer; }
#set-body { flex: 1; min-height: 0; background: var(--surface); display: flex; flex-direction: column; }
.set-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px)); }
.set-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px)); }
.empty-tip { color: var(--gray-light); text-align: center; padding: 18px; font-size: 13px; }
/* ---------- 设置主页卡片 ---------- */
@@ -1101,9 +1108,16 @@ label.icon-btn { cursor: pointer; }
@media (min-width: 960px) {
:root { --sidebar-w: 280px; }
/* 会话区占满侧栏右侧;折叠时占满整个窗口 */
#app { max-width: none; margin-left: var(--sidebar-w); transition: margin-left .25s ease; }
body:not(.drawer-open) #app { margin-left: 0; }
/* 会话区占满侧栏右侧;折叠时占满整个窗口。
宽度显式算出来(calc(100% - 侧栏)),不靠 max-width/margin auto 推导,
保证窗口任意缩放都实时跟着缩,内容不会被顶出视口。 */
#app {
max-width: none;
width: calc(100% - var(--sidebar-w));
margin: 0 0 0 var(--sidebar-w);
transition: width .25s ease, margin-left .25s ease;
}
body:not(.drawer-open) #app { width: 100%; margin-left: 0; }
/* 侧边栏:常驻左列,轻边框与页面区隔 */
#drawer { width: var(--sidebar-w); box-shadow: none; border-right: 1px solid var(--border); }
+1 -1
View File
@@ -99,7 +99,7 @@
<div class="logo-badge">
<svg class="ic" viewBox="0 0 24 24"><rect x="4" y="8" width="16" height="12" rx="3"></rect><line x1="12" y1="4" x2="12" y2="8"></line><circle cx="12" cy="3" r="1.4"></circle><circle cx="9" cy="13.5" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="13.5" r="1" fill="currentColor" stroke="none"></circle><line x1="9.5" y1="17" x2="14.5" y2="17"></line></svg>
</div>
<div class="welcome-slog</title>an">选择模式开始对话</div>
<div class="welcome-slogan">选择模式开始对话</div>
</div>
<div class="mode-switch" role="tablist" id="mode-switch">