mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-10 04:57:45 +00:00
client: use for loop instead of array.filter()
This commit is contained in:
parent
9310382436
commit
1cbf770fee
@ -14,7 +14,7 @@
|
|||||||
<tr
|
<tr
|
||||||
v-for="song in searchSongs"
|
v-for="song in searchSongs"
|
||||||
:key="song"
|
:key="song"
|
||||||
:class="{ current: current._id.$oid == song._id.$oid }"
|
:class="{ current: current._id == song._id }"
|
||||||
>
|
>
|
||||||
<td
|
<td
|
||||||
:style="{ width: songTitleWidth + 'px' }"
|
:style="{ width: songTitleWidth + 'px' }"
|
||||||
@ -29,7 +29,7 @@
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="now-playing-track image"
|
class="now-playing-track image"
|
||||||
v-if="current._id.$oid == song._id.$oid"
|
v-if="current._id == song._id"
|
||||||
:class="{ active: is_playing, not_active: !is_playing }"
|
:class="{ active: is_playing, not_active: !is_playing }"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
@ -138,11 +138,26 @@ export default {
|
|||||||
const search_query = ref(state.search_query);
|
const search_query = ref(state.search_query);
|
||||||
|
|
||||||
const searchSongs = computed(() => {
|
const searchSongs = computed(() => {
|
||||||
return song_list.value.filter((song) => {
|
const songs = [];
|
||||||
return song.title
|
|
||||||
.toLowerCase()
|
if (search_query.value.length > 2) {
|
||||||
.includes(state.search_query.value.toLowerCase());
|
state.loading.value = true;
|
||||||
});
|
for (let i = 0; i < song_list.value.length; i++) {
|
||||||
|
if (
|
||||||
|
song_list.value[i].title
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(search_query.value.toLowerCase())
|
||||||
|
) {
|
||||||
|
songs.push(song_list.value[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state.loading.value = false;
|
||||||
|
|
||||||
|
return songs;
|
||||||
|
} else {
|
||||||
|
return song_list.value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user