Switched to Pinia, Added Save for Albums

This commit is contained in:
Shiny Nematoda 2022-07-17 08:06:17 +00:00
parent a43b0907e2
commit f303f91108
No known key found for this signature in database
GPG key ID: 6506D50F5613A42D
25 changed files with 945 additions and 799 deletions

11
src/stores/misc.js Normal file
View file

@ -0,0 +1,11 @@
import { reactive } from 'vue';
import { defineStore } from 'pinia';
export const useNav = defineStore('nav', () => {
const state = reactive({
search: '',
page: 'home',
});
return { state };
});

50
src/stores/player.js Normal file
View file

@ -0,0 +1,50 @@
import { reactive } from 'vue';
import { defineStore } from 'pinia';
import { useStore } from '../scripts/util.js';
const store = useStore();
export const useData = defineStore('data', () => {
const state = reactive({
title: '',
description: '',
artist: '',
art: '',
url: '',
artistUrl: '',
lyrics: '',
src: [],
urls: [],
});
return { state };
});
export const usePlayer = defineStore('player', () => {
const state = reactive({
loop: false,
play: false,
status: 'play',
duration: 0,
time: 0,
playlist: false,
lyrics: false,
info: false,
vol: store.vol ? store.vol / 100 : 1,
});
function toggle(i) {
console.log(i, state[i]);
if (typeof state[i] == 'boolean') {
state[i] = !state[i];
}
console.log(i, state[i]);
}
function setTime(t) {
state.time = Math.floor((t / state.duration) * 100);
}
return { state, toggle, setTime };
});

44
src/stores/results.js Normal file
View file

@ -0,0 +1,44 @@
import { ref, reactive } from 'vue';
import { defineStore } from 'pinia';
export const useResults = defineStore('results', () => {
const items = ref({}),
search = ref('');
function setItem(key, val) {
items.value[key] = val;
console.log(items.value);
}
function resetItems() {
for (let i in items.value) {
items.value[i] = undefined;
}
}
return { items, search, setItem, resetItems };
});
export const useArtist = defineStore('artist', () => {
const state = reactive({
playlistId: null,
title: null,
description: null,
subscriberCount: 0,
thumbnails: [],
});
function reset() {
for (let i in state) {
state[i] = undefined;
}
}
function set(obj) {
for (let i in obj) {
state[i] = obj[i];
}
}
return { state, set, reset };
});