feat: add option to launch app at Windows startup
record-daemon / Build, check and test (push) Successful in 2m23s

- Add tauri-plugin-autostart dependency to Cargo.toml
- Add autostart permissions to capabilities/default.json
- Initialize autostart plugin in lib.rs with LaunchAgent config
- Add "Launch at Startup" toggle in Settings.vue Daemon tab with state management and async enable/disable functions
This commit is contained in:
vhaudiquet committed 2026-06-15 20:10:49 +02:00
1 parent ba4ed63f4c
commit 45aac067f8
4 files changed
+128 -8

No files matched your search

+49
View File
@@ -37,6 +37,8 @@ const daemonStatus = ref<DaemonStatusResponse | null>(null);
const encoders = ref<EncodersResponse | null>(null);
const daemonRunning = ref(false);
const statusPolling = ref<ReturnType<typeof setInterval> | null>(null);
const autostartEnabled = ref(false);
const autostartLoading = ref(false);
// Active settings tab
type SettingsTab = "video" | "output" | "audio" | "daemon";
@@ -97,6 +99,35 @@ async function refreshStatus() {
}
}
// ---------------------------------------------------------------------------
// Autostart management
// ---------------------------------------------------------------------------
async function checkAutostart() {
try {
autostartEnabled.value = await invoke<boolean>("plugin:autostart|is_enabled");
} catch {
autostartEnabled.value = false;
}
}
async function toggleAutostart() {
autostartLoading.value = true;
try {
if (autostartEnabled.value) {
await invoke("plugin:autostart|disable");
autostartEnabled.value = false;
} else {
await invoke("plugin:autostart|enable");
autostartEnabled.value = true;
}
} catch (e) {
error.value = `Failed to ${autostartEnabled.value ? 'disable' : 'enable'} autostart: ${e}`;
} finally {
autostartLoading.value = false;
}
}
// ---------------------------------------------------------------------------
// Save settings
// ---------------------------------------------------------------------------
@@ -240,6 +271,7 @@ const statusColor = computed(() => {
onMounted(async () => {
await loadSettings();
await checkAutostart();
// Poll daemon status every 3 seconds
statusPolling.value = setInterval(refreshStatus, 3000);
});
@@ -651,6 +683,23 @@ onUnmounted(() => {
<!-- Daemon tab -->
<div v-if="activeTab === 'daemon'" class="tab-content">
<section class="settings-section">
<h3>Startup</h3>
<div class="form-group">
<label class="form-label">Launch at Startup</label>
<label class="toggle">
<input
type="checkbox"
:checked="autostartEnabled"
:disabled="autostartLoading"
@change="toggleAutostart"
/>
<span class="toggle-slider"></span>
</label>
<span class="form-hint">Automatically launch League Recorder when you log in to Windows</span>
</div>
</section>
<section class="settings-section">
<h3>Daemon Behavior</h3>
<div class="form-group">