55 lines
1.3 KiB
Svelte
55 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import MainView from "./views/main.svelte";
|
|
import { listen } from "@tauri-apps/api/event";
|
|
import { invoke } from "@tauri-apps/api";
|
|
import { onDestroy, onMount } from "svelte";
|
|
import { config } from "./store";
|
|
import type { Config } from "./store";
|
|
|
|
$: transparent = $config.background_color === "transparent";
|
|
$: color =
|
|
typeof $config.background_color === "object"
|
|
? $config.background_color.custom
|
|
: $config.background_color;
|
|
|
|
$: {
|
|
invoke("log", {
|
|
msg: `color: ${color} trasnparent: ${transparent}`,
|
|
}).catch();
|
|
}
|
|
|
|
onMount(async () => {
|
|
$config = (await invoke("get_config")) as Config;
|
|
await listen("reload-config", async () => {
|
|
$config = (await invoke("get_config")) as Config;
|
|
});
|
|
config.subscribe((value) => {
|
|
invoke("log", { msg: `setting config: ${JSON.stringify(value)}` });
|
|
invoke("set_config", { config: value });
|
|
});
|
|
});
|
|
|
|
onDestroy(async () => {
|
|
await invoke("save_current_config");
|
|
});
|
|
</script>
|
|
|
|
<main>
|
|
<MainView
|
|
--active-color={transparent ? "lightblue" : color}
|
|
--inactive-color={color}
|
|
/>
|
|
</main>
|
|
|
|
<style lang="scss">
|
|
:global(*) {
|
|
-moz-user-select: none;
|
|
-webkit-user-select: none;
|
|
user-select: none;
|
|
}
|
|
|
|
:global(body) {
|
|
overflow: hidden;
|
|
}
|
|
</style>
|