feat(pwa-offline): Pinia store + IndexedDB; contexto para cache/eliminación; toasts; compatibilidad PWA offline
All checks were successful
build-and-deploy / build (push) Successful in 40s
build-and-deploy / deploy (push) Successful in 4s

- Agrega @pinia/nuxt, idb y store central (stores/music.ts)
- Cacheo manual desde menú contextual y borrado (TrackContextMenu)
- Ícono verde para canciones cacheadas, sin auto-cache al reproducir
- Toasts de feedback (stores/toast.ts, ToastContainer)
- Fallback offline de listado a IndexedDB; fix MUSIC_DIR absoluto en preview/prod
- Ajustes PWA: navigateFallback '/', devOptions, workbox condicional
- Estilos y animación del context menu (tema light/dark, blur fuerte)
- Correcciones de sintaxis y posicionamiento exacto al cursor
This commit is contained in:
2025-08-10 02:51:38 -06:00
parent ba70e0d280
commit 81330de97e
14 changed files with 613 additions and 39 deletions

View File

@@ -1,7 +1,14 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from 'nuxt/config'
import { resolve, isAbsolute } from 'path'
// Compute absolute music directory at build-time to avoid .output cwd issues in preview/prod
const musicDirEnv = process.env.MUSIC_DIR || './music'
const musicDirAbs = isAbsolute(musicDirEnv) ? musicDirEnv : resolve(process.cwd(), musicDirEnv)
export default defineNuxtConfig({
// Helpers
hooks: {},
compatibilityDate: '2025-08-02',
// Disable SSR completely to avoid hydration issues with client-side audio APIs
ssr: false,
@@ -36,29 +43,20 @@ export default defineNuxtConfig({
},
modules: [
'@vueuse/nuxt',
'@vueuse/nuxt',
'@pinia/nuxt',
['@vite-pwa/nuxt', {
registerType: 'autoUpdate',
includeAssets: ['favicon.ico', 'logo.png', 'logo-192.png', 'logo-512.png', 'logo-maskable-512.png', 'icon.svg'],
workbox: {
workbox: process.env.NODE_ENV === 'production' ? {
navigateFallback: '/',
cleanupOutdatedCaches: true,
globPatterns: [
'**/*.{js,css,html,ico,png,svg}',
'_nuxt/**/*.{js,css}',
'assets/**/*.{png,jpg,jpeg,svg,gif,webp}'
],
runtimeCaching: [
{
urlPattern: /^https?:\/\/.*\/api\/music\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'music-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 30 // 30 days
}
}
},
{
urlPattern: /\.(png|jpg|jpeg|svg|gif|webp)$/,
handler: 'CacheFirst',
@@ -71,17 +69,22 @@ export default defineNuxtConfig({
}
}
]
} : {
// Dev SW: configuración mínima y sin patrones problemáticos
navigateFallback: '/',
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
globIgnores: ['**/_payload.json', '_nuxt/builds/**/*.json'],
},
client: {
installPrompt: true,
periodicSyncForUpdates: 20
},
devOptions: {
enabled: false,
// Permite instalar SW en dev cuando se habilita explícitamente
enabled: process.env.PWA_DEV === 'true',
type: 'module',
navigateFallback: '/'
},
mode: 'development',
manifest: {
name: 'RepoDructor Music Player',
short_name: 'RepoDructor',
@@ -131,12 +134,17 @@ export default defineNuxtConfig({
experimental: {
wasm: true
},
prerender: {
crawlLinks: true,
routes: ['/']
},
// Development configuration for proxy
devProxy: process.env.NODE_ENV === 'development' ? {} : undefined
},
// Runtime configuration
runtimeConfig: {
musicDirAbs,
public: {
musicPath: process.env.NUXT_PUBLIC_MUSIC_PATH || '/music'
}