move config to store
This commit is contained in:
parent
df884108e2
commit
562030bed3
|
@ -5,17 +5,23 @@
|
|||
import {invoke} from "@tauri-apps/api";
|
||||
import {onMount} from "svelte";
|
||||
import {config} from "./store";
|
||||
import type {Config} from "./store";
|
||||
import type {Config, BGColor} from "./store";
|
||||
|
||||
$: transparent = $config.background_color == "transparent";
|
||||
$: color = typeof $config.background_color == "object" ? $config.background_color.custom : $config.background_color;
|
||||
$: {
|
||||
invoke("set_blink_interval", {value: $config.blink_interval}).catch();
|
||||
}
|
||||
|
||||
$: {
|
||||
|
||||
invoke("log", {msg: `color: ${color} trasnparent: ${transparent}`
|
||||
}).catch();
|
||||
}
|
||||
|
||||
|
||||
onMount(async () => {
|
||||
$config = await invoke("get_config") as Config;
|
||||
// $config = await invoke("get_config") as Config;
|
||||
await appWindow.listen("reload-config", async () => {
|
||||
$config = await invoke("get_config") as Config;
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {writable} from "svelte/store";
|
||||
type BGColor ="transparent" | "blue" | "green" | "pink" | {custom: string} ;
|
||||
import {invoke} from "@tauri-apps/api";
|
||||
export type BGColor ="transparent" | "blue" | "green" | "pink" | {custom: string} ;
|
||||
|
||||
export class Config {
|
||||
background_color: BGColor;
|
||||
|
@ -11,5 +12,8 @@ export class Config {
|
|||
}
|
||||
}
|
||||
|
||||
const conf = await invoke("get_config") as Config;
|
||||
|
||||
|
||||
export let frames = writable(new Array<string>(4));
|
||||
export let config = writable(new Config());
|
||||
export let config = writable(conf);
|
||||
|
|
Loading…
Reference in New Issue