mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
client: add progress bar
- add favourites buttons - redirect /folder/ => /folder/home - minor fixes
This commit is contained in:
+59
-25
@@ -1,23 +1,38 @@
|
||||
import { ref } from "@vue/reactivity";
|
||||
import { watch } from "@vue/runtime-core";
|
||||
|
||||
const current = ref({
|
||||
title: "Nothing played yet",
|
||||
artists: ["... blah blah blah"],
|
||||
title: "Nothing played yet",
|
||||
artists: ["... blah blah blah"],
|
||||
_id: {
|
||||
$oid: "",
|
||||
},
|
||||
});
|
||||
|
||||
const next = ref({
|
||||
title: "Next song shows here",
|
||||
artists: ["... blah blah blah"],
|
||||
title: "The next song",
|
||||
artists: ["... blah blah blah"],
|
||||
_id: {
|
||||
$oid: "",
|
||||
},
|
||||
});
|
||||
|
||||
const prev = ref({
|
||||
title: "The previous song",
|
||||
artists: ["... blah blah blah"],
|
||||
_id: {
|
||||
$oid: "",
|
||||
},
|
||||
});
|
||||
|
||||
const queue = ref([
|
||||
{
|
||||
title: "Nothing played yet",
|
||||
artists: ["... blah blah blah"],
|
||||
_id: {
|
||||
$oid: ""
|
||||
}
|
||||
}
|
||||
{
|
||||
title: "Nothing played yet",
|
||||
artists: ["... blah blah blah"],
|
||||
_id: {
|
||||
$oid: "",
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const putCommas = (artists) => {
|
||||
@@ -42,21 +57,40 @@ const doThat = (songs, current) => {
|
||||
};
|
||||
|
||||
const readQueue = () => {
|
||||
const prev_queue = JSON.parse(localStorage.getItem("queue"));
|
||||
const last_played = JSON.parse(localStorage.getItem("current"));
|
||||
const next_ = JSON.parse(localStorage.getItem("next"));
|
||||
const prev_queue = JSON.parse(localStorage.getItem("queue"));
|
||||
const last_played = JSON.parse(localStorage.getItem("current"));
|
||||
const next_ = JSON.parse(localStorage.getItem("next"));
|
||||
|
||||
if (last_played){
|
||||
current.value = last_played;
|
||||
}
|
||||
if (last_played) {
|
||||
current.value = last_played;
|
||||
}
|
||||
|
||||
if (prev_queue){
|
||||
queue.value = prev_queue;
|
||||
}
|
||||
if (prev_queue) {
|
||||
queue.value = prev_queue;
|
||||
}
|
||||
|
||||
if (next_){
|
||||
next.value = next_;
|
||||
}
|
||||
}
|
||||
if (next_) {
|
||||
next.value = next_;
|
||||
}
|
||||
};
|
||||
|
||||
export default { putCommas, doThat, readQueue, current, queue, next };
|
||||
watch(current, (new_current) => {
|
||||
localStorage.setItem("current", JSON.stringify(new_current));
|
||||
|
||||
const index = queue.value.findIndex(
|
||||
(item) => item._id.$oid === new_current._id.$oid
|
||||
);
|
||||
|
||||
if (index == queue.value.length - 1) {
|
||||
next.value = queue.value[0];
|
||||
prev.value = queue.value[queue.value.length - 2];
|
||||
} else if (index == 0) {
|
||||
next.value = queue.value[1];
|
||||
prev.value = queue.value[queue.value.length - 1];
|
||||
} else {
|
||||
next.value = queue.value[index + 1];
|
||||
prev.value = queue.value[index - 1];
|
||||
}
|
||||
});
|
||||
|
||||
export default { putCommas, doThat, readQueue, current, queue, next, prev };
|
||||
|
||||
Reference in New Issue
Block a user