mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-09 04:35:36 +00:00
debounce global search
This commit is contained in:
parent
7f73d89fcc
commit
f6787421c3
@ -33,7 +33,12 @@ def search_by_title():
|
|||||||
albums = []
|
albums = []
|
||||||
artists = []
|
artists = []
|
||||||
|
|
||||||
s = instances.songs_instance.find_song_by_title(query)
|
s = []
|
||||||
|
|
||||||
|
for track in all_the_f_music:
|
||||||
|
if query.lower() in track['title'].lower():
|
||||||
|
s.append(track)
|
||||||
|
|
||||||
al = instances.songs_instance.search_songs_by_album(query)
|
al = instances.songs_instance.search_songs_by_album(query)
|
||||||
ar = instances.songs_instance.search_songs_by_artist(query)
|
ar = instances.songs_instance.search_songs_by_artist(query)
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(query, () => {
|
watch(query, () => {
|
||||||
|
console.log(query.value);
|
||||||
emit("search", query.value);
|
emit("search", query.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder .table table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -143,6 +143,8 @@ export default {
|
|||||||
@include tablet-landscape {
|
@include tablet-landscape {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width: 5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
th.album-header {
|
th.album-header {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="right-search border" ref="searchComponent">
|
<div class="right-search border" ref="searchComponent">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<div class="search-icon image"></div>
|
<div class="search-icon image"></div>
|
||||||
<div class="filter">
|
<div class="filter">
|
||||||
@ -48,14 +48,12 @@
|
|||||||
<div class="tracks-results">
|
<div class="tracks-results">
|
||||||
<div class="heading">TRACKS<span class="more">SEE ALL</span></div>
|
<div class="heading">TRACKS<span class="more">SEE ALL</span></div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
<div class="result-item" v-for="song in songs" :key="song">
|
<table>
|
||||||
<div class="album-art image"></div>
|
<thead></thead>
|
||||||
<div class="tags">
|
<tbody>
|
||||||
<span class="title">{{ song.title }}</span>
|
<SongItem v-for="song in songs" :key="song" :song="song" />
|
||||||
<hr />
|
</tbody>
|
||||||
<span class="artist">{{ song.artist }}</span>
|
</table>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@ -89,11 +87,15 @@ import { ref, toRefs } from "@vue/reactivity";
|
|||||||
import { onMounted, watch } from "@vue/runtime-core";
|
import { onMounted, watch } from "@vue/runtime-core";
|
||||||
import state from "@/composables/state.js";
|
import state from "@/composables/state.js";
|
||||||
import searchMusic from "../composables/searchMusic.js";
|
import searchMusic from "../composables/searchMusic.js";
|
||||||
// import useDebounce from "../composed/useDebounce.js";
|
import useDebouncedRef from "@/composables/useDebouncedRef";
|
||||||
|
import SongItem from "@/components/SongItem.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
emits: ["expandSearch", "collapseSearch"],
|
emits: ["expandSearch", "collapseSearch"],
|
||||||
props: ["search"],
|
props: ["search"],
|
||||||
|
components: {
|
||||||
|
SongItem,
|
||||||
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const options = [
|
const options = [
|
||||||
{
|
{
|
||||||
@ -121,7 +123,7 @@ export default {
|
|||||||
icon: "🈁",
|
icon: "🈁",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const loading = ref(state.loading);
|
const loading = ref(state.loading);
|
||||||
const searchComponent = ref(null);
|
const searchComponent = ref(null);
|
||||||
const filters = ref(state.filters);
|
const filters = ref(state.filters);
|
||||||
@ -132,7 +134,7 @@ export default {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const artists = ["Michael Jackson waihenya", "Jackson 5"];
|
const artists = ["Michael Jackson waihenya", "Jackson 5"];
|
||||||
const query = ref(state.search_query);
|
const query = useDebouncedRef("", 400);
|
||||||
const magic_flag = ref(state.magic_flag);
|
const magic_flag = ref(state.magic_flag);
|
||||||
const is_hidden = toRefs(props).search;
|
const is_hidden = toRefs(props).search;
|
||||||
|
|
||||||
@ -176,8 +178,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(query, (new_query) => {
|
watch(query, (new_query) => {
|
||||||
// search music
|
searchMusic(new_query);
|
||||||
// searchMusic(new_query);
|
|
||||||
|
|
||||||
state.search_query.value = new_query;
|
state.search_query.value = new_query;
|
||||||
if (new_query !== "") {
|
if (new_query !== "") {
|
||||||
@ -202,7 +203,6 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addFilter,
|
addFilter,
|
||||||
activateMagicFlag,
|
activateMagicFlag,
|
||||||
@ -403,9 +403,10 @@ export default {
|
|||||||
|
|
||||||
.right-search .tracks-results {
|
.right-search .tracks-results {
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
background: #ca0377;
|
// background: #ca0377;
|
||||||
margin-left: $small;
|
margin-left: $small;
|
||||||
padding: $small;
|
padding: $small;
|
||||||
|
// border: solid;
|
||||||
|
|
||||||
.items {
|
.items {
|
||||||
border-radius: $small;
|
border-radius: $small;
|
||||||
|
@ -87,6 +87,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.song-duration {
|
||||||
|
width: 5rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
|
@ -10,7 +10,8 @@ async function search(query) {
|
|||||||
state.search_tracks.value = json.songs;
|
state.search_tracks.value = json.songs;
|
||||||
state.search_albums.value = json.albums;
|
state.search_albums.value = json.albums;
|
||||||
state.search_artists.value = json.artists;
|
state.search_artists.value = json.artists;
|
||||||
console.log(state.search);
|
|
||||||
|
console.log(state.search_tracks.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default search;
|
export default search;
|
Loading…
x
Reference in New Issue
Block a user