This commit is contained in:
2026-05-12 22:08:15 +02:00
parent 24d34c77d5
commit 0a02a94561
24 changed files with 5318 additions and 11596 deletions

View File

@@ -3,47 +3,50 @@
windows_subsystem = "windows"
)]
// mod menu;
use tauri::{webview::{NewWindowResponse, WebviewWindowBuilder}, WebviewUrl};
use tauri::{
webview::{NewWindowResponse, WebviewWindowBuilder},
WebviewUrl,
};
use tauri_plugin_opener::OpenerExt;
const LOCALHOST_PORT: u16 = 44_548;
fn main_window_url() -> WebviewUrl {
#[cfg(debug_assertions)]
{
WebviewUrl::default()
}
#[cfg(not(debug_assertions))]
{
let url = format!("http://localhost:{LOCALHOST_PORT}")
.parse()
.expect("failed to parse localhost app URL");
WebviewUrl::External(url)
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let port: u16 = 44548;
let context = tauri::generate_context!();
let builder = tauri::Builder::default();
// #[cfg(target_os = "macos")]
// {
// builder = builder.menu(menu::menu());
// }
builder
.plugin(tauri_plugin_localhost::Builder::new(port).build())
.plugin(tauri_plugin_window_state::Builder::default().build())
tauri::Builder::default()
.plugin(tauri_plugin_localhost::Builder::new(LOCALHOST_PORT).build())
.plugin(tauri_plugin_opener::init())
.setup(move |app| {
// Dev: use devUrl from tauri.conf.json (http://localhost:8080) to support HMR
#[cfg(debug_assertions)]
let window_url = WebviewUrl::App(Default::default());
// Release: tauri-plugin-localhost serves bundled frontend assets on this port
#[cfg(not(debug_assertions))]
let window_url = {
let url = format!("http://localhost:{}", port).parse().unwrap();
WebviewUrl::External(url)
};
.setup(|app| {
let app_handle = app.handle().clone();
WebviewWindowBuilder::new(app, "main".to_string(), window_url)
.title("Cinny")
let builder = WebviewWindowBuilder::new(app, "main", main_window_url());
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let builder = builder.title("Cinny");
builder
.on_new_window(move |url, _features| {
let _ = app_handle.opener().open_url(url.as_str(), None::<&str>);
NewWindowResponse::Deny
})
.build()?;
Ok(())
})
.run(context)
.run(tauri::generate_context!())
.expect("error while building tauri application");
}