How to get theme on tauri backend?
Opened this issue · 1 comments
How to get theme on tauri backend?
My application is creating all webviewWindow on the Tauri backend. when I create webviewWindow on the backend,
I want to apply the current theme value. Does this plug-in support that?
I think it seems support only javascript api. Is that right?
Currently only the JavaScript API is exposed, the Rust API is not.
But it is simple, if you want, you can get the theme by writing this code.
fn get_theme_value<R: Runtime>(app: &AppHandle<R>) -> Theme {
let config_dir = app.path().app_config_dir().unwrap();
let p = config_dir.join("tauri-plugin-theme");
fs::read_to_string(p)
.map(Theme::from)
.unwrap_or(Theme::Auto)
}
tauri-plugin-theme/tauri-plugin-theme/src/lib.rs
Lines 88 to 98 in df7229e
There are some issues with this plugin (mostly on Windows), such as setting the theme directly and locking the theme.
Until these issues are resolved I would recommend not using this plugin and controlling the theme entirely with CSS and JavaScript.