Make the app feel more native & use transparency on windows & macos
This commit is contained in:
8 files changed
+71
-27
No files matched your search
@@ -22,6 +22,12 @@ tauri-plugin-os = "2.3.2"
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-single-instance = "2.4.2"
|
||||
|
||||
[target.'cfg(any(target_os = "windows", target_os = "macos"))'.dependencies]
|
||||
window-vibrancy = "0.7.1"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows-version = "0.1.7"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = "fat"
|
||||
|
||||
+53
-1
@@ -1,4 +1,4 @@
|
||||
use tauri::Manager;
|
||||
use tauri::{Manager, WebviewUrl, WebviewWindowBuilder};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
@@ -11,6 +11,58 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.invoke_handler(tauri::generate_handler![])
|
||||
.setup(|app| {
|
||||
#[allow(unused)]
|
||||
let mut transparency = false;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
transparency = true;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
transparency = windows_version::OsVersion::current()
|
||||
>= windows_version::OsVersion::new(10, 0, 0, 22000);
|
||||
}
|
||||
|
||||
let window = WebviewWindowBuilder::new(
|
||||
app,
|
||||
"main",
|
||||
WebviewUrl::App(
|
||||
format!(
|
||||
"/{}",
|
||||
if transparency {
|
||||
"?transparent=true"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
)
|
||||
.title("Password Generator")
|
||||
.inner_size(400.0, 600.0)
|
||||
.min_inner_size(400.0, 600.0)
|
||||
.transparent(transparency)
|
||||
.visible(false)
|
||||
.build()?;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None)
|
||||
.expect("Unable to apply window blur");
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
if transparency {
|
||||
window_vibrancy::apply_mica(&window, Some(true))
|
||||
.expect("Unable to apply window blur");
|
||||
}
|
||||
|
||||
window.show().unwrap();
|
||||
window.set_focus().unwrap();
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
@@ -10,15 +10,7 @@
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Password Generator",
|
||||
"width": 400,
|
||||
"height": 600,
|
||||
"minWidth": 400,
|
||||
"minHeight": 600
|
||||
}
|
||||
],
|
||||
"windows": [],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
@@ -26,10 +18,6 @@
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/icon.icns",
|
||||
"icons/icon.png",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
"icon": ["icons/icon.icns", "icons/icon.png", "icons/icon.ico"]
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user