add save config

This commit is contained in:
Julian Freeman
2025-12-07 19:05:35 -04:00
parent fb8be899d5
commit b9a41342a5
2 changed files with 87 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ const toggleTheme = (val: string | number | boolean) => {
}
};
onMounted(() => {
onMounted(async () => {
const savedTheme = localStorage.getItem('theme');
if (savedTheme === 'dark' || (!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
isDark.value = true;
@@ -33,6 +33,8 @@ onMounted(() => {
isDark.value = false;
document.documentElement.classList.remove('dark');
}
await loadConfig();
});
// Preparation Data
@@ -42,6 +44,45 @@ const selectedDate = ref<Date | null>(new Date());
const currentDir = ref("");
const videoNamePrefix = ref("");
// Configuration Types
interface AppConfig {
working_dir: string;
template_dir: string;
}
// Load/Save Config Logic
const loadConfig = async () => {
try {
const config = await invoke<AppConfig>('load_config');
if (config.working_dir) workingDir.value = config.working_dir;
if (config.template_dir) templateDir.value = config.template_dir;
} catch (e) {
console.error("Failed to load config:", e);
}
}
const saveConfig = async () => {
try {
await invoke('save_config', {
config: {
working_dir: workingDir.value,
template_dir: templateDir.value
}
});
} catch (e) {
console.error("Failed to save config:", e);
}
}
// Watchers for Auto-Save
watch(workingDir, () => {
saveConfig();
});
watch(templateDir, () => {
saveConfig();
});
// Actions
const selectWorkingDir = async () => {
const selected = await open({
@@ -271,4 +312,4 @@ body {
max-width: 800px;
margin-bottom: 20px;
}
</style>
</style>