Skip to content

Commit 833e83b

Browse files
committed
feat: 优化窄窗口布局样式 #149
1 parent 1f935c2 commit 833e83b

15 files changed

Lines changed: 156 additions & 90 deletions

File tree

‎electron/main/window/create.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import icon from "../../../public/icons/favicon.png?asset";
88
const getDefaultOptions = (): BrowserWindowConstructorOptions => ({
99
width: 1280,
1010
height: 800,
11-
minWidth: 1280,
12-
minHeight: 800,
11+
minWidth: 900,
12+
minHeight: 600,
1313
autoHideMenuBar: true,
1414
show: false,
1515
backgroundColor: nativeTheme.shouldUseDarkColors ? "#101014" : "#f6f6f6",

‎electron/main/window/taskbarLyric.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ export const createTaskbarLyricWindow = (): BrowserWindow | null => {
292292
taskbarLyricWindow = createWindow({
293293
width: INITIAL_WIDTH,
294294
height: INITIAL_HEIGHT,
295-
// 覆盖默认 minWidth/minHeight(800/600),允许 setBounds 缩小到很小
296295
minWidth: 0,
297296
minHeight: 0,
298297
type: "toolbar",

‎src/components/layout/NavHeader.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const onMenuSelect = (key: string): void => {
8383
<NavSearch />
8484
<SButton
8585
v-if="update.hasUpdate"
86-
class="app-no-drag shrink-0"
86+
class="app-no-drag shrink-0 lt-md:hidden"
8787
variant="tertiary"
8888
circle
8989
:size="40"

‎src/components/layout/NavSearch.vue‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ onMounted(() => {
295295
<div
296296
role="button"
297297
:aria-label="t('nav.searchPlaceholder')"
298-
class="app-no-drag w-60 h-10 px-4 cursor-pointer flex items-center gap-2 rounded-full border border-solid bg-on-surface/3 border-on-surface/15 hover:bg-on-surface/10 hover:border-on-surface/25 transition-colors duration-250 select-none"
298+
class="app-no-drag w-60 lt-compact:w-40 lt-md:w-10 h-10 px-4 lt-md:px-0 cursor-pointer flex items-center lt-md:justify-center gap-2 rounded-full border border-solid bg-on-surface/3 border-on-surface/15 hover:bg-on-surface/10 hover:border-on-surface/25 transition-colors duration-250 select-none"
299299
@click="dialogOpen = true"
300300
@contextmenu.prevent="dialogOpen = true"
301301
@mousedown.prevent
302302
>
303303
<IconLucideSearch class="size-4 text-on-surface-variant/50 shrink-0" />
304-
<span class="flex-1 min-w-0 truncate text-base text-on-surface-variant/40">
304+
<span class="flex-1 min-w-0 truncate text-base text-on-surface-variant/40 lt-md:hidden">
305305
{{ t("nav.searchPlaceholder") }}
306306
</span>
307307
</div>

‎src/components/layout/NavUser.vue‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const handleLogout = async (): Promise<void> => {
8888
>
8989
<template #trigger>
9090
<div
91-
class="app-no-drag inline-flex items-center gap-2 h-10 pl-1 pr-3 rounded-full bg-on-surface/6 hover:bg-on-surface/10 transition-colors cursor-pointer select-none"
91+
class="app-no-drag inline-flex items-center gap-2 h-10 pl-1 pr-3 lt-sidebar:pr-1 rounded-full bg-on-surface/6 hover:bg-on-surface/10 transition-colors cursor-pointer select-none"
9292
>
9393
<span
9494
class="size-8 rounded-full overflow-hidden bg-on-surface/10 flex items-center justify-center"
@@ -102,13 +102,13 @@ const handleLogout = async (): Promise<void> => {
102102
/>
103103
<IconLucideUserRound v-else class="size-4 text-on-surface-variant" />
104104
</span>
105-
<span class="text-sm text-on-surface max-w-[7rem] truncate">
105+
<span class="text-sm text-on-surface max-w-[7rem] truncate lt-sidebar:hidden">
106106
{{ user.profile?.nickname || t("login.unknownUser") }}
107107
</span>
108-
<img v-if="isVip" :src="vipImg" alt="VIP" class="h-4 shrink-0" />
108+
<img v-if="isVip" :src="vipImg" alt="VIP" class="h-4 shrink-0 lt-sidebar:hidden" />
109109
<IconLucideChevronDown
110110
:class="[
111-
'size-3 text-on-surface-variant transition-transform duration-200',
111+
'size-3 text-on-surface-variant transition-transform duration-200 lt-sidebar:hidden',
112112
popoverOpen && 'rotate-180',
113113
]"
114114
/>

‎src/components/layout/SideBar.vue‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { usePlaylistStore } from "@/stores/playlist";
1111
import { useUserStore } from "@/stores/user";
1212
import { useDownloadStore } from "@/stores/download";
1313
import { useHeartMode } from "@/composables/useHeartMode";
14+
import { useResponsiveLayout } from "@/composables/useResponsiveLayout";
1415
import { useSettingsDialog } from "@/settings/useSettingsDialog";
1516
import * as player from "@/core/player";
1617
import IconLucideListMusic from "~icons/lucide/list-music";
@@ -31,6 +32,7 @@ const playlistStore = usePlaylistStore();
3132
const userStore = useUserStore();
3233
const downloadStore = useDownloadStore();
3334
const { enterHeartMode } = useHeartMode();
35+
const { sidebarCollapsed } = useResponsiveLayout();
3436
const settingsDialog = useSettingsDialog();
3537
3638
/** 心动模式 */
@@ -346,21 +348,19 @@ onMounted(() => {
346348

347349
<template>
348350
<div class="flex flex-col h-full">
349-
<SideBarLogo :collapsed="appearance.sidebarCollapsed" />
351+
<SideBarLogo :collapsed="sidebarCollapsed" />
350352
<SContextMenu :items="contextMenuItems" @select="onContextMenuSelect">
351353
<div
352354
class="flex-1 min-h-0 pb-3 overflow-y-auto transition-[padding] duration-300"
353355
:class="
354-
appearance.sidebarCollapsed
355-
? 'px-2 [&::-webkit-scrollbar]:hidden'
356-
: 'px-3 [scrollbar-gutter:stable]'
356+
sidebarCollapsed ? 'px-2 [&::-webkit-scrollbar]:hidden' : 'px-3 [scrollbar-gutter:stable]'
357357
"
358358
@contextmenu.capture="onMenuContextMenu"
359359
>
360360
<SMenu
361361
:items="menuItems"
362362
:model-value="activeKey"
363-
:collapsed="appearance.sidebarCollapsed"
363+
:collapsed="sidebarCollapsed"
364364
@select="onSelect"
365365
/>
366366
</div>

‎src/components/list/CoverCard.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const actualFallback = computed(() => (props.type === "artist" ? artistFallback
6969
:class="type === 'artist' ? 'items-center' : ''"
7070
>
7171
<div
72-
class="text-sm text-on-surface line-clamp-2 leading-snug text-pretty"
72+
class="text-sm text-on-surface line-clamp-2 leading-snug text-pretty min-h-[2.75em]"
7373
:class="type === 'artist' ? 'text-center w-full' : ''"
7474
>
7575
{{ item.title }}

‎src/components/onboarding/StepLibrary.vue‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ defineEmits<{ (e: "next"): void; (e: "back"): void }>();
77
</script>
88

99
<template>
10-
<div class="flex flex-col max-w-2xl w-full mx-auto">
11-
<div class="flex items-center gap-3 mb-2">
10+
<div class="flex flex-col flex-1 min-h-0 max-w-2xl w-full mx-auto">
11+
<div class="flex items-center gap-3 mb-2 shrink-0">
1212
<IconFolder class="size-6 text-primary" />
1313
<h2 class="text-2xl font-bold">{{ t("onboarding.library.title") }}</h2>
1414
</div>
15-
<p class="text-on-surface-variant/70 mb-6 leading-relaxed">
15+
<p class="text-on-surface-variant/70 mb-6 leading-relaxed shrink-0">
1616
{{ t("onboarding.library.subtitle") }}
1717
</p>
1818

19-
<div class="bg-on-surface/4 border border-solid border-primary/10 rounded-xl p-4 mb-6">
19+
<div
20+
class="flex-1 min-h-0 overflow-y-auto bg-on-surface/4 border border-solid border-primary/10 rounded-xl p-4 mb-6"
21+
>
2022
<FolderManager />
2123
</div>
2224

23-
<div class="flex items-center gap-3">
25+
<div class="flex items-center gap-3 shrink-0">
2426
<SButton variant="ghost" round @click="$emit('back')">
2527
<template #icon><IconChevronLeft /></template>
2628
{{ t("onboarding.back") }}

‎src/components/player/PlayerBar.vue‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { usePlaylistPicker } from "@/composables/usePlaylistPicker";
77
import { useTrackMenu } from "@/composables/useTrackMenu";
88
import { useDownload } from "@/composables/useDownload";
99
import { useProgressLyric } from "@/composables/useProgressLyric";
10+
import { useResponsiveLayout } from "@/composables/useResponsiveLayout";
1011
import * as player from "@/core/player";
1112
1213
const status = useStatusStore();
@@ -16,8 +17,11 @@ const fav = useFavorite();
1617
const { position, duration } = storeToRefs(status);
1718
const { formatTooltip, snapToNearestLyric } = useProgressLyric();
1819
19-
/** 是否是浮动模式 */
20-
const isFloating = computed(() => settings.appearance.layoutMode === "floating");
20+
const { isCompact } = useResponsiveLayout();
21+
/** 浮动模式或窄窗口统一使用紧凑布局 */
22+
const useCompactLayout = computed(
23+
() => settings.appearance.layoutMode === "floating" || isCompact.value,
24+
);
2125
/** 是否显示进度条提示 */
2226
const showTooltip = computed(() => settings.player.showProgressTooltip);
2327
@@ -44,8 +48,8 @@ const { items: menuItems, handleSelect: onMenuSelect } = useTrackMenu(toRef(medi
4448
</script>
4549

4650
<template>
47-
<!-- 浮动模式 -->
48-
<div v-if="isFloating" class="relative flex items-center px-4 gap-4 min-w-0">
51+
<!-- 浮动模式与窄窗口紧凑布局 -->
52+
<div v-if="useCompactLayout" class="relative flex items-center h-full px-4 gap-4 min-w-0">
4953
<PlayerControls compact />
5054
<div class="flex flex-col flex-1 min-w-0 gap-1 pt-2 pb-1">
5155
<div class="flex items-center gap-2 min-w-0">
@@ -93,7 +97,9 @@ const { items: menuItems, handleSelect: onMenuSelect } = useTrackMenu(toRef(medi
9397
</div>
9498
</template>
9599
</TrackInfo>
96-
<PlayerTimeInfo compact />
100+
<div class="contents lt-md:hidden">
101+
<PlayerTimeInfo compact />
102+
</div>
97103
</div>
98104
<SSlider
99105
:model-value="position"

‎src/components/player/Toolbar.vue‎

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -82,42 +82,46 @@ const onMoreMenuSelect = (key: string): void => {
8282
<template>
8383
<div class="flex items-center gap-1">
8484
<!-- 在线音质 -->
85-
<QualityControl v-if="settings.appearance.showQualitySwitch" :cover="cover" />
86-
<SPopover trigger="hover" side="top" :cover="cover" content-class="px-3 pb-2 pt-3">
87-
<template #trigger>
88-
<SButton
89-
:type="buttonType"
90-
variant="ghost"
91-
circle
92-
size="large"
93-
:class="mutedClass"
94-
@click="toggleMute"
95-
@wheel.prevent="onVolumeWheel"
96-
>
97-
<template #icon>
98-
<IconLucideVolumeX v-if="volumePercent === 0" />
99-
<IconLucideVolume1 v-else-if="volumePercent < 50" />
100-
<IconLucideVolume2 v-else />
101-
</template>
102-
</SButton>
103-
</template>
104-
<div class="flex flex-col items-center w-7" @wheel.prevent="onVolumeWheel">
105-
<div class="h-30">
106-
<SSlider
107-
:model-value="volumePosition"
108-
:min="0"
109-
:max="1"
110-
:step="0.01"
111-
:thumb-size="15"
112-
:track-height="5"
113-
:cover="cover"
114-
vertical
115-
@change="player.setVolume(volumePositionToGain($event))"
116-
/>
85+
<div v-if="settings.appearance.showQualitySwitch" class="contents lt-md:hidden">
86+
<QualityControl :cover="cover" />
87+
</div>
88+
<div class="contents lt-xs:hidden">
89+
<SPopover trigger="hover" side="top" :cover="cover" content-class="px-3 pb-2 pt-3">
90+
<template #trigger>
91+
<SButton
92+
:type="buttonType"
93+
variant="ghost"
94+
circle
95+
size="large"
96+
:class="mutedClass"
97+
@click="toggleMute"
98+
@wheel.prevent="onVolumeWheel"
99+
>
100+
<template #icon>
101+
<IconLucideVolumeX v-if="volumePercent === 0" />
102+
<IconLucideVolume1 v-else-if="volumePercent < 50" />
103+
<IconLucideVolume2 v-else />
104+
</template>
105+
</SButton>
106+
</template>
107+
<div class="flex flex-col items-center w-7" @wheel.prevent="onVolumeWheel">
108+
<div class="h-30">
109+
<SSlider
110+
:model-value="volumePosition"
111+
:min="0"
112+
:max="1"
113+
:step="0.01"
114+
:thumb-size="15"
115+
:track-height="5"
116+
:cover="cover"
117+
vertical
118+
@change="player.setVolume(volumePositionToGain($event))"
119+
/>
120+
</div>
121+
<span class="text-xs tabular-nums mt-2">{{ volumePercent }}%</span>
117122
</div>
118-
<span class="text-xs tabular-nums mt-2">{{ volumePercent }}%</span>
119-
</div>
120-
</SPopover>
123+
</SPopover>
124+
</div>
121125
<SButton
122126
:type="lyricButtonType"
123127
:variant="isDesktopLyricOpen ? 'tertiary' : 'ghost'"
@@ -154,27 +158,28 @@ const onMoreMenuSelect = (key: string): void => {
154158
<template #icon><IconLucideListMusic /></template>
155159
</SButton>
156160
<!-- 常规播放列表气泡 -->
157-
<SPopover
158-
v-else
159-
v-model:open="status.outerQueueOpen"
160-
trigger="click"
161-
side="top"
162-
:side-offset="12"
163-
content-class="!p-0 w-72 h-[min(60vh,520px)] overflow-hidden"
164-
>
165-
<template #trigger>
166-
<SButton
167-
:type="status.outerQueueOpen ? 'primary' : buttonType"
168-
:variant="status.outerQueueOpen ? 'tertiary' : 'ghost'"
169-
circle
170-
size="large"
171-
:class="status.outerQueueOpen ? undefined : mutedClass"
172-
>
173-
<template #icon><IconLucideListMusic /></template>
174-
</SButton>
175-
</template>
176-
<QueuePopover @close="status.outerQueueOpen = false" />
177-
</SPopover>
161+
<div v-else class="contents lt-xs:hidden">
162+
<SPopover
163+
v-model:open="status.outerQueueOpen"
164+
trigger="click"
165+
side="top"
166+
:side-offset="12"
167+
content-class="!p-0 w-72 h-[min(60vh,520px)] overflow-hidden"
168+
>
169+
<template #trigger>
170+
<SButton
171+
:type="status.outerQueueOpen ? 'primary' : buttonType"
172+
:variant="status.outerQueueOpen ? 'tertiary' : 'ghost'"
173+
circle
174+
size="large"
175+
:class="status.outerQueueOpen ? undefined : mutedClass"
176+
>
177+
<template #icon><IconLucideListMusic /></template>
178+
</SButton>
179+
</template>
180+
<QueuePopover @close="status.outerQueueOpen = false" />
181+
</SPopover>
182+
</div>
178183
<SDropdownMenu
179184
:items="moreMenuItems"
180185
side="top"

0 commit comments

Comments
 (0)