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
+320 -1066
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -13,8 +13,10 @@
},
"license": "MIT",
"dependencies": {
"@tailwindcss/vite": "^4.3.3",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2"
"@tauri-apps/plugin-opener": "^2",
"tailwindcss": "^4.3.3"
},
"devDependencies": {
"@sveltejs/adapter-static": "^3.0.6",
+1 -1
View File
@@ -18,7 +18,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri = { version = "2", features = ["macos-private-api", "unstable"] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
+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");
}
+2 -1
View File
@@ -12,7 +12,8 @@
"app": {
"security": {
"csp": null
}
},
"macOSPrivateApi": true
},
"bundle": {
"active": true,
+1
View File
@@ -0,0 +1 @@
@import "tailwindcss";
+15
View File
@@ -0,0 +1,15 @@
<script>
import { browser } from "$app/environment";
import "../app.css";
let { children } = $props();
if (browser) {
document.addEventListener("contextmenu", (e) => {
e.preventDefault();
});
}
</script>
<div class="w-screen h-screen max-w-[100vw] max-h-screen *:size-full">
{@render children?.()}
</div>
+5
View File
@@ -0,0 +1,5 @@
<div>
<div class="mt-12 mx-auto px-3 py-1 rounded w-min bg-white text-black">
<p>WYD</p>
</div>
</div>
+2 -1
View File
@@ -1,4 +1,5 @@
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
import { sveltekit } from "@sveltejs/kit/vite";
// @ts-expect-error process is a nodejs global
@@ -6,7 +7,7 @@ const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [sveltekit()],
plugins: [sveltekit(), tailwindcss()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//