mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-22 05:34:04 +02:00
much cleaner file structure
This commit is contained in:
parent
374dc45674
commit
296a844aaa
4 changed files with 72 additions and 84 deletions
|
@ -1,50 +0,0 @@
|
|||
mod clipboard_listener;
|
||||
mod database;
|
||||
mod global_shortcut;
|
||||
mod tray;
|
||||
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_autostart::MacosLauncher;
|
||||
use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
Some(vec![]),
|
||||
))
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||
.setup(|app| {
|
||||
let app_handle = app.handle().clone();
|
||||
|
||||
global_shortcut::setup(app_handle.clone());
|
||||
tray::setup(app)?;
|
||||
database::setup(app)?;
|
||||
clipboard_listener::setup(app_handle);
|
||||
|
||||
if let Some(window) = app.get_window("main") {
|
||||
let _ = window.restore_state(StateFlags::POSITION);
|
||||
window.show().unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|app, event| match event {
|
||||
tauri::WindowEvent::CloseRequested { .. }
|
||||
| tauri::WindowEvent::Destroyed
|
||||
| tauri::WindowEvent::Focused(false) => {
|
||||
let _ = AppHandleExt::save_window_state(app.app_handle(), StateFlags::POSITION);
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
clipboard_listener::simulate_paste
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
|
@ -1,6 +1,52 @@
|
|||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
#![cfg_attr(
|
||||
all(not(debug_assertions), target_os = "windows"),
|
||||
windows_subsystem = "windows"
|
||||
)]
|
||||
|
||||
mod clipboard_listener;
|
||||
mod database;
|
||||
mod global_shortcut;
|
||||
mod tray;
|
||||
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_autostart::MacosLauncher;
|
||||
use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt};
|
||||
|
||||
fn main() {
|
||||
app_lib::run();
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
Some(vec![]),
|
||||
))
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||
.setup(|app| {
|
||||
let app_handle = app.handle().clone();
|
||||
|
||||
global_shortcut::setup(app_handle.clone());
|
||||
tray::setup(app)?;
|
||||
database::setup(app)?;
|
||||
clipboard_listener::setup(app_handle);
|
||||
|
||||
if let Some(window) = app.get_window("main") {
|
||||
let _ = window.restore_state(StateFlags::POSITION);
|
||||
window.show().unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|app, event| match event {
|
||||
tauri::WindowEvent::CloseRequested { .. }
|
||||
| tauri::WindowEvent::Destroyed
|
||||
| tauri::WindowEvent::Focused(false) => {
|
||||
let _ = AppHandleExt::save_window_state(app.app_handle(), StateFlags::POSITION);
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![clipboard_listener::simulate_paste])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue