mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
client:fetch songs and folders in folder view
This commit is contained in:
@@ -22,7 +22,9 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: ["folders"],
|
props: ["folders"],
|
||||||
setup() {},
|
setup() {
|
||||||
|
console.log('props.folders')
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="folder">
|
<div class="folder">
|
||||||
<div class="table rounded" ref="songtitle">
|
<div class="table rounded" ref="songtitle" v-if="songs.length">
|
||||||
<table class="rounded">
|
<table class="rounded">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Track</th>
|
<th>Track</th>
|
||||||
@@ -10,7 +10,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr v-for="song in songs" :key="song">
|
<tr v-for="song in songs" :key="song">
|
||||||
<td :style="{ width: songTitleWidth + 'px' }" class="flex">
|
<td :style="{ width: songTitleWidth + 'px' }" class="flex">
|
||||||
<div class="album-art rounded image"></div>
|
<div
|
||||||
|
class="album-art rounded image"
|
||||||
|
:style='{ backgroundImage: `url("${image_path + song.image}")` }'
|
||||||
|
></div>
|
||||||
<div>
|
<div>
|
||||||
<span class="ellipsis">{{ song.title }}</span>
|
<span class="ellipsis">{{ song.title }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,28 +28,28 @@
|
|||||||
:style="{ width: songTitleWidth + 'px' }"
|
:style="{ width: songTitleWidth + 'px' }"
|
||||||
v-if="songTitleWidth > minWidth"
|
v-if="songTitleWidth > minWidth"
|
||||||
>
|
>
|
||||||
{{ song.duration }}
|
{{ song.length/60 }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else ref="songtitle"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "@vue/reactivity";
|
import { ref } from "@vue/reactivity";
|
||||||
import { onMounted, onUnmounted } from "@vue/runtime-core";
|
import { onMounted, onUnmounted } from "@vue/runtime-core";
|
||||||
import Songs from "../../data/songs.js";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
props: ["songs"],
|
||||||
setup() {
|
setup() {
|
||||||
const songtitle = ref(null);
|
const songtitle = ref(null);
|
||||||
const songTitleWidth = ref(null);
|
const songTitleWidth = ref(null);
|
||||||
|
const image_path = "http://127.0.0.1:8900/images/thumbnails/";
|
||||||
|
|
||||||
const minWidth = ref(300);
|
const minWidth = ref(300);
|
||||||
|
|
||||||
const songs = Songs.songs;
|
|
||||||
|
|
||||||
const resizeSongTitleWidth = () => {
|
const resizeSongTitleWidth = () => {
|
||||||
let a = songtitle.value.clientWidth;
|
let a = songtitle.value.clientWidth;
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ export default {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
resizeSongTitleWidth();
|
resizeSongTitleWidth();
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
resizeSongTitleWidth();
|
resizeSongTitleWidth();
|
||||||
});
|
});
|
||||||
@@ -67,7 +70,7 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return { songtitle, songTitleWidth, songs, minWidth };
|
return { songtitle, image_path, songTitleWidth, minWidth };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -95,8 +98,8 @@ export default {
|
|||||||
width: 3rem;
|
width: 3rem;
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
margin-right: 1rem;
|
margin-right: 1rem;
|
||||||
background-color: #ccc;
|
// background-color: rgb(194, 67, 67);
|
||||||
background-image: url(../../assets/images/jw.jpeg);
|
// background-image: url(../../assets/images/jw.jpeg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder .table .flex {
|
.folder .table .flex {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const getData = async (path) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
songs.value = data.songs;
|
songs.value = data.files;
|
||||||
folders.value = data.folders;
|
folders.value = data.folders;
|
||||||
|
|
||||||
return { songs, folders };
|
return { songs, folders };
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<SearchBox />
|
<SearchBox />
|
||||||
</div>
|
</div>
|
||||||
<div id="scrollable">
|
<div id="scrollable">
|
||||||
<SongList />
|
<SongList :songs="songs" />
|
||||||
<FolderList :folders="folders" />
|
<FolderList :folders="folders" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -12,13 +12,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "@vue/reactivity";
|
import { ref } from "@vue/reactivity";
|
||||||
import { useRoute } from 'vue-router'
|
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 SearchBox from "@/components/FolderView/SearchBox.vue";
|
||||||
|
|
||||||
import getData from "../composables/getFiles.js";
|
import getData from "../composables/getFiles.js";
|
||||||
|
import { watch } from "@vue/runtime-core";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -28,18 +29,25 @@ export default {
|
|||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const path = ref(route.params.path);
|
||||||
const path = route.params.path;
|
|
||||||
|
|
||||||
console.log(path);
|
|
||||||
|
|
||||||
const songs = ref([]);
|
const songs = ref([]);
|
||||||
const folders = ref([]);
|
const folders = ref([]);
|
||||||
|
|
||||||
getData("/Music").then((data) => {
|
const getPathFolders = (path) => {
|
||||||
songs.value = data.songs.value;
|
getData(path).then((data) => {
|
||||||
folders.value = data.folders.value;
|
songs.value = data.songs.value;
|
||||||
|
folders.value = data.folders.value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getPathFolders(path.value);
|
||||||
|
|
||||||
|
watch(route, (new_route) => {
|
||||||
|
const path = ref(new_route.params.path);
|
||||||
|
getPathFolders(path.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
songs,
|
songs,
|
||||||
folders,
|
folders,
|
||||||
|
|||||||
Reference in New Issue
Block a user