Home
+__ _ _____ / /________ ____ ___ ___ | | /| / / _ \/ / ___/ __ \/ __ `__ \/ _ \ | |/ |/ / __/ / /__/ /_/ / / / / / / __/ |__/|__/\___/_/\___/\____/_/ /_/ /_/\___/-- -@@ -26,6 +33,7 @@ + \ No newline at end of file diff --git a/plugins/music.ts b/plugins/music.ts index 2bb5f6b..3339c83 100644 --- a/plugins/music.ts +++ b/plugins/music.ts @@ -97,6 +97,8 @@ export default defineNuxtPlugin((nuxtApp) => { musicStore.player.currentSongId = id; await musicStore.setSongFromBuffer(contents); await this.ensureAudioContextAndFilters(); + const currentTime = new Date().toISOString(); + musicStore.updateLastPlayed(id, currentTime); } else { settingsStore.settings.playerSettings.currentSong = ""; await settingsStore.saveSettings(); diff --git a/stores/music.ts b/stores/music.ts index 240e23f..448cc65 100644 --- a/stores/music.ts +++ b/stores/music.ts @@ -1,19 +1,23 @@ +import { + BaseDirectory, + writeTextFile, +} from "@tauri-apps/plugin-fs"; import type { MusicStore, SongsConfig, Song } from "~/types/types"; export const useMusicStore = defineStore("musicStore", { state: () => - ({ - songsConfig: { - songs: {}, - }, - player: { - audio: new Audio(), - currentSongId: "", - audioContext: null, - sourceNode: null, - eqFilters: [] - }, - } as MusicStore), + ({ + songsConfig: { + songs: {}, + }, + player: { + audio: new Audio(), + currentSongId: "", + audioContext: null, + sourceNode: null, + eqFilters: [] + }, + } as MusicStore), actions: { init(songs: SongsConfig) { @@ -45,6 +49,14 @@ export const useMusicStore = defineStore("musicStore", { }, getSongByID(id: string): Song | null { return this.songsConfig?.songs?.[id] ?? null; - } + }, + updateLastPlayed(songId: string, lastPlayed: string) { + if (this.songsConfig.songs[songId]) { + this.songsConfig.songs[songId].lastPlayed = lastPlayed; + writeTextFile("Vleer/songs.json", JSON.stringify(this.songsConfig, null, 2), { + baseDir: BaseDirectory.Audio, + }); + } + }, }, }); diff --git a/types/types.ts b/types/types.ts index 5d6e791..777930f 100644 --- a/types/types.ts +++ b/types/types.ts @@ -6,6 +6,7 @@ export interface Song { cover: string; coverURL?: string; date_added: string; + lastPlayed?: string; } export interface SongsConfig {Song ID is missing
--{{ song.title }}
-{{ song.artist }}
-{{ formatDuration(song.length) }}
-{{ formatDate(song.date_added) }}
+ +++ +Playlists+ ++Recently played++-+ +++{{ truncate(song.title) }}
+{{ truncate(song.artist) }}
+