Add custom topbar for windows, and remove flags like right click

This commit is contained in:
2026-02-17 16:12:32 -07:00
parent e7583d3f9e
commit 6b17ab9b9d
6 changed files with 75 additions and 21 deletions

View File

@@ -23,6 +23,8 @@ reqwest = { version = "0.13.2", default-features = false, features = ["stream",
tauri-plugin-opener = "2.5.3" tauri-plugin-opener = "2.5.3"
tauri-plugin-dialog = "2.6.0" tauri-plugin-dialog = "2.6.0"
sha2 = "0.10.9" sha2 = "0.10.9"
tauri-plugin-decorum = "1.1.1"
tauri-plugin-prevent-default = "4.0.3"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-single-instance = "2.4.0" tauri-plugin-single-instance = "2.4.0"

View File

@@ -7,7 +7,16 @@
], ],
"permissions": [ "permissions": [
"core:default", "core:default",
"core:window:allow-close",
"core:window:allow-center",
"core:window:allow-minimize",
"core:window:allow-maximize",
"core:window:allow-set-size",
"core:window:allow-set-focus",
"core:window:allow-is-maximized",
"core:window:allow-start-dragging", "core:window:allow-start-dragging",
"core:window:allow-toggle-maximize",
"decorum:allow-show-snap-overlay",
"fs:default", "fs:default",
"os:default", "os:default",
"opener:default", "opener:default",

View File

@@ -1,16 +1,20 @@
use sha2::{Digest, Sha512}; use sha2::{Digest, Sha512};
use std::fs::{remove_dir_all}; use std::fs::remove_dir_all;
use std::io::Cursor; use std::io::Cursor;
use std::{ use std::{
fs::{File, create_dir_all}, fs::{File, create_dir_all},
io::{copy}, io::copy,
path::PathBuf, path::PathBuf,
process::Command process::Command,
}; };
use tauri::{AppHandle, Manager}; use tauri::{AppHandle, Manager};
use tauri_plugin_os::platform; use tauri_plugin_os::platform;
use tauri_plugin_prevent_default::Flags;
use zip::ZipArchive; use zip::ZipArchive;
#[cfg(target_os = "windows")]
use tauri_plugin_decorum::WebviewWindowExt;
#[cfg(unix)] #[cfg(unix)]
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
@@ -127,19 +131,22 @@ fn load(app: AppHandle) {
if let Err(_) = Command::new("open") if let Err(_) = Command::new("open")
.arg("Lncvrt Games Launcher.app") .arg("Lncvrt Games Launcher.app")
.current_dir(&bin_path) .current_dir(&bin_path)
.spawn() { .spawn()
{
eprintln!("Failed to launch game on macOS"); eprintln!("Failed to launch game on macOS");
} }
} else if platform() == "linux" { } else if platform() == "linux" {
if let Err(_) = Command::new("./lncvrt-games-launcher") if let Err(_) = Command::new("./lncvrt-games-launcher")
.current_dir(&bin_path) .current_dir(&bin_path)
.spawn() { .spawn()
{
eprintln!("Failed to launch game on macOS"); eprintln!("Failed to launch game on macOS");
} }
} else if platform() == "windows" { } else if platform() == "windows" {
if let Err(_) = Command::new(&bin_path.join("lncvrt-games-launcher.exe")) if let Err(_) = Command::new(&bin_path.join("lncvrt-games-launcher.exe"))
.current_dir(&bin_path) .current_dir(&bin_path)
.spawn() { .spawn()
{
eprintln!("Failed to launch game on macOS"); eprintln!("Failed to launch game on macOS");
} }
} }
@@ -150,7 +157,44 @@ fn load(app: AppHandle) {
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
tauri::Builder::default() tauri::Builder::default()
.plugin(
tauri_plugin_prevent_default::Builder::new()
.with_flags(
Flags::FIND
| Flags::CARET_BROWSING
| Flags::DEV_TOOLS
| Flags::DOWNLOADS
| Flags::FOCUS_MOVE
| Flags::RELOAD
| Flags::SOURCE
| Flags::OPEN
| Flags::PRINT
| Flags::CONTEXT_MENU,
)
.build(),
)
.plugin(tauri_plugin_window_state::Builder::new().build())
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
let _ = app
.get_webview_window("main")
.expect("no main window")
.set_focus();
}))
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_decorum::init())
.plugin(tauri_plugin_os::init())
.setup(|app| { .setup(|app| {
#[cfg(target_os = "windows")]
{
if let Some(main_window) = app.get_webview_window("main") {
if let Err(e) = main_window.create_overlay_titlebar() {
eprintln!("Failed to create overlay titlebar: {:?}", e);
}
}
}
let app_local_data_dir = match app.path().app_local_data_dir() { let app_local_data_dir = match app.path().app_local_data_dir() {
Ok(p) => p, Ok(p) => p,
Err(_) => return Ok(()), Err(_) => return Ok(()),
@@ -175,17 +219,6 @@ pub fn run() {
Ok(()) Ok(())
}) })
.plugin(tauri_plugin_window_state::Builder::new().build())
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
let _ = app
.get_webview_window("main")
.expect("no main window")
.set_focus();
}))
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_fs::init())
.invoke_handler(tauri::generate_handler![download, load]) .invoke_handler(tauri::generate_handler![download, load])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");

View File

@@ -15,9 +15,13 @@
{ {
"title": "Lncvrt Games Launcher", "title": "Lncvrt Games Launcher",
"width": 300, "width": 300,
"height": 300, "height": 332,
"resizable": false, "resizable": false,
"maximizable": false "maximizable": false,
"titleBarStyle": "Overlay",
"hiddenTitle": true,
"decorations": false,
"shadow": true
} }
], ],
"security": { "security": {

View File

@@ -5,7 +5,9 @@ body {
font-family: 'Lexend', sans-serif; font-family: 'Lexend', sans-serif;
--col0: rgb(8, 8, 8); --col0: rgb(8, 8, 8);
--col1: rgb(16, 16, 16);
--col2: rgb(32, 32, 32); --col2: rgb(32, 32, 32);
--col3: rgb(48, 48, 48);
--col4: rgb(64, 64, 64); --col4: rgb(64, 64, 64);
--col6: rgb(96, 96, 96); --col6: rgb(96, 96, 96);
} }

View File

@@ -112,13 +112,17 @@ export default function App () {
} }
setState('Starting...') setState('Starting...')
// invoke('load') invoke('load')
})() })()
}, []) }, [])
return ( return (
<> <>
<div className='absolute left-1/2 top-[20%] -translate-x-1/2 flex flex-col items-center'> <div
className='relative z-2 w-screen border-b border-b-(--col3) h-8.25 bg-(--col1)'
hidden={platform() != 'windows'}
/>
<div className={`absolute left-1/2 ${platform() == 'windows' ? 'top-18' : 'top-10'} -translate-x-1/2 flex flex-col items-center`}>
<img <img
src='/Icon.png' src='/Icon.png'
width={128} width={128}