diff --git a/src/components/selected-sounds-display/selected-sounds-display.tsx b/src/components/selected-sounds-display/selected-sounds-display.tsx index d0fa1f6..d433d9c 100644 --- a/src/components/selected-sounds-display/selected-sounds-display.tsx +++ b/src/components/selected-sounds-display/selected-sounds-display.tsx @@ -50,7 +50,7 @@ export function SelectedSoundsDisplay() { Object.keys(state.sounds).filter(id => state.sounds[id].isSelected) ); - // 独立展开逻辑:两个区域可以独立展开/收起 + // 独立展开逻辑:展开当前选中声音时收起所有展开的音乐 const toggleExpandedCurrent = () => { setExpandedCurrent(!expandedCurrent); if (!expandedCurrent) { @@ -101,12 +101,19 @@ export function SelectedSoundsDisplay() { setExpandedMusic(prev => { const newSet = new Set(prev); if (newSet.has(musicId)) { + // 如果点击已展开的音乐,直接收起 newSet.delete(musicId); } else { - newSet.add(musicId); + // 如果点击未展开的音乐,收起其他所有展开的项目,只展开当前这个 + return new Set([musicId]); } return newSet; }); + + // 展开音乐时,同时收起当前选中声音模块 + if (!expandedMusic.has(musicId)) { + setExpandedCurrent(false); + } }; // 根据选中的声音ID获取声音对象 @@ -354,7 +361,7 @@ export function SelectedSoundsDisplay() { {/* 音乐列表 - 展开时显示 */} {expandedMyMusic && ( -
+
0 ? styles.hasExpanded : ''}`}> {console.log('🎵 渲染音乐列表:', { isLoadingMusic, listLength: savedMusicList.length })} {isLoadingMusic ? (
加载中...
diff --git a/src/components/sounds/sounds.module.css b/src/components/sounds/sounds.module.css index 686440a..4fd2841 100644 --- a/src/components/sounds/sounds.module.css +++ b/src/components/sounds/sounds.module.css @@ -134,6 +134,12 @@ overflow-y: auto; border-radius: 6px; background: var(--color-component-bg); + transition: max-height 0.3s ease; +} + +/* 当有展开的音乐项时,移除高度限制 */ +.musicList.hasExpanded { + max-height: none; } .musicItem { @@ -191,8 +197,9 @@ flex: 1; min-width: 0; display: flex; - flex-direction: column; - gap: 2px; + flex-direction: row; + align-items: center; + gap: 8px; } /* 音乐操作按钮容器 - 右侧按钮 */ @@ -207,14 +214,13 @@ .soundNames { font-size: 12px; color: var(--color-foreground-subtle); - line-height: 1.4; + line-height: 1.2; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; - padding: 1px 4px; - flex: 1; - justify-content: flex-start; + padding: 6px 0; + margin: 0; } /* 展开按钮 */ @@ -223,14 +229,14 @@ border: 1px solid var(--color-border); color: var(--color-foreground-subtle); border-radius: 4px; - padding: 2px 6px; - font-size: 10px; + padding: 4px 8px; + font-size: 11px; cursor: pointer; transition: all 0.2s ease; flex-shrink: 0; - height: 24px; + height: auto; line-height: 1; - margin-left: 4px; + margin: 0; } .expandButton:hover { @@ -287,8 +293,8 @@ font-size: 11px; transition: all 0.2s ease; flex-shrink: 0; - height: 24px; - margin-top: 2px; + height: auto; + margin: 0; } .deleteButton:hover {