mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 13:14:04 +02:00
feat: add autostart toggle setting
This commit is contained in:
parent
6d7874c1ae
commit
3bfd72b638
7 changed files with 11 additions and 16 deletions
9
app.vue
9
app.vue
|
@ -7,9 +7,11 @@
|
|||
<script setup lang="ts">
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { app, window } from "@tauri-apps/api";
|
||||
import { disable, enable } from "@tauri-apps/plugin-autostart";
|
||||
import { onMounted } from "vue";
|
||||
|
||||
const keyboard = useKeyboard();
|
||||
const { $settings } = useNuxtApp();
|
||||
|
||||
onMounted(async () => {
|
||||
await listen("settings", async () => {
|
||||
|
@ -19,6 +21,12 @@ onMounted(async () => {
|
|||
await window.getCurrentWindow().show();
|
||||
});
|
||||
|
||||
if ((await $settings.getSetting("autostart")) === "true") {
|
||||
await enable();
|
||||
} else {
|
||||
await disable();
|
||||
}
|
||||
|
||||
await listen("main_route", async () => {
|
||||
await navigateTo("/");
|
||||
});
|
||||
|
@ -54,7 +62,6 @@ onMounted(async () => {
|
|||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
color: #e5dfd5;
|
||||
text-decoration: none;
|
||||
font-family: SFRoundedRegular;
|
||||
scroll-behavior: smooth;
|
||||
|
|
|
@ -162,7 +162,6 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
|||
import "overlayscrollbars/overlayscrollbars.css";
|
||||
import { app, window } from "@tauri-apps/api";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { enable, isEnabled } from "@tauri-apps/plugin-autostart";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { useNuxtApp } from "#app";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
@ -666,10 +665,6 @@ onMounted(async () => {
|
|||
?.viewport?.addEventListener("scroll", handleScroll);
|
||||
|
||||
await setupEventListeners();
|
||||
|
||||
if (!(await isEnabled())) {
|
||||
await enable();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error during onMounted:", error);
|
||||
}
|
||||
|
|
|
@ -12,14 +12,6 @@ export default defineNuxtPlugin(() => {
|
|||
async saveSetting(key: string, value: string): Promise<void> {
|
||||
await invoke<void>("save_setting", { key, value });
|
||||
},
|
||||
|
||||
async getKeybind(): Promise<string[]> {
|
||||
return await invoke<string[]>("get_keybind");
|
||||
},
|
||||
|
||||
async saveKeybind(keybind: string[]): Promise<void> {
|
||||
await invoke<void>("save_keybind", { keybind });
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -69,9 +69,9 @@ async fn apply_migrations(pool: &SqlitePool) -> Result<(), Box<dyn std::error::E
|
|||
.files()
|
||||
.filter_map(|file| {
|
||||
let file_name = file.path().file_name()?.to_str()?;
|
||||
if file_name.ends_with(".sql") && file_name.starts_with("migration") {
|
||||
if file_name.ends_with(".sql") && file_name.starts_with("v") {
|
||||
let version: i64 = file_name
|
||||
.trim_start_matches("migration")
|
||||
.trim_start_matches("v")
|
||||
.trim_end_matches(".sql")
|
||||
.parse()
|
||||
.ok()?;
|
||||
|
|
1
src-tauri/src/db/migrations/v3.sql
Normal file
1
src-tauri/src/db/migrations/v3.sql
Normal file
|
@ -0,0 +1 @@
|
|||
INSERT INTO settings (key, value) VALUES ('autostart', 'true');
|
Loading…
Add table
Add a link
Reference in a new issue