Skip to content

Commit

Permalink
✨ feat: 搜索栏跳转完善 #262
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Sep 29, 2024
1 parent 528f9b0 commit 2b48713
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/Search/SearchInp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@

<script setup lang="ts">
import { useStatusStore, useDataStore } from "@/stores";
import SearchInpMenu from "@/components/Menu/SearchInpMenu.vue";
import { searchDefault } from "@/api/search";
import SearchInpMenu from "@/components/Menu/SearchInpMenu.vue";
import player from "@/utils/player";
import { songDetail } from "@/api/song";
import { formatSongsList } from "@/utils/format";
const router = useRouter();
const dataStore = useDataStore();
Expand Down Expand Up @@ -90,7 +93,7 @@ const updatePlaceholder = async () => {
};
// 前往搜索
const toSearch = (key: any, type: string = "keyword") => {
const toSearch = async (key: any, type: string = "keyword") => {
// 未输入内容且不存在推荐
if (!key && searchPlaceholder.value === "搜索音乐 / 视频") return;
if (!key && searchPlaceholder.value !== "搜索音乐 / 视频" && searchRealkeyword.value) {
Expand All @@ -110,15 +113,23 @@ const toSearch = (key: any, type: string = "keyword") => {
});
setSearchHistory(key);
break;
case "songs":
case "songs": {
const result = await songDetail(key?.id);
const song = formatSongsList(result.songs)[0];
player.addNextSong(song, true);
break;
}
case "playlists":
router.push({
name: "playlist",
query: { id: key?.id },
});
break;
case "artists":
router.push({
name: "artist",
query: { id: key?.id },
});
break;
case "albums":
router.push({
Expand Down

0 comments on commit 2b48713

Please sign in to comment.