mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-18 19:47:29 +08:00
refactor(playHistory): v1 旧 localStorage key 清理与调用方对齐
老用户升级后清掉 v1 时代独立 key 释放配额,调用方切到 store API。
- player.ts initializePlayState 调用从 migrateFromLocalStorage 切到
cleanupLegacyPlayHistoryStorage:不再做数据迁移(历史是低关键性
衍生数据,老用户重新听几次即可),仅清掉旧 musicHistory/podcastHistory/
playlistHistory/albumHistory/podcastRadioHistory/playHistory-migrated/
playMode 这 7 个旧 key,避免和新 play-history-store key 双倍占用
- SystemTab.vue 清缓存的 case 'history' 改走 usePlayHistoryStore().
clearMusicHistory(),与 v1 时代行为对齐(只清音乐历史,不动 podcast/
playlist/album/podcastRadio);移除 case 'settings' 里的
removeItem('playMode')——已并入 player-core-store
This commit is contained in:
@@ -13,7 +13,7 @@ import { computed } from 'vue';
|
||||
import { useFavoriteStore } from './favorite';
|
||||
import { useIntelligenceModeStore } from './intelligenceMode';
|
||||
import { usePlayerCoreStore } from './playerCore';
|
||||
import { usePlayHistoryStore } from './playHistory';
|
||||
import { cleanupLegacyPlayHistoryStorage } from './playHistory';
|
||||
import { usePlaylistStore } from './playlist';
|
||||
import { type SleepTimerInfo, SleepTimerType, useSleepTimerStore } from './sleepTimer';
|
||||
|
||||
@@ -72,9 +72,8 @@ export const usePlayerStore = defineStore('player', () => {
|
||||
* 初始化播放状态(从 localStorage 恢复)
|
||||
*/
|
||||
const initializePlayState = async () => {
|
||||
// 从旧的 localStorage 迁移播放记录到 Pinia store
|
||||
const playHistoryStore = usePlayHistoryStore();
|
||||
playHistoryStore.migrateFromLocalStorage();
|
||||
// 一次性清理 v1 时代的旧 localStorage key,不做数据迁移(详见 playHistory.ts 注释)
|
||||
cleanupLegacyPlayHistoryStorage();
|
||||
|
||||
const { initializePlayState: initPlayState } = await import('@/services/playbackController');
|
||||
await initPlayState();
|
||||
|
||||
@@ -124,6 +124,7 @@ import { useI18n } from 'vue-i18n';
|
||||
|
||||
import localData from '@/../main/set.json';
|
||||
import ClearCacheSettings from '@/components/settings/ClearCacheSettings.vue';
|
||||
import { usePlayHistoryStore } from '@/store/modules/playHistory';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { isElectron } from '@/utils';
|
||||
import { openDirectory, selectDirectory } from '@/utils/fileOperation';
|
||||
@@ -435,7 +436,10 @@ const clearCache = async (selectedCacheTypes: string[]) => {
|
||||
const clearTasks = selectedCacheTypes.map(async (type) => {
|
||||
switch (type) {
|
||||
case 'history':
|
||||
localStorage.removeItem('musicHistory');
|
||||
// 与旧版本行为对齐:只清音乐历史,不动 podcast/playlist/album/podcastRadio。
|
||||
// 数据已迁到 pinia store(key=play-history-store),老 musicHistory key 由
|
||||
// cleanupLegacyPlayHistoryStorage 在启动时清掉,这里不再需要 removeItem
|
||||
usePlayHistoryStore().clearMusicHistory();
|
||||
break;
|
||||
case 'favorite':
|
||||
localStorage.removeItem('favoriteList');
|
||||
@@ -451,7 +455,6 @@ const clearCache = async (selectedCacheTypes: string[]) => {
|
||||
localStorage.removeItem('theme');
|
||||
localStorage.removeItem('lyricData');
|
||||
localStorage.removeItem('lyricFontSize');
|
||||
localStorage.removeItem('playMode');
|
||||
break;
|
||||
case 'downloads':
|
||||
if (window.electron) {
|
||||
|
||||
Reference in New Issue
Block a user