From 8602e2968fa68650442c2de79d81038c6c10f185 Mon Sep 17 00:00:00 2001 From: kicer Date: Wed, 9 Sep 2026 12:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E7=AB=AF=E7=BC=A9=E6=94=BE=E7=AA=97=E5=8F=A3=E4=B8=8D=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E3=80=81=E5=87=BA=E7=8E=B0=E6=A8=AA=E7=AB=96?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 整站是视口锁定的 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 名(标语样式此前一直没生效)。 --- app/server/public/css/style.css | 28 +++++++++++++++++++++------- app/server/public/index.html | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 3dae157..52c8502 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -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); } diff --git a/app/server/public/index.html b/app/server/public/index.html index 64304ae..2cfda9a 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -99,7 +99,7 @@
-
选择模式开始对话
+
选择模式开始对话