diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 276c114..889e3f8 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -271,6 +271,28 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "async-task" version = "4.7.1" @@ -339,6 +361,51 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "itoa 1.0.11", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.74" @@ -745,6 +812,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "combine" version = "4.6.7" @@ -986,6 +1063,48 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "devtools-core" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78cdd51f6f62ad4eb9b6581d7e238e1779db3144ddbd711388f552e6ed3194b" +dependencies = [ + "async-stream", + "bytes", + "devtools-wire-format", + "futures", + "http 0.2.12", + "hyper 0.14.31", + "log", + "prost-types", + "ringbuf", + "thiserror", + "tokio", + "tokio-stream", + "tonic", + "tonic-health", + "tonic-web", + "tower", + "tower-http", + "tower-layer", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "devtools-wire-format" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1c0de542960449c9566001c1879d10ede95f3f2e0013fdae0cc3b153bfabb0d" +dependencies = [ + "bitflags 2.6.0", + "prost", + "prost-types", + "tonic", + "tracing-core", +] + [[package]] name = "digest" version = "0.10.7" @@ -1114,6 +1233,12 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + [[package]] name = "embed-resource" version = "2.5.0" @@ -1248,7 +1373,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" dependencies = [ - "colored", + "colored 1.9.4", "log", ] @@ -1781,6 +1906,25 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap 2.6.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "h2" version = "0.4.6" @@ -1792,7 +1936,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http", + "http 1.1.0", "indexmap 2.6.0", "slab", "tokio", @@ -1859,6 +2003,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa 1.0.11", +] + [[package]] name = "http" version = "1.1.0" @@ -1870,6 +2025,17 @@ dependencies = [ "itoa 1.0.11", ] +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + [[package]] name = "http-body" version = "1.0.1" @@ -1877,7 +2043,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http", + "http 1.1.0", ] [[package]] @@ -1888,8 +2054,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -1899,12 +2065,48 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" +[[package]] +name = "http-range-header" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" + [[package]] name = "httparse" version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa 1.0.11", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + [[package]] name = "hyper" version = "1.5.0" @@ -1914,9 +2116,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2", - "http", - "http-body", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", "httparse", "itoa 1.0.11", "pin-project-lite", @@ -1932,8 +2134,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http", - "hyper", + "http 1.1.0", + "hyper 1.5.0", "hyper-util", "rustls", "rustls-pki-types", @@ -1943,6 +2145,18 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper 0.14.31", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "hyper-tls" version = "0.6.0" @@ -1951,7 +2165,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper", + "hyper 1.5.0", "hyper-util", "native-tls", "tokio", @@ -1968,9 +2182,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.5.0", "pin-project-lite", "socket2", "tokio", @@ -2115,6 +2329,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -2332,6 +2555,18 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "local-ip-address" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612ed4ea9ce5acfb5d26339302528a5e1e59dfed95e9e11af3c083236ff1d15d" +dependencies = [ + "libc", + "neli", + "thiserror", + "windows-sys 0.48.0", +] + [[package]] name = "lock_api" version = "0.4.12" @@ -2391,12 +2626,27 @@ dependencies = [ "tendril", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.7.4" @@ -2542,6 +2792,31 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "neli" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1100229e06604150b3becd61a4965d5c70f3be1759544ea7274166f4be41ef43" +dependencies = [ + "byteorder", + "libc", + "log", + "neli-proc-macros", +] + +[[package]] +name = "neli-proc-macros" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168194d373b1e134786274020dae7fc5513d565ea2ebb9bc9ff17ffb69106d4" +dependencies = [ + "either", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -2589,6 +2864,16 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -2652,11 +2937,13 @@ dependencies = [ "serde_json", "tauri", "tauri-build", + "tauri-plugin-devtools", "tauri-plugin-dialog", "tauri-plugin-log", "tauri-plugin-shell", "tauri-plugin-single-instance", "tauri-plugin-updater", + "tauri-plugin-window-state", "tokio", "version-compare", ] @@ -2995,6 +3282,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "pango" version = "0.18.3" @@ -3285,6 +3578,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -3365,6 +3664,38 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.85", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost", +] + [[package]] name = "ptr_meta" version = "0.1.4" @@ -3590,8 +3921,17 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -3602,9 +3942,15 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -3631,11 +3977,11 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", "http-body-util", - "hyper", + "hyper 1.5.0", "hyper-rustls", "hyper-tls", "hyper-util", @@ -3654,7 +4000,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "system-configuration", "tokio", "tokio-native-tls", @@ -3708,6 +4054,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "ringbuf" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "726bb493fe9cac765e8f96a144c3a8396bdf766dedad22e504b70b908dcbceb4" +dependencies = [ + "crossbeam-utils", + "portable-atomic", +] + [[package]] name = "rkyv" version = "0.7.45" @@ -3827,6 +4183,12 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + [[package]] name = "ryu" version = "1.0.18" @@ -4118,6 +4480,15 @@ dependencies = [ "digest", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shared_child" version = "1.0.1" @@ -4335,6 +4706,12 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "sync_wrapper" version = "1.0.1" @@ -4467,7 +4844,7 @@ dependencies = [ "glob", "gtk", "heck 0.5.0", - "http", + "http 1.1.0", "http-range", "image", "jni", @@ -4494,6 +4871,7 @@ dependencies = [ "tauri-utils", "thiserror", "tokio", + "tracing", "tray-icon", "url", "urlpattern", @@ -4583,6 +4961,33 @@ dependencies = [ "walkdir", ] +[[package]] +name = "tauri-plugin-devtools" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5cd17faa36a826e5686bd0fda5bc3f4c903682263f00cd50f2f778fc4bb866" +dependencies = [ + "async-stream", + "bytes", + "cocoa", + "colored 2.1.0", + "devtools-core", + "futures", + "local-ip-address", + "log", + "objc", + "serde", + "serde_json", + "swift-rs", + "tauri", + "tauri-plugin", + "tokio", + "tonic", + "tonic-health", + "tracing", + "tracing-subscriber", +] + [[package]] name = "tauri-plugin-dialog" version = "2.0.3" @@ -4690,7 +5095,7 @@ dependencies = [ "dirs", "flate2", "futures-util", - "http", + "http 1.1.0", "infer", "minisign-verify", "percent-encoding", @@ -4710,6 +5115,21 @@ dependencies = [ "zip", ] +[[package]] +name = "tauri-plugin-window-state" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd1cef203a15b4772898e7bc8e57c1f34696e39848987dfcd294d51ba0525650" +dependencies = [ + "bitflags 2.6.0", + "log", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror", +] + [[package]] name = "tauri-runtime" version = "2.1.1" @@ -4718,7 +5138,7 @@ checksum = "a1ef7363e7229ac8d04e8a5d405670dbd43dde8fc4bc3bc56105c35452d03784" dependencies = [ "dpi", "gtk", - "http", + "http 1.1.0", "jni", "raw-window-handle", "serde", @@ -4736,7 +5156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62fa2068e8498ad007b54d5773d03d57c3ff6dd96f8c8ce58beff44d0d5e0d30" dependencies = [ "gtk", - "http", + "http 1.1.0", "jni", "log", "objc2", @@ -4748,6 +5168,7 @@ dependencies = [ "tao", "tauri-runtime", "tauri-utils", + "tracing", "url", "webkit2gtk", "webview2-com", @@ -4851,6 +5272,16 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.36" @@ -4918,6 +5349,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-macros" version = "2.4.0" @@ -5049,6 +5490,110 @@ dependencies = [ "winnow", ] +[[package]] +name = "tonic" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-health" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f80db390246dfb46553481f6024f0082ba00178ea495dbb99e70ba9a4fafb5e1" +dependencies = [ + "async-stream", + "prost", + "tokio", + "tokio-stream", + "tonic", +] + +[[package]] +name = "tonic-web" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fddb2a37b247e6adcb9f239f4e5cefdcc5ed526141a416b943929f13aea2cce" +dependencies = [ + "base64 0.21.7", + "bytes", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "pin-project", + "tokio-stream", + "tonic", + "tower-http", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +dependencies = [ + "bitflags 2.6.0", + "bytes", + "futures-core", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "http-range-header", + "pin-project-lite", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.3" @@ -5061,6 +5606,7 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -5084,6 +5630,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -5262,6 +5838,12 @@ dependencies = [ "serde", ] +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "value-bag" version = "1.10.0" @@ -5961,7 +6543,7 @@ dependencies = [ "gdkx11", "gtk", "html5ever", - "http", + "http 1.1.0", "javascriptcore-rs", "jni", "kuchikiki", @@ -5979,6 +6561,7 @@ dependencies = [ "soup3", "tao-macros", "thiserror", + "tracing", "webkit2gtk", "webkit2gtk-sys", "webview2-com", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 784c95e..a0b317e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -31,10 +31,12 @@ tauri = { version = "2.0", features = [ "tray-icon", "devtools", ] } +tauri-plugin-devtools = "2.0" tauri-plugin-dialog = "2.0" tauri-plugin-log = { version = "2.0", features = ["colored"] } tauri-plugin-shell = "2.0" tauri-plugin-single-instance = "2.0" +tauri-plugin-window-state = "2.0" tauri-plugin-updater = "2.0" tokio = { version = "1", features = ["full"] } serde = { version = "1", features = ["derive"] } diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 56aa19b..79aa1ba 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -10,21 +10,52 @@ "core:path:default", "core:event:default", "core:window:default", - "core:window:allow-close", - "core:window:allow-start-dragging", - "core:window:allow-minimize", - "core:window:allow-unminimize", - "core:window:allow-show", - "core:window:allow-set-focus", + "core:window:allow-create", + "core:window:allow-center", + "core:window:allow-request-user-attention", + "core:window:allow-set-resizable", + "core:window:allow-set-closable", + "core:window:allow-set-title", + "core:window:allow-show", + "core:window:allow-hide", + "core:window:allow-close", + "core:window:allow-set-decorations", + "core:window:allow-set-always-on-top", + "core:window:allow-set-content-protected", + "core:window:allow-set-size", + "core:window:allow-set-min-size", + "core:window:allow-set-max-size", + "core:window:allow-set-position", + "core:window:allow-set-fullscreen", + "core:window:allow-set-focus", + "core:window:allow-set-icon", + "core:window:allow-set-skip-taskbar", + "core:window:allow-set-cursor-grab", + "core:window:allow-set-cursor-visible", + "core:window:allow-set-cursor-icon", + "core:window:allow-set-cursor-position", + "core:window:allow-set-ignore-cursor-events", + "core:window:allow-start-dragging", + "core:window:allow-maximize", + "core:window:allow-toggle-maximize", + "core:window:allow-unmaximize", + "core:window:allow-minimize", + "core:window:allow-unminimize", + "core:window:allow-set-maximizable", + "core:window:allow-set-minimizable", + "core:webview:allow-print", "core:app:default", "core:image:default", "core:resources:default", "core:menu:default", "core:tray:default", - "shell:allow-open", - "updater:allow-check", - "updater:allow-download", - "updater:allow-install", - "updater:allow-download-and-install" + "shell:allow-execute", + "shell:allow-open", + "shell:allow-kill", + "shell:allow-spawn", + "shell:allow-stdin-write", + "dialog:default", + "updater:default", + "window-state:default" ] } \ No newline at end of file diff --git a/src-tauri/src/core/handle.rs b/src-tauri/src/core/handle.rs index 0b6e523..59a7c0c 100644 --- a/src-tauri/src/core/handle.rs +++ b/src-tauri/src/core/handle.rs @@ -1,13 +1,13 @@ use super::tray::Tray; -use anyhow::{bail, Result}; +use anyhow::Result; use once_cell::sync::OnceCell; -use parking_lot::Mutex; +use parking_lot::RwLock; use std::sync::Arc; -use tauri::AppHandle; +use tauri::{AppHandle, Manager, WebviewWindow}; #[derive(Debug, Default, Clone)] pub struct Handle { - pub app_handle: Arc>>, + pub app_handle: Arc>>, } impl Handle { @@ -15,40 +15,37 @@ impl Handle { static HANDLE: OnceCell = OnceCell::new(); HANDLE.get_or_init(|| Handle { - app_handle: Arc::new(Mutex::new(None)), + app_handle: Arc::new(RwLock::new(None)), }) } - pub fn init(&self, app_handle: AppHandle) { - *self.app_handle.lock() = Some(app_handle); + pub fn init(&self, app_handle: &AppHandle) { + let mut handle = self.app_handle.write(); + *handle = Some(app_handle.clone()); } - pub fn update_systray() -> Result<()> { - let app_handle = Self::global().app_handle.lock(); - if app_handle.is_none() { - bail!("update_systray unhandled error"); + pub fn app_handle(&self) -> Option { + self.app_handle.read().clone() + } + + pub fn get_window(&self) -> Option { + let app_handle = self.app_handle().unwrap(); + let window: Option = app_handle.get_webview_window("main"); + if window.is_none() { + log::debug!(target:"app", "main window not found"); } - Tray::update_systray(app_handle.as_ref().unwrap())?; - Ok(()) + window } /// update the system tray state pub fn update_systray_part() -> Result<()> { - let app_handle = Self::global().app_handle.lock(); - if app_handle.is_none() { - bail!("update_systray unhandled error"); - } - Tray::update_part(app_handle.as_ref().unwrap())?; + Tray::update_part()?; Ok(()) } /// update the system tray state & emit event pub fn update_systray_part_with_emit(event: &str, version: &str) -> Result<()> { - let app_handle = Self::global().app_handle.lock(); - if app_handle.is_none() { - bail!("update_systray unhandled error"); - } - Tray::update_part_with_emit(app_handle.as_ref().unwrap(), event, version)?; + Tray::update_part_with_emit(event, version)?; Ok(()) } } diff --git a/src-tauri/src/core/tray.rs b/src-tauri/src/core/tray.rs index 39e166f..434d15f 100644 --- a/src-tauri/src/core/tray.rs +++ b/src-tauri/src/core/tray.rs @@ -14,6 +14,8 @@ use tauri::{ AppHandle, Emitter, Manager, Wry, }; +use super::handle; + pub struct Tray {} fn gen_check_menu_items( @@ -36,7 +38,7 @@ fn gen_check_menu_items( } impl Tray { - pub fn tray_menu(app_handle: &AppHandle) -> Result> { + pub fn create_tray_menu(app_handle: &AppHandle) -> Result> { let package_info = app_handle.package_info(); let version = package_info.version.to_string(); let app_name: String = package_info.name.to_string(); @@ -153,17 +155,17 @@ impl Tray { .build()?) } - pub fn update_systray(app_handle: &AppHandle) -> Result<()> { + pub fn create_systray() -> Result<()> { + let app_handle = handle::Handle::global().app_handle().unwrap(); if let Some(tray) = app_handle.tray_by_id("main") { - tray.set_menu(Some(Tray::tray_menu(app_handle)?))?; - tray.on_tray_icon_event(|tray, event| { + tray.on_tray_icon_event(|_, event| { #[cfg(not(target_os = "macos"))] if let TrayIconEvent::Click { button: MouseButton::Left, .. } = event { - let _ = resolve::create_window(&tray.app_handle()); + let _ = resolve::create_window(); } }); tray.on_menu_event(Tray::on_menu_event); @@ -172,19 +174,21 @@ impl Tray { Ok(()) } - pub fn update_part(app_handle: &AppHandle) -> Result<()> { + pub fn update_part() -> Result<()> { + let app_handle = handle::Handle::global().app_handle().unwrap(); if let Some(tray) = app_handle.tray_by_id("main") { - tray.set_menu(Some(Tray::tray_menu(app_handle)?))?; + let _ = tray.set_menu(Some(Tray::create_tray_menu(&app_handle)?)); Ok(()) } else { bail!("The system tray menu has not been initialized") } } - pub fn update_part_with_emit(app_handle: &AppHandle, event: &str, version: &str) -> Result<()> { + pub fn update_part_with_emit(event: &str, version: &str) -> Result<()> { + let app_handle = handle::Handle::global().app_handle().unwrap(); if let Some(tray) = app_handle.tray_by_id("main") { - tray.set_menu(Some(Tray::tray_menu(app_handle)?))?; - if let Some(window) = app_handle.get_webview_window("main") { + let _ = tray.set_menu(Some(Tray::create_tray_menu(&app_handle)?)); + if let Some(window) = handle::Handle::global().get_window() { window.emit(event, version)?; } Ok(()) @@ -196,7 +200,7 @@ impl Tray { pub fn on_menu_event(app_handle: &AppHandle, event: MenuEvent) { match event.id().as_ref() { "open_window" => { - let _ = resolve::create_window(app_handle); + let _ = resolve::create_window(); } "quit" => cmds::exit_app(app_handle.clone()), "open_data_dir" => crate::log_err!(cmds::open_data_dir()), diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 8043c6d..1ab478c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -8,29 +8,16 @@ mod utils; use config::Config; use tauri::Manager; -use tauri_plugin_log::{Target, TargetKind}; +use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use utils::resolve; fn main() -> tauri::Result<()> { #[cfg(target_os = "linux")] std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1"); - let builder = tauri::Builder::default() - .setup(|app| { - resolve::resolve_setup(app)?; - Ok(()) - }) + let mut builder = tauri::Builder::default() + .plugin(tauri_plugin_window_state::Builder::default().build()) .plugin(tauri_plugin_updater::Builder::default().build()) - .plugin( - tauri_plugin_log::Builder::default() - .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll) - .targets([ - Target::new(TargetKind::Stdout), - Target::new(TargetKind::LogDir { file_name: None }), - // Target::new(TargetKind::Webview), - ]) - .build(), - ) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_shell::init()) // Ensure single instance operation @@ -42,6 +29,13 @@ fn main() -> tauri::Result<()> { } }, )) + .setup(|app| { + tauri::async_runtime::block_on(async move { + resolve::resolve_setup(app).await; + }); + + Ok(()) + }) .invoke_handler(tauri::generate_handler![ // settings cmds::read_settings, @@ -60,8 +54,8 @@ fn main() -> tauri::Result<()> { cmds::update_projects, cmds::sync_project_version, cmds::batch_update_project_version, - cmds::open_dir, - cmds::open_with_vscode, + cmds::open_dir, + cmds::open_with_vscode, // groups cmds::group_list, cmds::update_groups, @@ -73,6 +67,28 @@ fn main() -> tauri::Result<()> { cmds::restart, ]); + #[cfg(debug_assertions)] + { + let devtools = tauri_plugin_devtools::init(); + builder = builder.plugin(devtools); + } + + #[cfg(not(debug_assertions))] + { + use tauri_plugin_log::{Builder, Target, TargetKind}; + + let log_plugin = Builder::default() + .rotation_strategy(tauri_plugin_log::RotationStrategy::KeepAll) + .targets([ + Target::new(TargetKind::Stdout), + Target::new(TargetKind::LogDir { file_name: None }), + // Target::new(TargetKind::Webview), + ]) + .build(); + + builder = builder.plugin(log_plugin); + } + let app = builder.build(tauri::generate_context!())?; app.run(|app_handle, err| match err { @@ -84,16 +100,20 @@ fn main() -> tauri::Result<()> { if closer == "minimize" { api.prevent_exit(); + return; } + + let _ = app_handle.save_window_state(StateFlags::default()); } tauri::RunEvent::WindowEvent { label, event, .. } => { if label == "main" { match event { - tauri::WindowEvent::Destroyed => { - // Destroyed Event - } tauri::WindowEvent::CloseRequested { api, .. } => { // CloseRequested Event + api.prevent_close(); + if let Some(window) = core::handle::Handle::global().get_window() { + log_err!(window.hide()); + } } _ => {} } diff --git a/src-tauri/src/utils/dirs.rs b/src-tauri/src/utils/dirs.rs index 8357fed..c1427d7 100644 --- a/src-tauri/src/utils/dirs.rs +++ b/src-tauri/src/utils/dirs.rs @@ -65,22 +65,24 @@ pub fn default_install_dir() -> PathBuf { /// get the resources dir pub fn app_resources_dir() -> Result { - let handle = handle::Handle::global(); - let app_handle = handle.app_handle.lock(); - if let Some(app_handle) = app_handle.as_ref() { - let res_dir = app_handle.path().resource_dir()?.join("resources"); - return Ok(res_dir); + let app_handle = handle::Handle::global().app_handle().unwrap(); + match app_handle.path().resource_dir() { + Ok(dir) => Ok(dir.join("resources")), + Err(e) => { + log::error!(target:"app", "Failed to get the resource directory: {}", e); + Err(anyhow::anyhow!("Failed to get the resource directory")) + } } - Err(anyhow::anyhow!("failed to get the resource dir")) } /// get the logs dir pub fn app_logs_dir() -> Result { - let handle = handle::Handle::global(); - let app_handle = handle.app_handle.lock(); - if let Some(app_handle) = app_handle.as_ref() { - let res_dir = app_handle.path().app_log_dir()?; - return Ok(res_dir); + let app_handle = handle::Handle::global().app_handle().unwrap(); + match app_handle.path().app_log_dir() { + Ok(dir) => Ok(dir), + Err(e) => { + log::error!(target:"app", "Failed to get the logs directory: {}", e); + Err(anyhow::anyhow!("Failed to get the logs directory")) + } } - Err(anyhow::anyhow!("failed to get the logs dir")) } diff --git a/src-tauri/src/utils/migrate.rs b/src-tauri/src/utils/migrate.rs index 13978e4..67a41c9 100644 --- a/src-tauri/src/utils/migrate.rs +++ b/src-tauri/src/utils/migrate.rs @@ -1,6 +1,8 @@ use anyhow::Result; -use std::{fs, thread, time::Duration}; +use std::time::Duration; use tauri::{Emitter, Manager}; +use tokio::fs; +use tokio::time::sleep; use super::{dirs, help}; use crate::core::handle; @@ -8,35 +10,34 @@ use crate::core::handle; const CURRENT_MIGRATION_VERSION: i16 = 16; const NODE_DEFAULT_EXECUTE: [&str; 4] = ["node", "npm", "npx", "corepack"]; -pub fn init() -> Result<()> { - thread::spawn(move || { - if let Err(err) = update_schema() { - log::error!(target: "migrate", "{err}"); - // Delay 1s before sending events to the window - thread::sleep(Duration::from_secs(1)); - let handle = handle::Handle::global(); - let app_handle = handle.app_handle.lock(); - if let Some(app_handle) = app_handle.as_ref() { - if let Some(window) = app_handle.get_webview_window("main") { - let _ = window.emit("app-migration-error", ()); - } - } +pub async fn init() -> Result<()> { + if let Err(err) = update_schema().await { + log::error!(target: "migrate", "{err}"); + // Delay 1s before sending events to the window + sleep(Duration::from_secs(1)).await; + + if let Some(window) = handle::Handle::global().get_window() { + let _ = window.emit("app-migration-error", ()); } - }); + } Ok(()) } -fn update_schema() -> Result<()> { - let mut schema_version = get_schema_version()?; - - if schema_version == 0 { - update_schema_from_basic()?; - schema_version = CURRENT_MIGRATION_VERSION; - } +async fn update_schema() -> Result<()> { + let schema_version = match get_schema_version() { + Ok(version) => version, + Err(err) => { + log::error!(target: "migrate", "{err}"); + 0 // treat error as version 0 + } + }; if schema_version < CURRENT_MIGRATION_VERSION { - update_schema_to_last()?; + if schema_version == 0 { + update_schema_from_basic().await?; + } + update_schema_to_last().await?; } Ok(()) @@ -54,81 +55,81 @@ fn get_schema_version() -> Result { } #[cfg(windows)] -fn update_schema_from_basic() -> Result<()> { +async fn update_schema_from_basic() -> Result<()> { let res_dir = dirs::app_resources_dir()?; - let bin_path = ensure_bin_path_exists()?; + let bin_path = ensure_bin_path_exists().await?; let nvmd_exe_source = res_dir.join("nvmd.exe"); let nvmd_cmd_source = res_dir.join("temp.cmd"); - fs::copy(&nvmd_exe_source, bin_path.join("nvmd.exe"))?; + fs::copy(&nvmd_exe_source, bin_path.join("nvmd.exe")).await?; for name in NODE_DEFAULT_EXECUTE { - fs::copy(&nvmd_exe_source, bin_path.join(format!("{}.exe", name)))?; + fs::copy(&nvmd_exe_source, bin_path.join(format!("{}.exe", name))).await?; if name != "node" { - fs::copy(&nvmd_cmd_source, bin_path.join(format!("{}.cmd", name)))?; + fs::copy(&nvmd_cmd_source, bin_path.join(format!("{}.cmd", name))).await?; } } - save_schema_version(CURRENT_MIGRATION_VERSION)?; + save_schema_version(CURRENT_MIGRATION_VERSION).await?; Ok(()) } #[cfg(unix)] -fn update_schema_from_basic() -> Result<()> { +async fn update_schema_from_basic() -> Result<()> { use std::os::unix::fs::symlink; let res_dir = dirs::app_resources_dir()?; - let bin_path = ensure_bin_path_exists()?; + let bin_path = ensure_bin_path_exists().await?; let nvmd_exe_path = bin_path.join("nvmd"); - fs::copy(res_dir.join("nvmd"), &nvmd_exe_path)?; + fs::copy(res_dir.join("nvmd"), &nvmd_exe_path).await?; for name in NODE_DEFAULT_EXECUTE { symlink(&nvmd_exe_path, bin_path.join(name))?; } - save_schema_version(CURRENT_MIGRATION_VERSION)?; + save_schema_version(CURRENT_MIGRATION_VERSION).await?; Ok(()) } #[cfg(windows)] -fn update_schema_to_last() -> Result<()> { +async fn update_schema_to_last() -> Result<()> { use anyhow::bail; let res_dir = dirs::app_resources_dir()?; - let bin_path = ensure_bin_path_exists()?; + let bin_path = ensure_bin_path_exists().await?; let nvmd_exe_source = res_dir.join("nvmd.exe"); - fs::copy(&nvmd_exe_source, bin_path.join("nvmd.exe"))?; - for entry in fs::read_dir(&bin_path)? { + fs::copy(&nvmd_exe_source, bin_path.join("nvmd.exe")).await?; + for entry in std::fs::read_dir(&bin_path)? { let path = entry?.path(); if path.extension().and_then(|ext| ext.to_str()) == Some("exe") { if let Some(file_name) = path.file_name() { - fs::copy(&nvmd_exe_source, bin_path.join(file_name))?; + fs::copy(&nvmd_exe_source, bin_path.join(file_name)).await?; } else { bail!("Failed to get file name for path: {:?}", path); } } } - save_schema_version(CURRENT_MIGRATION_VERSION)?; + save_schema_version(CURRENT_MIGRATION_VERSION).await?; Ok(()) } #[cfg(unix)] -fn update_schema_to_last() -> Result<()> { +async fn update_schema_to_last() -> Result<()> { let res_dir = dirs::app_resources_dir()?; - let bin_path = ensure_bin_path_exists()?; + let bin_path = ensure_bin_path_exists().await?; - fs::copy(res_dir.join("nvmd"), bin_path.join("nvmd"))?; - save_schema_version(CURRENT_MIGRATION_VERSION)?; + fs::copy(res_dir.join("nvmd"), bin_path.join("nvmd")).await?; + save_schema_version(CURRENT_MIGRATION_VERSION).await?; Ok(()) } -fn ensure_bin_path_exists() -> Result { +async fn ensure_bin_path_exists() -> Result { let bin_path = dirs::bin_path()?; if !bin_path.exists() { - fs::create_dir_all(&bin_path)?; + fs::create_dir_all(&bin_path).await?; } Ok(bin_path) } -fn save_schema_version(version: i16) -> Result<()> { - help::save_string(&dirs::migration_path()?, &version.to_string())?; +async fn save_schema_version(version: i16) -> Result<()> { + help::async_save_string(&dirs::migration_path()?, &version.to_string()).await?; Ok(()) } diff --git a/src-tauri/src/utils/resolve.rs b/src-tauri/src/utils/resolve.rs index a4ba62b..69833b9 100644 --- a/src-tauri/src/utils/resolve.rs +++ b/src-tauri/src/utils/resolve.rs @@ -1,5 +1,6 @@ use anyhow::Result; -use tauri::{App, AppHandle, Manager}; +use tauri::{App, Manager}; +use tauri_plugin_window_state::{StateFlags, WindowExt}; use crate::{ config::Config, @@ -9,34 +10,35 @@ use crate::{ }; /// handle something when start app -pub fn resolve_setup(app: &mut App) -> Result<()> { +pub async fn resolve_setup(app: &mut App) { #[cfg(target_os = "macos")] app.set_activation_policy(tauri::ActivationPolicy::Regular); - handle::Handle::global().init(app.app_handle().clone()); + handle::Handle::global().init(app.app_handle()); - log_err!(migrate::init()); - log_err!(tray::Tray::update_systray(&app.app_handle())); + log_err!(migrate::init().await); + log_err!(tray::Tray::create_systray()); let silent_start = { Config::settings().data().enable_silent_start }; if !silent_start.unwrap_or(false) { - create_window(&app.app_handle())?; + log_err!(create_window()); } - - Ok(()) + + log_err!(handle::Handle::update_systray_part()); } /// create main window -pub fn create_window(app_handle: &AppHandle) -> Result<()> { - if let Some(window) = app_handle.get_webview_window("main") { - trace_err!(window.unminimize(), "set win unminimize"); +pub fn create_window() -> Result<()> { + let app_handle = handle::Handle::global().app_handle().unwrap(); + + if let Some(window) = handle::Handle::global().get_window() { trace_err!(window.show(), "set win visible"); trace_err!(window.set_focus(), "set win focus"); return Ok(()); } let builder = tauri::WebviewWindowBuilder::new( - app_handle, + &app_handle, "main", tauri::WebviewUrl::App("index.html".into()), ) @@ -69,5 +71,7 @@ pub fn create_window(app_handle: &AppHandle) -> Result<()> { window.open_devtools(); } + let _ = window.restore_state(StateFlags::all()); + Ok(()) } diff --git a/src/app.tsx b/src/app.tsx index 2d715f2..55fc393 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -20,7 +20,6 @@ export default function App({ // open main webview window setTimeout(() => { const webviewWindow = getCurrent(); - webviewWindow.unminimize(); webviewWindow.show(); webviewWindow.setFocus(); });