-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThemePlugin not defined #13
Comments
@MatthewScholefield This is just a documentation error, I forgot to change README.md. If you are using tauri_plugin_theme::ThemePlugin::init(ctx.config_mut()); If you are using tauri_plugin_theme::init(ctx.config_mut()); |
Note: A new version was released an hour ago. To avoid confusion, both v1 and v2 use the same API. # For tauri@v1
cargo add tauri-plugin-theme@1
# For tauri@v2
cargo add tauri-plugin-theme@2 let mut ctx = tauri::generate_context!();
tauri::Builder::default()
// ...
.plugin(tauri_plugin_theme::init(ctx.config_mut()))
// ...
.run(ctx)
// ... |
when i use the theme on vue3, and code below: |
async function getSystemTheme() {
- const theme = await invoke('plugin:theme|theme')
+ const theme = await invoke("plugin:theme|get_theme");
console.log(theme)
} ; |
It works but all i get the theme is auto, even i changed it to dark. btw my system is redhat 9, and tauri v1, theme-plugin-theme@0.2.0 and i also tried to listen theme-changed, seems no response. code like below: listen('tauri://theme-changed', (event) => { |
# 1.
invoke("plugin:theme|set_theme", {theme: 'dark'})
# 2.
$ cat ~/.config/{YOUR_APP_ID}/tauri-plugin-theme
# 3.
const theme = invoke("plugin:theme|get_theme")
# 4.
invoke("plugin:theme|set_theme", {theme: 'light'})
# 5.
$ cat ~/.config/{YOUR_APP_ID}/tauri-plugin-theme
# 6.
const theme = invoke("plugin:theme|get_theme") The results of
This plugin does not send events to Tauri. If you need to get the currently used theme, please use the following code: const medie = window.matchMedia('(prefers-color-scheme: dark)')
medie.addEventListener('change', () => {
const theme = medie.matches ? 'dark' : 'light'
}) |
The exact code on the README doesn't seem to work:
I had to change it to:
Not sure if this is something that changed in the new version but afterwards everything works great!
The text was updated successfully, but these errors were encountered: