diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 7940374..28e027f 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -114,12 +114,41 @@ html[theme-mode='dark'] .ss-sidebar .t-menu__item.t-is-active svg:not([fill='non z-index: 10; flex-shrink: 0; animation: twinkle-animation 3s infinite ease-in-out; - transition: background-color 0.3s, color 0.3s; + transition: opacity 0.1s ease, transform 0.1s ease; } -.global-sidebar-toggle:hover { - background-color: var(--ss-item-hover); - color: var(--td-brand-color); +.global-sidebar-toggle.hidden { + opacity: 0; + pointer-events: none; + transform: translateX(10px); +} + +.sidebar-content-area { + display: flex; + flex-direction: column; + backgroundColor: var(--ss-card-bg); + border-radius: 12px 0 0 12px; + box-shadow: -4px 0 16px rgba(0,0,0,0.15); + border: 1px solid var(--ss-border-color); + border-right: none; + padding: 12px 8px; + gap: 12px; + width: 60px; + transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1); + backface-visibility: hidden; + transform: translateZ(0); +} + +.sidebar-content-area.hidden { + opacity: 0; + pointer-events: none; + transform: translateX(20px); +} + +.sidebar-content-area.visible { + opacity: 1; + pointer-events: auto; + transform: translateX(0); } @keyframes twinkle-animation { diff --git a/src/renderer/src/components/GlobalSidebar.tsx b/src/renderer/src/components/GlobalSidebar.tsx index ba50a1c..ee978f3 100644 --- a/src/renderer/src/components/GlobalSidebar.tsx +++ b/src/renderer/src/components/GlobalSidebar.tsx @@ -11,34 +11,47 @@ import { export const GlobalSidebar: React.FC = () => { const [expanded, setExpanded] = useState(false) + const [showToggle, setShowToggle] = useState(true) - useEffect(() => { - if (!(window as any).api) return - if (expanded) { - (window as any).api.windowResize(84, 300) - } else { - (window as any).api.windowResize(24, 300) - } - }, [expanded]) + const handleExpand = () => { + // 1. 先隐藏三角 + setShowToggle(false) + + // 2. 稍后扩大窗口 + setTimeout(() => { + if ((window as any).api) { + (window as any).api.windowResize(84, 300) + } + // 3. 最后显示侧边栏内容 + setTimeout(() => { + setExpanded(true) + }, 20) + }, 100) + } + + const handleCollapse = () => { + // 1. 先隐藏侧边栏内容 + setExpanded(false) + + // 2. 稍后缩小窗口 + setTimeout(() => { + if ((window as any).api) { + (window as any).api.windowResize(24, 300) + } + // 3. 最后重新显示三角 + setTimeout(() => { + setShowToggle(true) + }, 20) + }, 150) + } const openMain = () => { if (!(window as any).api) return (window as any).api.openWindow({ key: 'main', route: '/' }) } - const openQuickPoint = () => { - // 统一使用 / 路径,因为主页即是积分操作页 - openMain() - } - - const openLeaderboard = () => { - if (!(window as any).api) return - (window as any).api.openWindow({ key: 'main', route: '/leaderboard' }) - } - return (