chore: rebuild release package

This commit is contained in:
shiyue
2026-07-18 12:39:55 +08:00
parent a76de06c47
commit b90f5e1e44
14 changed files with 512 additions and 13 deletions

View File

@@ -9,6 +9,9 @@
const DIVIDER_TIME_STORAGE_KEY = 'cc-web-show-divider-time';
const CCWEB_PROMPT_VIEW_MODE_STORAGE_KEY = 'cc-web-ccweb-prompt-view-mode';
const PROJECT_COLLAPSE_STORAGE_KEY = 'cc-web-collapsed-projects';
const SIDEBAR_COLLAPSE_STORAGE_KEY = 'cc-web-sidebar-collapsed';
const SIDEBAR_DRAWER_MEDIA_QUERY = '(max-width: 768px)';
const SIDEBAR_DESKTOP_COLLAPSE_MEDIA_QUERY = '(width > 768px) and (hover: hover) and (pointer: fine)';
const CROSS_CONVERSATION_REPLY_COLLAPSE_STORAGE_KEY = 'cc-web-collapsed-cross-replies';
const CROSS_CONVERSATION_REPLY_COLLAPSE_LIMIT = 500;
const ASSISTANT_LAST_SECTION_BUTTON_CLASS = 'msg-last-section-btn';
@@ -278,6 +281,9 @@
const sidebar = $('#sidebar');
const sidebarOverlay = $('#sidebar-overlay');
const menuBtn = $('#menu-btn');
const mobileInputMedia = window.matchMedia('(max-width: 768px), (pointer: coarse)');
const sidebarDrawerMedia = window.matchMedia(SIDEBAR_DRAWER_MEDIA_QUERY);
const sidebarDesktopCollapseMedia = window.matchMedia(SIDEBAR_DESKTOP_COLLAPSE_MEDIA_QUERY);
const chatMain = document.querySelector('.chat-main');
const newChatSplit = sidebar.querySelector('.new-chat-split');
const newChatBtn = $('#new-chat-btn');
@@ -8510,17 +8516,67 @@
}
// --- Sidebar ---
function readSidebarCollapsedPreference() {
try {
return localStorage.getItem(SIDEBAR_COLLAPSE_STORAGE_KEY) === 'true';
} catch {
return false;
}
}
function persistSidebarCollapsedPreference(collapsed) {
try {
localStorage.setItem(SIDEBAR_COLLAPSE_STORAGE_KEY, collapsed ? 'true' : 'false');
} catch {
// 存储不可用时仍保留当前页面内的交互状态。
}
}
function syncSidebarButtonState() {
const isDrawer = isSidebarDrawerMode();
const isDesktopCollapsible = isSidebarDesktopCollapseMode();
// aria-expanded 表示按钮控制的固定/抽屉状态hover/focus 预览不改变用户的固定选择。
const expanded = isDrawer
? sidebar.classList.contains('open')
: (isDesktopCollapsible ? !app.classList.contains('sidebar-collapsed') : true);
const label = isDrawer
? (expanded ? '关闭左侧菜单' : '打开左侧菜单')
: (isDesktopCollapsible
? (expanded ? '收起左侧菜单' : '固定展开左侧菜单')
: '左侧菜单');
menuBtn.setAttribute('aria-expanded', String(expanded));
menuBtn.setAttribute('aria-label', label);
menuBtn.title = label;
}
function setSidebarCollapsed(collapsed, { persist = false } = {}) {
const nextCollapsed = Boolean(collapsed);
app.classList.toggle('sidebar-collapsed', nextCollapsed);
if (persist) persistSidebarCollapsedPreference(nextCollapsed);
syncSidebarButtonState();
}
function openSidebar() {
sidebar.classList.add('open');
sidebarOverlay.hidden = false;
syncSidebarButtonState();
}
function closeSidebar() {
sidebar.classList.remove('open');
sidebarOverlay.hidden = true;
syncSidebarButtonState();
}
function handleSidebarInputModeChange() {
sidebar.classList.remove('open');
sidebarOverlay.hidden = true;
syncSidebarButtonState();
}
setSidebarCollapsed(readSidebarCollapsedPreference());
function canOpenSidebarBySwipe(target) {
if (!window.matchMedia('(max-width: 768px), (pointer: coarse)').matches) return false;
if (!isSidebarDrawerMode()) return false;
if (sidebar.classList.contains('open')) return false;
if (sessionLoadingOverlay && !sessionLoadingOverlay.hidden) return false;
if (!chatMain || !target || !chatMain.contains(target)) return false;
@@ -8531,7 +8587,7 @@
}
function canCloseSidebarBySwipe(target) {
if (!window.matchMedia('(max-width: 768px), (pointer: coarse)').matches) return false;
if (!isSidebarDrawerMode()) return false;
if (!sidebar.classList.contains('open')) return false;
if (!target) return false;
return sidebar.contains(target) || target === sidebarOverlay;
@@ -8996,7 +9052,15 @@
}
function isMobileInputMode() {
return window.matchMedia('(max-width: 768px), (pointer: coarse)').matches;
return mobileInputMedia.matches;
}
function isSidebarDrawerMode() {
return sidebarDrawerMedia.matches;
}
function isSidebarDesktopCollapseMode() {
return sidebarDesktopCollapseMedia.matches;
}
// --- Event Listeners ---
@@ -9018,10 +9082,23 @@
});
menuBtn.addEventListener('click', () => {
sidebar.classList.contains('open') ? closeSidebar() : openSidebar();
if (isSidebarDrawerMode()) {
sidebar.classList.contains('open') ? closeSidebar() : openSidebar();
return;
}
if (isSidebarDesktopCollapseMode()) {
setSidebarCollapsed(!app.classList.contains('sidebar-collapsed'), { persist: true });
}
});
sidebarOverlay.addEventListener('click', closeSidebar);
[sidebarDrawerMedia, sidebarDesktopCollapseMedia].forEach((media) => {
if (typeof media.addEventListener === 'function') {
media.addEventListener('change', handleSidebarInputModeChange);
} else if (typeof media.addListener === 'function') {
media.addListener(handleSidebarInputModeChange);
}
});
document.addEventListener('touchstart', handleSidebarSwipeStart, { passive: true });
document.addEventListener('touchmove', handleSidebarSwipeMove, { passive: false });
document.addEventListener('touchend', handleSidebarSwipeEnd, { passive: true });