feat(settings): add button to open app data folder

This commit is contained in:
2025-10-05 00:17:33 -04:00
parent 8fb27b1acd
commit ca5f79b23a
9 changed files with 122 additions and 24 deletions

View File

@@ -19,6 +19,8 @@
import { clearDeezerCache } from '$lib/library/deezer-database';
import { open, confirm, message } from '@tauri-apps/plugin-dialog';
import { relaunch } from '@tauri-apps/plugin-process';
import { appDataDir } from '@tauri-apps/api/path';
import { openPath } from '@tauri-apps/plugin-opener';
let currentMusicFolder = $state<string | null>(null);
let currentPlaylistsFolder = $state<string | null>(null);
@@ -122,6 +124,21 @@
}
}
}
async function openAppDataFolder() {
try {
const dataPath = await appDataDir();
console.log('App data path:', dataPath);
if (!dataPath) {
throw new Error('Could not get app data directory path');
}
await openPath(dataPath);
} catch (error) {
console.error('Error opening app data folder:', error);
const errorMessage = error instanceof Error ? error.message : String(error);
await message('Error opening app data folder: ' + errorMessage, { title: 'Error', kind: 'error' });
}
}
</script>
<div style="padding: 8px;">
@@ -339,6 +356,12 @@
<small class="help-text">This will delete all cached Deezer favorites data. The next time you visit the Deezer page, it will refetch from the API.</small>
<button onclick={clearDeezerDatabase}>Clear Deezer Cache</button>
</div>
<div class="field-row-stacked">
<div class="setting-heading">Open App Data Folder</div>
<small class="help-text">Opens the application data folder containing SQLite databases and other app data.</small>
<button onclick={openAppDataFolder}>Open Folder</button>
</div>
</section>
{/if}
</div>