@@ -7,14 +7,12 @@ mod api;
77mod db;
88mod utils;
99
10+ use sqlx:: sqlite:: SqlitePoolOptions ;
1011use std:: fs;
1112use tauri:: Manager ;
12- use tauri:: WebviewUrl ;
13- use tauri:: WebviewWindow ;
14- use sqlx:: sqlite:: SqlitePoolOptions ;
13+ use tauri_plugin_aptabase:: { EventTracker , InitOptions } ;
1514use tauri_plugin_autostart:: MacosLauncher ;
1615use tauri_plugin_prevent_default:: Flags ;
17- use tauri_plugin_aptabase:: { EventTracker , InitOptions } ;
1816
1917fn main ( ) {
2018 let runtime = tokio:: runtime:: Runtime :: new ( ) . expect ( "Failed to create Tokio runtime" ) ;
@@ -27,19 +25,27 @@ fn main() {
2725 . plugin ( tauri_plugin_dialog:: init ( ) )
2826 . plugin ( tauri_plugin_fs:: init ( ) )
2927 . plugin ( tauri_plugin_updater:: Builder :: default ( ) . build ( ) )
30- . plugin ( tauri_plugin_aptabase:: Builder :: new ( "A-SH-8937252746" )
31- . with_options ( InitOptions {
32- host : Some ( "https://aptabase.pandadev.net" . to_string ( ) ) ,
33- flush_interval : None ,
34- } )
35- . with_panic_hook ( Box :: new ( |client, info, msg| {
36- let location = info. location ( ) . map ( |loc| format ! ( "{}:{}:{}" , loc. file( ) , loc. line( ) , loc. column( ) ) ) . unwrap_or_else ( || "" . to_string ( ) ) ;
37-
38- let _ = client. track_event ( "panic" , Some ( serde_json:: json!( {
39- "info" : format!( "{} ({})" , msg, location) ,
40- } ) ) ) ;
41- } ) )
42- . build ( ) )
28+ . plugin (
29+ tauri_plugin_aptabase:: Builder :: new ( "A-SH-8937252746" )
30+ . with_options ( InitOptions {
31+ host : Some ( "https://aptabase.pandadev.net" . to_string ( ) ) ,
32+ flush_interval : None ,
33+ } )
34+ . with_panic_hook ( Box :: new ( |client, info, msg| {
35+ let location = info
36+ . location ( )
37+ . map ( |loc| format ! ( "{}:{}:{}" , loc. file( ) , loc. line( ) , loc. column( ) ) )
38+ . unwrap_or_else ( || "" . to_string ( ) ) ;
39+
40+ let _ = client. track_event (
41+ "panic" ,
42+ Some ( serde_json:: json!( {
43+ "info" : format!( "{} ({})" , msg, location) ,
44+ } ) ) ,
45+ ) ;
46+ } ) )
47+ . build ( ) ,
48+ )
4349 . plugin ( tauri_plugin_autostart:: init (
4450 MacosLauncher :: LaunchAgent ,
4551 Some ( vec ! [ ] ) ,
@@ -52,7 +58,7 @@ fn main() {
5258 . setup ( |app| {
5359 let app_data_dir = app. path ( ) . app_data_dir ( ) . unwrap ( ) ;
5460 utils:: logger:: init_logger ( & app_data_dir) . expect ( "Failed to initialize logger" ) ;
55-
61+
5662 fs:: create_dir_all ( & app_data_dir) . expect ( "Failed to create app data directory" ) ;
5763
5864 let db_path = app_data_dir. join ( "data.db" ) ;
@@ -76,31 +82,16 @@ fn main() {
7682 app_handle_clone. manage ( pool) ;
7783 } ) ;
7884
79- let main_window = if let Some ( window) = app. get_webview_window ( "main" ) {
80- window
81- } else {
82- WebviewWindow :: builder ( app. handle ( ) , "main" , WebviewUrl :: App ( "index.html" . into ( ) ) )
83- . title ( "Qopy" )
84- . resizable ( false )
85- . fullscreen ( false )
86- . inner_size ( 750.0 , 474.0 )
87- . focused ( true )
88- . skip_taskbar ( true )
89- . visible ( false )
90- . decorations ( false )
91- . transparent ( true )
92- . always_on_top ( false )
93- . build ( ) ?
94- } ;
85+ let main_window = app. get_webview_window ( "main" ) ;
9586
9687 let _ = db:: database:: setup ( app) ;
9788 api:: hotkeys:: setup ( app_handle. clone ( ) ) ;
9889 api:: tray:: setup ( app) ?;
9990 api:: clipboard:: setup ( app. handle ( ) ) ;
10091 let _ = api:: clipboard:: start_monitor ( app_handle. clone ( ) ) ;
10192
102- utils:: commands:: center_window_on_current_monitor ( & main_window) ;
103- main_window. hide ( ) ?;
93+ utils:: commands:: center_window_on_current_monitor ( main_window. as_ref ( ) . unwrap ( ) ) ;
94+ main_window. as_ref ( ) . map ( |w| w . hide ( ) ) . unwrap_or ( Ok ( ( ) ) ) ?;
10495
10596 let _ = app. track_event ( "app_started" , None ) ;
10697
0 commit comments