mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-05 07:20:50 +08:00
异步组件 优化首屏加载速度
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { IPlayMusicUrl } from "@/type/music";
|
||||
import { ILyric } from "@/type/lyric";
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 根据音乐Id获取音乐播放URl
|
||||
export const getMusicUrl = (id: number) => {
|
||||
return request.get<IPlayMusicUrl>("/song/url", { params: { id: id } });
|
||||
|
||||
@@ -30,7 +30,13 @@
|
||||
import type { SongResult } from '@/type/music';
|
||||
import { computed } from 'vue';
|
||||
import { useStore } from 'vuex';
|
||||
import { AppMenu, PlayBar, SearchBar } from './components';
|
||||
// import { AppMenu, PlayBar, SearchBar } from './components';
|
||||
import {defineAsyncComponent} from 'vue';
|
||||
const AppMenu = defineAsyncComponent(() => import('./components/AppMenu.vue'));
|
||||
const PlayBar = defineAsyncComponent(() => import('./components/PlayBar.vue'));
|
||||
const SearchBar = defineAsyncComponent(() => import('./components/SearchBar.vue'));
|
||||
|
||||
|
||||
|
||||
const store = useStore();
|
||||
|
||||
|
||||
@@ -14,10 +14,15 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import RecommendSinger from "@/components/RecommendSinger.vue";
|
||||
import PlaylistType from "@/components/PlaylistType.vue";
|
||||
import RecommendSonglist from "@/components/RecommendSonglist.vue";
|
||||
import RecommendAlbum from "@/components/RecommendAlbum.vue";
|
||||
import {defineAsyncComponent} from 'vue';
|
||||
// import RecommendSinger from "@/components/RecommendSinger.vue";
|
||||
// import PlaylistType from "@/components/PlaylistType.vue";
|
||||
// import RecommendSonglist from "@/components/RecommendSonglist.vue";
|
||||
// import RecommendAlbum from "@/components/RecommendAlbum.vue";
|
||||
const RecommendSinger = defineAsyncComponent(() => import("@/components/RecommendSinger.vue"));
|
||||
const PlaylistType = defineAsyncComponent(() => import("@/components/PlaylistType.vue"));
|
||||
const RecommendSonglist = defineAsyncComponent(() => import("@/components/RecommendSonglist.vue"));
|
||||
const RecommendAlbum = defineAsyncComponent(() => import("@/components/RecommendAlbum.vue"));
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user