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