tailwindcss

This commit is contained in:
2026-08-14 08:22:18 +08:00
parent 4c0cbc9c85
commit 747e0840f4
11 changed files with 460 additions and 1071 deletions
+3 -1
View File
@@ -7,6 +7,7 @@ mod network;
mod profile;
mod remotes;
mod ufa;
mod ui;
mod user;
mod windowing;
@@ -21,7 +22,8 @@ async fn launch_app(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>>
app.manage(cursor::CursorState::default());
ufa::init(handle);
cursor::init(handle);
windowing::init(handle);
// windowing::init(handle);
ui::init(handle);
Ok(())
}
+7
View File
@@ -0,0 +1,7 @@
use tauri::AppHandle;
mod scene;
pub fn init(app_handle: &AppHandle) {
scene::init(app_handle);
}
+101
View File
@@ -0,0 +1,101 @@
use tauri::{AppHandle, Manager, WebviewUrl};
pub fn apply_macos_decoration_window_policy(app_handle: &AppHandle, window_label: String) {
#[cfg(target_os = "macos")]
{
let app_handle_for_closure = app_handle.clone();
if let Err(e) = app_handle.run_on_main_thread(move || {
let Some(window) = app_handle_for_closure.get_window(&window_label) else {
println!(
"Failed to apply macOS scene hardening: window '{}' not found",
window_label
);
return;
};
fn native(window: &tauri::Window) -> Result<(), tauri::Error> {
let ns_window = unsafe { &*window.ns_window()?.cast::<objc2_app_kit::NSWindow>() };
let behavior = objc2_app_kit::NSWindowCollectionBehavior::CanJoinAllSpaces
| objc2_app_kit::NSWindowCollectionBehavior::Stationary
| objc2_app_kit::NSWindowCollectionBehavior::IgnoresCycle;
ns_window.setLevel(objc2_app_kit::NSStatusWindowLevel);
ns_window.setCollectionBehavior(behavior);
Ok(())
}
if let Err(e) = native(&window) {
println!("Failed to apply macOS scene hardening policy: {}", e);
}
}) {
println!("Failed to schedule macOS scene hardening policy: {}", e);
}
}
#[cfg(not(target_os = "macos"))]
{}
}
pub const WINDOW_LABEL: &str = "scene";
pub fn overlay_fullscreen(
app_handle: &AppHandle,
window: &tauri::WebviewWindow,
) -> Result<(), tauri::Error> {
let monitor = app_handle.primary_monitor()?.unwrap();
let monitor_size = monitor.size();
// Fullscreen the window by expanding the window to match monitor size then move it to the top-left corner
// This forces the window to fit under the notch that exists on MacBooks with a notch
window.set_size(tauri::PhysicalSize {
width: monitor_size.width,
height: monitor_size.height,
})?;
window.set_position(tauri::PhysicalPosition { x: 0, y: 0 })?;
Ok(())
}
pub fn open_window(app_handle: &AppHandle) -> Result<tauri::WebviewWindow, String> {
if let Some(window) = app_handle.get_webview_window(WINDOW_LABEL) {
window.show().map_err(|e| e.to_string())?;
return Ok(window);
};
let builder = tauri::WebviewWindowBuilder::new(
app_handle,
WINDOW_LABEL,
WebviewUrl::App("/scene".into()),
)
.title("Scene")
.inner_size(800.0, 600.0)
.resizable(false)
.maximizable(false)
.minimizable(false)
.decorations(false)
.transparent(true)
.always_on_top(true)
.skip_taskbar(true)
.shadow(false)
.visible(true)
.focused(false);
let window = builder.build().map_err(|e: tauri::Error| e.to_string())?;
#[cfg(debug_assertions)]
window.open_devtools();
Ok(window)
}
pub fn init(app_handle: &AppHandle) {
let window = open_window(app_handle).expect("Scene window should be opened successfully");
overlay_fullscreen(app_handle, &window).expect("Scene window should be fullscreened");
apply_macos_decoration_window_policy(app_handle, WINDOW_LABEL.to_string());
window
.set_ignore_cursor_events(true)
.expect("Scene window needs to ignore cursor events");
}