🦄 refactor: 重构代码将 Vuex替换为 Pinia

集成 Pinia 状态管理
This commit is contained in:
alger
2025-03-19 22:48:28 +08:00
parent 4fa5ed0ca6
commit e355341596
40 changed files with 1170 additions and 494 deletions
+5 -5
View File
@@ -88,18 +88,18 @@ import { useMessage } from 'naive-ui';
import { computed, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { useStore } from 'vuex';
import { getMusicDetail } from '@/api/music';
import SongItem from '@/components/common/SongItem.vue';
import { getSongUrl } from '@/hooks/MusicListHook';
import { usePlayerStore } from '@/store';
import type { SongResult } from '@/type/music';
import { isElectron, setAnimationClass, setAnimationDelay } from '@/utils';
const { t } = useI18n();
const store = useStore();
const playerStore = usePlayerStore();
const message = useMessage();
const favoriteList = computed(() => store.state.favoriteList);
const favoriteList = computed(() => playerStore.favoriteList);
const favoriteSongs = ref<SongResult[]>([]);
const loading = ref(false);
const noMore = ref(false);
@@ -277,7 +277,7 @@ const handleScroll = (e: any) => {
};
onMounted(async () => {
await store.dispatch('initializeFavoriteList');
await playerStore.initializeFavoriteList();
await getFavoriteSongs();
});
@@ -293,7 +293,7 @@ watch(
);
const handlePlay = () => {
store.commit('setPlayList', favoriteSongs.value);
playerStore.setPlayList(favoriteSongs.value);
};
const getItemAnimationDelay = (index: number) => {