mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
Integrated titlebar windows
This commit is contained in:
13
src-tauri/Cargo.lock
generated
13
src-tauri/Cargo.lock
generated
@@ -5328,6 +5328,18 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "window-shadows"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67ff424735b1ac21293b0492b069394b0a189c8a463fb015a16dea7c2e221c08"
|
||||
dependencies = [
|
||||
"cocoa 0.25.0",
|
||||
"objc",
|
||||
"raw-window-handle",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.37.0"
|
||||
@@ -5813,6 +5825,7 @@ dependencies = [
|
||||
"tauri-plugin-window-state",
|
||||
"tokio",
|
||||
"uuid",
|
||||
"window-shadows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -17,6 +17,9 @@ tauri-build = { version = "1.2", features = [] }
|
||||
objc = "0.2.7"
|
||||
cocoa = "0.25.0"
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
openssl-sys = {version = "0.9", features = ["vendored"] } # For Ubuntu installation to work
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.21.0"
|
||||
boa_engine = "0.17.3"
|
||||
@@ -29,7 +32,7 @@ reqwest = { version = "0.11.14", features = ["json", "multipart", "gzip", "brotl
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0", features = ["raw_value"] }
|
||||
sqlx = { version = "0.7.2", features = ["sqlite", "runtime-tokio-rustls", "json", "chrono", "time"] }
|
||||
tauri = { version = "1.3", features = [
|
||||
tauri = { version = "1.5.2", features = [
|
||||
"config-toml",
|
||||
"devtools",
|
||||
"dialog-open",
|
||||
@@ -42,6 +45,7 @@ tauri = { version = "1.3", features = [
|
||||
"window-close",
|
||||
"window-maximize",
|
||||
"window-minimize",
|
||||
"window-set-decorations",
|
||||
"window-set-title",
|
||||
"window-start-dragging",
|
||||
"window-unmaximize",
|
||||
@@ -52,7 +56,7 @@ tokio = { version = "1.25.0", features = ["sync"] }
|
||||
uuid = "1.3.0"
|
||||
log = "0.4.20"
|
||||
datetime = "0.5.2"
|
||||
openssl-sys = {version = "0.9", features = ["vendored"] } # For Ubuntu installation to work
|
||||
window-shadows = "0.2.2"
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
|
||||
@@ -17,16 +17,17 @@ use log::{debug, info, warn};
|
||||
use rand::random;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use sqlx::{Pool, Sqlite, SqlitePool};
|
||||
use sqlx::migrate::Migrator;
|
||||
use sqlx::types::Json;
|
||||
use tauri::{AppHandle, RunEvent, State, Window, WindowUrl, Wry};
|
||||
use tauri::{Manager, WindowEvent};
|
||||
use sqlx::{Pool, Sqlite, SqlitePool};
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
use tauri::{AppHandle, RunEvent, State, Window, WindowUrl, Wry};
|
||||
use tauri::{Manager, WindowEvent};
|
||||
use tauri_plugin_log::{fern, LogTarget};
|
||||
use tauri_plugin_window_state::{StateFlags, WindowExt};
|
||||
use tokio::sync::Mutex;
|
||||
use window_shadows::set_shadow;
|
||||
|
||||
use window_ext::TrafficLightWindowExt;
|
||||
|
||||
@@ -68,7 +69,7 @@ async fn migrate_db(
|
||||
info!("Running migrations at {}", p.to_string_lossy());
|
||||
let m = Migrator::new(p).await.expect("Failed to load migrations");
|
||||
m.run(pool).await.expect("Failed to run migrations");
|
||||
info!("Migrations complete");
|
||||
info!("Migrations complete!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -232,12 +233,7 @@ async fn track_event(
|
||||
action: AnalyticsAction,
|
||||
attributes: Option<Value>,
|
||||
) -> Result<(), String> {
|
||||
analytics::track_event(
|
||||
&window.app_handle(),
|
||||
resource,
|
||||
action,
|
||||
attributes,
|
||||
).await;
|
||||
analytics::track_event(&window.app_handle(), resource, action, attributes).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -701,9 +697,16 @@ fn main() {
|
||||
)
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.setup(|app| {
|
||||
let app_data_dir = app.path_resolver().app_data_dir().unwrap();
|
||||
let app_config_dir = app.path_resolver().app_config_dir().unwrap();
|
||||
info!(
|
||||
"App Config Dir: {}",
|
||||
app_config_dir.as_path().to_string_lossy(),
|
||||
);
|
||||
info!("App Data Dir: {}", app_data_dir.as_path().to_string_lossy(),);
|
||||
let dir = match is_dev() {
|
||||
true => current_dir().unwrap(),
|
||||
false => app.path_resolver().app_data_dir().unwrap(),
|
||||
false => app_data_dir,
|
||||
};
|
||||
|
||||
create_dir_all(dir.clone()).expect("Problem creating App directory!");
|
||||
@@ -835,10 +838,12 @@ fn main() {
|
||||
}
|
||||
|
||||
fn is_dev() -> bool {
|
||||
#[cfg(dev)] {
|
||||
#[cfg(dev)]
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#[cfg(not(dev))] {
|
||||
#[cfg(not(dev))]
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -860,7 +865,7 @@ fn create_window(handle: &AppHandle<Wry>, url: Option<&str>) -> Window<Wry> {
|
||||
100.0 + random::<f64>() * 30.0,
|
||||
100.0 + random::<f64>() * 30.0,
|
||||
)
|
||||
.decorations(false)
|
||||
.decorations(false) // Doesn't seem to work from Rust, here, so we do it in JS
|
||||
.title(handle.package_info().name.to_string());
|
||||
|
||||
// Add macOS-only things
|
||||
@@ -870,11 +875,16 @@ fn create_window(handle: &AppHandle<Wry>, url: Option<&str>) -> Window<Wry> {
|
||||
.menu(app_menu)
|
||||
.hidden_title(true)
|
||||
.decoratons(true)
|
||||
.transparent(false)
|
||||
.title_bar_style(TitleBarStyle::Overlay);
|
||||
}
|
||||
|
||||
let win = win_builder.build().expect("failed to build window");
|
||||
|
||||
// Tauri doesn't support shadows when hiding decorations, so we add our own
|
||||
#[cfg(any(windows, target_os = "macos"))]
|
||||
set_shadow(&win, true).unwrap();
|
||||
|
||||
let win2 = win.clone();
|
||||
let handle2 = handle.clone();
|
||||
win.on_menu_event(move |event| match event.menu_item_id() {
|
||||
|
||||
@@ -53,8 +53,9 @@ pub async fn actually_send_request(
|
||||
.tls_info(true);
|
||||
|
||||
if settings.request_timeout > 0 {
|
||||
client_builder =
|
||||
client_builder.timeout(Duration::from_millis(settings.request_timeout.unsigned_abs()));
|
||||
client_builder = client_builder.timeout(Duration::from_millis(
|
||||
settings.request_timeout.unsigned_abs(),
|
||||
));
|
||||
}
|
||||
|
||||
// .use_rustls_tls() // TODO: Make this configurable (maybe)
|
||||
|
||||
@@ -35,12 +35,13 @@
|
||||
"open": true
|
||||
},
|
||||
"window": {
|
||||
"startDragging": true,
|
||||
"setTitle": true,
|
||||
"minimize": true,
|
||||
"close": true,
|
||||
"maximize": true,
|
||||
"unmaximize": true,
|
||||
"close": true
|
||||
"minimize": true,
|
||||
"setDecorations": true,
|
||||
"setTitle": true,
|
||||
"startDragging": true,
|
||||
"unmaximize": true
|
||||
},
|
||||
"dialog": {
|
||||
"all": false,
|
||||
|
||||
Reference in New Issue
Block a user