Add custom topbar for windows, and remove flags like right click
This commit is contained in:
@@ -23,6 +23,8 @@ reqwest = { version = "0.13.2", default-features = false, features = ["stream",
|
||||
tauri-plugin-opener = "2.5.3"
|
||||
tauri-plugin-dialog = "2.6.0"
|
||||
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]
|
||||
tauri-plugin-single-instance = "2.4.0"
|
||||
|
||||
@@ -7,7 +7,16 @@
|
||||
],
|
||||
"permissions": [
|
||||
"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-toggle-maximize",
|
||||
"decorum:allow-show-snap-overlay",
|
||||
"fs:default",
|
||||
"os:default",
|
||||
"opener:default",
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
use sha2::{Digest, Sha512};
|
||||
use std::fs::{remove_dir_all};
|
||||
use std::fs::remove_dir_all;
|
||||
use std::io::Cursor;
|
||||
use std::{
|
||||
fs::{File, create_dir_all},
|
||||
io::{copy},
|
||||
io::copy,
|
||||
path::PathBuf,
|
||||
process::Command
|
||||
process::Command,
|
||||
};
|
||||
use tauri::{AppHandle, Manager};
|
||||
use tauri_plugin_os::platform;
|
||||
use tauri_plugin_prevent_default::Flags;
|
||||
use zip::ZipArchive;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use tauri_plugin_decorum::WebviewWindowExt;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
@@ -127,19 +131,22 @@ fn load(app: AppHandle) {
|
||||
if let Err(_) = Command::new("open")
|
||||
.arg("Lncvrt Games Launcher.app")
|
||||
.current_dir(&bin_path)
|
||||
.spawn() {
|
||||
.spawn()
|
||||
{
|
||||
eprintln!("Failed to launch game on macOS");
|
||||
}
|
||||
} else if platform() == "linux" {
|
||||
if let Err(_) = Command::new("./lncvrt-games-launcher")
|
||||
.current_dir(&bin_path)
|
||||
.spawn() {
|
||||
.spawn()
|
||||
{
|
||||
eprintln!("Failed to launch game on macOS");
|
||||
}
|
||||
} else if platform() == "windows" {
|
||||
if let Err(_) = Command::new(&bin_path.join("lncvrt-games-launcher.exe"))
|
||||
.current_dir(&bin_path)
|
||||
.spawn() {
|
||||
.spawn()
|
||||
{
|
||||
eprintln!("Failed to launch game on macOS");
|
||||
}
|
||||
}
|
||||
@@ -150,7 +157,44 @@ fn load(app: AppHandle) {
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
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| {
|
||||
#[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() {
|
||||
Ok(p) => p,
|
||||
Err(_) => return Ok(()),
|
||||
@@ -175,17 +219,6 @@ pub fn run() {
|
||||
|
||||
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])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
{
|
||||
"title": "Lncvrt Games Launcher",
|
||||
"width": 300,
|
||||
"height": 300,
|
||||
"height": 332,
|
||||
"resizable": false,
|
||||
"maximizable": false
|
||||
"maximizable": false,
|
||||
"titleBarStyle": "Overlay",
|
||||
"hiddenTitle": true,
|
||||
"decorations": false,
|
||||
"shadow": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
|
||||
@@ -5,7 +5,9 @@ body {
|
||||
font-family: 'Lexend', sans-serif;
|
||||
|
||||
--col0: rgb(8, 8, 8);
|
||||
--col1: rgb(16, 16, 16);
|
||||
--col2: rgb(32, 32, 32);
|
||||
--col3: rgb(48, 48, 48);
|
||||
--col4: rgb(64, 64, 64);
|
||||
--col6: rgb(96, 96, 96);
|
||||
}
|
||||
|
||||
@@ -112,13 +112,17 @@ export default function App () {
|
||||
}
|
||||
|
||||
setState('Starting...')
|
||||
// invoke('load')
|
||||
invoke('load')
|
||||
})()
|
||||
}, [])
|
||||
|
||||
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
|
||||
src='/Icon.png'
|
||||
width={128}
|
||||
|
||||
Reference in New Issue
Block a user