This commit is contained in:
geoffrey45
2022-01-11 03:36:42 +03:00
parent 521c195570
commit e473b5db92
8 changed files with 43 additions and 33 deletions
+3 -2
View File
@@ -314,8 +314,9 @@ def getFolderTree(folder: str = None):
song['artists'] = song['artists'].split(', ') or None song['artists'] = song['artists'].split(', ') or None
except: except:
pass pass
if song['image'] is not None:
song['image'] = img_path + song['image'] print(song['image'])
song['image'] = img_path + song['image']
return {"files": remove_duplicates(songs), "folders": sorted(folders, key=lambda i: i['name'])} return {"files": remove_duplicates(songs), "folders": sorted(folders, key=lambda i: i['name'])}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 41 KiB

+5 -12
View File
@@ -82,23 +82,16 @@ export default {
const current = ref(perks.current); const current = ref(perks.current);
const search_query = ref(state.search_query); const search_query = ref(state.search_query);
const updateQueue = async (song) => { function updateQueue(song){
if (state.queue.value[0]._id.$oid !== song_list.value[0]._id.$oid) { perks.updateQueue(song)
const new_queue = song_list.value; }
localStorage.setItem("queue", JSON.stringify(new_queue));
state.queue.value = new_queue;
}
state.current.value = song;
localStorage.setItem("current", JSON.stringify(song));
};
const searchSongs = computed(() => { const searchSongs = computed(() => {
const songs = []; const songs = [];
if (search_query.value.length > 2) { if (search_query.value.length > 2) {
state.loading.value = true; state.loading.value = true;
for (let i = 0; i < song_list.value.length; i++) { for (let i = 0; i < song_list.value.length; i++) {
if ( if (
song_list.value[i].title song_list.value[i].title
@@ -162,7 +155,7 @@ export default {
width: 3rem; width: 3rem;
height: 3rem; height: 3rem;
margin-right: 1rem; margin-right: 1rem;
background-image: url(../../assets/icons/file.svg); background-image: url(../../assets/images/null.webp);
display: grid; display: grid;
place-items: center; place-items: center;
} }
+1 -3
View File
@@ -3,7 +3,7 @@
<td <td
:style="{ width: songTitleWidth + 'px' }" :style="{ width: songTitleWidth + 'px' }"
class="flex" class="flex"
@click="emitUpdate(song), playAudio(song.filepath)" @click="emitUpdate(song)"
> >
<div <div
class="album-art rounded image" class="album-art rounded image"
@@ -56,7 +56,6 @@
<script> <script>
import perks from "@/composables/perks.js"; import perks from "@/composables/perks.js";
import state from "@/composables/state.js"; import state from "@/composables/state.js";
import audio from "@/composables/playAudio.js"
export default { export default {
props: ["song", "current", "songTitleWidth", "minWidth"], props: ["song", "current", "songTitleWidth", "minWidth"],
@@ -69,7 +68,6 @@ export default {
putCommas: perks.putCommas, putCommas: perks.putCommas,
emitUpdate, emitUpdate,
is_playing: state.is_playing, is_playing: state.is_playing,
playAudio: audio.playAudio
}; };
}, },
}; };
+22 -9
View File
@@ -80,6 +80,19 @@ const readQueue = () => {
} }
}; };
const updateQueue = async (song) => {
playAudio.playAudio(song.filepath)
if (state.queue.value[0]._id.$oid !== state.song_list.value[0]._id.$oid) {
const new_queue = state.song_list.value;
localStorage.setItem("queue", JSON.stringify(new_queue));
state.queue.value = new_queue;
}
state.current.value = song;
localStorage.setItem("current", JSON.stringify(song));
};
function focusCurrent() { function focusCurrent() {
const elem = document.getElementsByClassName("currentInQueue")[0]; const elem = document.getElementsByClassName("currentInQueue")[0];
@@ -92,21 +105,21 @@ function focusCurrent() {
} }
} }
function getElem(identifier, type){ function getElem(identifier, type) {
switch(type){ switch (type) {
case "class": { case "class": {
return document.getElementsByClassName(identifier)[0] return document.getElementsByClassName(identifier)[0];
} }
case "id": { case "id": {
return document.getElementById(identifier) return document.getElementById(identifier);
} }
} }
} }
function focusSearchBox() { function focusSearchBox() {
const elem = getElem('search', 'id') const elem = getElem("search", "id");
elem.focus() elem.focus();
} }
setTimeout(() => { setTimeout(() => {
@@ -135,7 +148,7 @@ window.addEventListener("keydown", (e) => {
setTimeout(() => { setTimeout(() => {
key_down_fired = false; key_down_fired = false;
}, 1000); }, 1000);
playAudio.playNext(); playAudio.playNext();
} }
} }
@@ -151,7 +164,6 @@ window.addEventListener("keydown", (e) => {
setTimeout(() => { setTimeout(() => {
key_down_fired = false; key_down_fired = false;
}, 1000); }, 1000);
} }
} }
@@ -174,7 +186,7 @@ window.addEventListener("keydown", (e) => {
if (!key_down_fired) { if (!key_down_fired) {
if (!ctrlKey) return; if (!ctrlKey) return;
e.preventDefault(); e.preventDefault();
focusSearchBox() focusSearchBox();
key_down_fired = true; key_down_fired = true;
} }
@@ -190,6 +202,7 @@ export default {
putCommas, putCommas,
readQueue, readQueue,
focusCurrent, focusCurrent,
updateQueue,
current, current,
queue, queue,
next, next,
+5
View File
@@ -12,6 +12,9 @@ const queue = ref([
}, },
]); ]);
const song_list = ref([])
const folder_list = ref([])
const current = ref({ const current = ref({
title: "Nothing played yet", title: "Nothing played yet",
artists: ["... blah blah blah"], artists: ["... blah blah blah"],
@@ -41,6 +44,8 @@ const search_artists = ref([]);
export default { export default {
search_query, search_query,
queue, queue,
song_list,
folder_list,
current, current,
prev, prev,
filters, filters,
+7 -7
View File
@@ -1,7 +1,7 @@
<template> <template>
<div id="f-view-parent" class="rounded"> <div id="f-view-parent" class="rounded">
<div class="fixed"> <div class="fixed">
<SearchBox :path="path" /> <Header :path="path" />
</div> </div>
<div id="scrollable" ref="scrollable"> <div id="scrollable" ref="scrollable">
<FolderList :folders="folders" /> <FolderList :folders="folders" />
@@ -17,7 +17,7 @@ import { useRoute } from "vue-router";
import SongList from "@/components/FolderView/SongList.vue"; import SongList from "@/components/FolderView/SongList.vue";
import FolderList from "@/components/FolderView/FolderList.vue"; import FolderList from "@/components/FolderView/FolderList.vue";
import SearchBox from "@/components/FolderView/SearchBox.vue"; import Header from "@/components/FolderView/Header.vue";
import getData from "../composables/getFiles.js"; import getData from "../composables/getFiles.js";
import { onMounted, watch } from "@vue/runtime-core"; import { onMounted, watch } from "@vue/runtime-core";
@@ -27,14 +27,14 @@ export default {
components: { components: {
SongList, SongList,
FolderList, FolderList,
SearchBox, Header,
}, },
setup() { setup() {
const route = useRoute(); const route = useRoute();
const path = ref(route.params.path); const path = ref(route.params.path);
const songs = ref([]); const songs = ref(state.song_list);
const folders = ref([]); const folders = ref(state.folder_list);
const scrollable = ref(null); const scrollable = ref(null);
@@ -48,8 +48,8 @@ export default {
getData(path, last_id).then((data) => { getData(path, last_id).then((data) => {
scrollable.value.scrollTop = 0; scrollable.value.scrollTop = 0;
songs.value = data.songs; state.song_list.value = data.songs;
folders.value = data.folders; state.folder_list.value = data.folders;
state.loading.value = false; state.loading.value = false;
}); });