diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index c917f3d..3775c94 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -1019,3 +1019,30 @@ label.icon-btn { cursor: pointer; } .modal .modal-text { font-size: 14px; color: #556; margin-bottom: 12px; white-space: pre-wrap; } .modal .del-dir { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink); margin-bottom: 14px; cursor: pointer; } .modal .del-dir input { width: 16px; height: 16px; padding: 0; margin: 0; flex: none; accent-color: var(--active); } + +/* ================= 桌面端布局(≥960px) ================= + 历史侧边栏常驻左侧(由 body.drawer-open 控制展开/折叠,不用遮罩); + 对话区占满右侧剩余宽度,内容限宽并水平居中。移动端(<960px)不受影响。 */ +@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; } + + /* 侧边栏:常驻左列,轻边框与页面区隔 */ + #drawer { width: var(--sidebar-w); box-shadow: none; border-right: 1px solid var(--border); } + /* 桌面端开合不走遮罩 */ + #scrim { display: none !important; } + + /* 对话内容限宽居中 */ + #chat-view { padding: 16px 32px 8px; } + #chat-view > * { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; } + + /* 输入区与会话列同宽、居中 */ + footer { padding-left: 32px; padding-right: 32px; } + footer > * { max-width: 860px; margin-left: auto; margin-right: auto; } + + /* toast 相对会话区(而非整个视口)居中 */ + body.drawer-open #toast { left: calc(50% + var(--sidebar-w) / 2); } +} diff --git a/app/server/public/index.html b/app/server/public/index.html index 1d61904..1f000ef 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -2124,13 +2124,17 @@ }); // ---------- 抽屉 ---------- + // 桌面端(≥960px):侧边栏常驻左侧列(由 body.drawer-open 驱动会话区偏移),不用遮罩; + // 移动端(<960px):仍为浮层抽屉 + 遮罩。 + const drawerMQ = window.matchMedia('(min-width: 960px)'); function openDrawer(open) { // 清掉手势拖动遗留的内联位移/透明度,改由 CSS transition 负责开合动画 const drawer = $('drawer'), scrim = $('scrim'); drawer.style.transform = ''; drawer.style.transition = ''; scrim.style.opacity = ''; drawer.classList.toggle('open', open); - scrim.classList.toggle('show', open); + scrim.classList.toggle('show', open && !drawerMQ.matches); + document.body.classList.toggle('drawer-open', open); } $('menu-btn').addEventListener('click', () => { const open = !$('drawer').classList.contains('open'); @@ -2151,7 +2155,7 @@ const item = e.target.closest('.conv-item'); if (!item) return; openSession(item.dataset.id); - openDrawer(false); + if (!drawerMQ.matches) openDrawer(false); // 桌面端侧栏常驻,选完会话不收起来 }); // ---------- 移动端右滑会话行露出删除按钮(iOS 风格) ---------- @@ -2278,7 +2282,7 @@ // 抽屉底部用户区:整行点击 → 设置主页(逻辑见文末「设置区」一节) $('drawer-user').addEventListener('click', () => { - openDrawer(false); + if (!drawerMQ.matches) openDrawer(false); // 桌面端设置页覆盖在会话区上,侧栏保持展开 showSettings(); }); @@ -3375,6 +3379,8 @@ bindChatScroll(); // 聊天区滚动跟随/右下角回底按钮(只绑一次) selectMode('secretary'); // 默认选中【文秘助理】 setView('welcome'); + openDrawer(drawerMQ.matches); // 桌面端:侧边栏默认展开;跨断点缩放窗口时同步切换开合态 + drawerMQ.addEventListener('change', e => openDrawer(e.matches)); // 页面加载时校验 cookie 身份:防止 localStorage 旧 token 通过 autoRestore 恢复错误用户 // 仅用 cookie 认证(不带 Basic auth),检测服务端实际认定的用户身份 (async () => {