@@ -242,10 +242,55 @@ const menuOptions = computed<MenuOption[] | MenuGroupOption[]>(() => {
242242 {
243243 key: " local" ,
244244 link: " local" ,
245- label: " 本地歌曲 " ,
245+ label: " 音乐库 " ,
246246 show: isElectron ,
247247 icon: renderIcon (" FolderMusic" ),
248248 },
249+ {
250+ key: " local-albums" ,
251+ link: " local-albums" ,
252+ label: " 专辑" ,
253+ show:
254+ isElectron &&
255+ (localStore .localSongs ?.length > 0 || settingStore .localFilesPath ?.length > 0 ),
256+ icon: renderIcon (" Album" ),
257+ },
258+ {
259+ key: " local-artists" ,
260+ link: " local-artists" ,
261+ label: " 艺术家" ,
262+ show:
263+ isElectron &&
264+ (localStore .localSongs ?.length > 0 || settingStore .localFilesPath ?.length > 0 ),
265+ icon: renderIcon (" Person" ),
266+ },
267+ {
268+ key: " divider" ,
269+ type: " divider" ,
270+ show: localPlaylistMenu .value .length > 0 ,
271+ },
272+ // 本地歌单
273+ {
274+ key: " local-playlists" ,
275+ show: localPlaylistMenu .value .length > 0 ,
276+ icon: statusStore .menuCollapsed ? renderIcon (" PlaylistAdd" ) : undefined ,
277+ label : () =>
278+ h (" div" , { class: " user-list" }, [
279+ h (NText , { depth: 3 }, () => " 本地歌单" ),
280+ h (NButton , {
281+ type: " tertiary" ,
282+ round: true ,
283+ strong: true ,
284+ secondary: true ,
285+ renderIcon: renderIcon (" Add" ),
286+ onclick : (event : Event ) => {
287+ event .stopPropagation ();
288+ openCreatePlaylist (true );
289+ },
290+ }),
291+ ]),
292+ children: [... localPlaylistMenu .value ],
293+ },
249294 ];
250295});
251296
@@ -341,12 +386,15 @@ const menuUpdate = (key: string, item: MenuOption) => {
341386 query: { id: item .key },
342387 });
343388 } else if (typeof key === " string" && key .startsWith (" local-" )) {
344- // 本地歌单
389+ // 检查是否为本地歌单(16位数字ID)
345390 const localId = key .replace (" local-" , " " );
346- router .push ({
347- name: " playlist" ,
348- query: { id: localId },
349- });
391+ const isLocalPlaylist = / ^ \d {16} $ / .test (localId );
392+ if (isLocalPlaylist ) {
393+ router .push ({
394+ name: " playlist" ,
395+ query: { id: localId },
396+ });
397+ }
350398 } else {
351399 switch (key ) {
352400 case " like-songs" :
@@ -377,18 +425,26 @@ const checkMenuItem = () => {
377425 // 处理路由名称
378426 const prefixMap = [
379427 { prefix: " discover-" , name: " discover" },
380- { prefix: " local-" , name: " local" },
428+ // 本地模式下不合并 local- 前缀的路由
429+ { prefix: " local-" , name: " local" , skipInLocalMode: true },
381430 { prefix: " like-" , name: " like" , exclude: " like-songs" },
382431 { prefix: " download-" , name: " download" },
383432 ];
384433 for (const item of prefixMap ) {
434+ if (item .skipInLocalMode && ! settingStore .useOnlineService ) continue ;
385435 if (routerName .startsWith (item .prefix ) && (! item .exclude || routerName !== item .exclude )) {
386436 routerName = item .name ;
387437 break ;
388438 }
389439 }
390440 // 显示菜单
391441 menuRef .value ?.showOption (routerName );
442+ // 本地模式下处理
443+ if (! settingStore .useOnlineService ) {
444+ if (routerName === " local-songs" || routerName === " local-folders" ) {
445+ routerName = " local" ;
446+ }
447+ }
392448 // 高亮菜单
393449 switch (routerName ) {
394450 case " playlist" : {
@@ -424,6 +480,15 @@ const openHeartMode = debounce(() => player.toggleShuffle("heartbeat"), 1000, {
424480 trailing: false ,
425481});
426482
483+ // 本地模式下自动展开本地歌单
484+ onMounted (() => {
485+ if (! settingStore .useOnlineService && localPlaylistMenu .value .length > 0 ) {
486+ if (! settingStore .menuExpandedKeys .includes (" local-playlists" )) {
487+ settingStore .menuExpandedKeys .push (" local-playlists" );
488+ }
489+ }
490+ });
491+
427492// 监听路由
428493watch (
429494 () => [router .currentRoute .value , dataStore .userLikeData .playlists ],
0 commit comments