From c1ce6f716e234f0f1ab8e572b000e5544df2ebea Mon Sep 17 00:00:00 2001 From: reya Date: Mon, 2 Sep 2024 08:26:10 +0700 Subject: [PATCH] fix: titlebar on windows --- src-tauri/capabilities/default.json | 1 + src-tauri/src/main.rs | 23 +++-- src/global.css | 132 +++++++++++++------------ src/routes/$account.chats.$id.lazy.tsx | 8 +- src/routes/$account.chats.lazy.tsx | 2 +- src/routes/index.lazy.tsx | 2 +- 6 files changed, 95 insertions(+), 73 deletions(-) diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 18b8d57..553e9be 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -26,6 +26,7 @@ "core:window:allow-set-size", "core:window:allow-set-focus", "core:window:allow-start-dragging", + "core:window:allow-toggle-maximize", "decorum:allow-show-snap-overlay", "prevent-default:default", "updater:default", diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 48cef7e..3bdc309 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -73,10 +73,6 @@ fn main() { let handle = app.handle(); let main_window = app.get_webview_window("main").unwrap(); - // Open devtools - #[cfg(debug_assertions)] - main_window.open_devtools(); - // Set custom decoration #[cfg(target_os = "windows")] main_window.create_overlay_titlebar().unwrap(); @@ -85,7 +81,7 @@ fn main() { #[cfg(target_os = "macos")] main_window.set_traffic_lights_inset(12.0, 18.0).unwrap(); - // Workaround for reset traffic light when window resized + // Workaround for reset traffic light when theme changed #[cfg(target_os = "macos")] let win_ = main_window.clone(); #[cfg(target_os = "macos")] @@ -165,9 +161,8 @@ fn main() { Ok(()) }) - .enable_macos_default_menu(false) + .plugin(prevent_default()) .plugin(tauri_plugin_fs::init()) - .plugin(tauri_plugin_prevent_default::init()) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_updater::Builder::new().build()) .plugin(tauri_plugin_os::init()) @@ -179,3 +174,17 @@ fn main() { .run(tauri::generate_context!()) .expect("error while running tauri application"); } + +#[cfg(debug_assertions)] +fn prevent_default() -> tauri::plugin::TauriPlugin { + use tauri_plugin_prevent_default::Flags; + + tauri_plugin_prevent_default::Builder::new() + .with_flags(Flags::all().difference(Flags::CONTEXT_MENU)) + .build() +} + +#[cfg(not(debug_assertions))] +fn prevent_default() -> tauri::plugin::TauriPlugin { + tauri_plugin_prevent_default::Builder::new().build() +} diff --git a/src/global.css b/src/global.css index 8ac02ee..b6b7a2c 100644 --- a/src/global.css +++ b/src/global.css @@ -3,98 +3,106 @@ @tailwind utilities; @layer utilities { - .break-message { - word-break: break-word; - word-wrap: break-word; - overflow-wrap: break-word; - } + .break-message { + word-break: break-word; + word-wrap: break-word; + overflow-wrap: break-word; + } } html { - font-size: 14px; + font-size: 14px; } a { - @apply cursor-default no-underline !important; + @apply cursor-default no-underline !important; } button { - @apply cursor-default focus:outline-none; + @apply cursor-default focus:outline-none; } input::-ms-reveal, input::-ms-clear { - display: none; + display: none; } ::-webkit-input-placeholder { - line-height: normal; + line-height: normal; +} + +div[data-tauri-decorum-tb] { + @apply h-12 !important; +} + +button.decorum-tb-btn { + @apply h-12 !important; } .spinner-leaf { - position: absolute; - top: 0; - left: calc(50% - 12.5% / 2); - width: 12.5%; - height: 100%; - animation: spinner-leaf-fade 800ms linear infinite; + position: absolute; + top: 0; + left: calc(50% - 12.5% / 2); + width: 12.5%; + height: 100%; + animation: spinner-leaf-fade 800ms linear infinite; - &::before { - content: ""; - display: block; - width: 100%; - height: 30%; - background-color: currentColor; - @apply rounded; - } + &::before { + content: ""; + display: block; + width: 100%; + height: 30%; + background-color: currentColor; + @apply rounded; + } - &:where(:nth-child(1)) { - transform: rotate(0deg); - animation-delay: -800ms; - } + &:where(:nth-child(1)) { + transform: rotate(0deg); + animation-delay: -800ms; + } - &:where(:nth-child(2)) { - transform: rotate(45deg); - animation-delay: -700ms; - } + &:where(:nth-child(2)) { + transform: rotate(45deg); + animation-delay: -700ms; + } - &:where(:nth-child(3)) { - transform: rotate(90deg); - animation-delay: -600ms; - } + &:where(:nth-child(3)) { + transform: rotate(90deg); + animation-delay: -600ms; + } - &:where(:nth-child(4)) { - transform: rotate(135deg); - animation-delay: -500ms; - } + &:where(:nth-child(4)) { + transform: rotate(135deg); + animation-delay: -500ms; + } - &:where(:nth-child(5)) { - transform: rotate(180deg); - animation-delay: -400ms; - } + &:where(:nth-child(5)) { + transform: rotate(180deg); + animation-delay: -400ms; + } - &:where(:nth-child(6)) { - transform: rotate(225deg); - animation-delay: -300ms; - } + &:where(:nth-child(6)) { + transform: rotate(225deg); + animation-delay: -300ms; + } - &:where(:nth-child(7)) { - transform: rotate(270deg); - animation-delay: -200ms; - } + &:where(:nth-child(7)) { + transform: rotate(270deg); + animation-delay: -200ms; + } - &:where(:nth-child(8)) { - transform: rotate(315deg); - animation-delay: -100ms; - } + &:where(:nth-child(8)) { + transform: rotate(315deg); + animation-delay: -100ms; + } } @keyframes spinner-leaf-fade { - from { - opacity: 1; - } + from { + opacity: 1; + } - to { - opacity: 0.25; - } + to { + opacity: 0.25; + } } diff --git a/src/routes/$account.chats.$id.lazy.tsx b/src/routes/$account.chats.$id.lazy.tsx index 43f7ead..431fe8b 100644 --- a/src/routes/$account.chats.$id.lazy.tsx +++ b/src/routes/$account.chats.$id.lazy.tsx @@ -46,13 +46,17 @@ function Screen() { function Header() { const { account, id } = Route.useParams(); + const { platform } = Route.useRouteContext(); return (
-
+
diff --git a/src/routes/$account.chats.lazy.tsx b/src/routes/$account.chats.lazy.tsx index f97754d..0938909 100644 --- a/src/routes/$account.chats.lazy.tsx +++ b/src/routes/$account.chats.lazy.tsx @@ -57,7 +57,7 @@ function Header() {
diff --git a/src/routes/index.lazy.tsx b/src/routes/index.lazy.tsx index cb11308..0627e61 100644 --- a/src/routes/index.lazy.tsx +++ b/src/routes/index.lazy.tsx @@ -59,7 +59,7 @@ function Screen() { if (res.status === "ok") { navigate({ - to: "/$account/chats", + to: "/$account/chats/new", params: { account: res.data }, replace: true, });