Skip to content

Commit

Permalink
fix: slinet start get_window err
Browse files Browse the repository at this point in the history
  • Loading branch information
keiko233 committed Mar 19, 2024
1 parent 1928442 commit 41fdd90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
20 changes: 0 additions & 20 deletions backend/tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ use crate::{
use anyhow::Context;
use tauri::{api, Manager, SystemTray};

#[cfg(target_os = "windows")]
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings6;
#[cfg(target_os = "windows")]
use windows::core::Interface;

rust_i18n::i18n!("../../locales");

#[cfg(feature = "deadlock-detection")]
Expand Down Expand Up @@ -135,21 +130,6 @@ fn main() -> std::io::Result<()> {
handle.emit_all("scheme-request-received", request).unwrap();
}
));
let window = app.get_window("main").unwrap();
#[cfg(target_os = "windows")]
window
.with_webview(|webview| unsafe {
let settings = webview
.controller()
.CoreWebView2()
.unwrap()
.Settings()
.unwrap();
let settings: ICoreWebView2Settings6 =
settings.cast::<ICoreWebView2Settings6>().unwrap();
settings.SetIsSwipeNavigationEnabled(false).unwrap();
})
.unwrap();
Ok(())
})
.on_system_tray_event(core::tray::Tray::on_system_tray_event)
Expand Down
22 changes: 22 additions & 0 deletions backend/tauri/src/utils/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ use serde_yaml::Mapping;
use std::net::TcpListener;
use tauri::{api::process::Command, App, AppHandle, Manager, PhysicalPosition, PhysicalSize};

#[cfg(target_os = "windows")]
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings6;
#[cfg(target_os = "windows")]
use windows::core::Interface;

pub fn find_unused_port() -> Result<u16> {
match TcpListener::bind("127.0.0.1:0") {
Ok(listener) => {
Expand Down Expand Up @@ -263,6 +268,23 @@ pub fn create_window(app_handle: &AppHandle) {

#[cfg(target_os = "linux")]
crate::log_err!(builder.decorations(true).transparent(false).build());

#[cfg(target_os = "windows")]
app_handle
.get_window("main")
.unwrap()
.with_webview(|webview| unsafe {
let settings = webview
.controller()
.CoreWebView2()
.unwrap()
.Settings()
.unwrap();
let settings: ICoreWebView2Settings6 =
settings.cast::<ICoreWebView2Settings6>().unwrap();
settings.SetIsSwipeNavigationEnabled(false).unwrap();
})
.unwrap();
}

/// close main window
Expand Down

0 comments on commit 41fdd90

Please sign in to comment.