diff --git a/src-tauri/src/adb.rs b/src-tauri/src/adb.rs index dbd4b79..08c5b11 100644 --- a/src-tauri/src/adb.rs +++ b/src-tauri/src/adb.rs @@ -1,8 +1,6 @@ use crate::resource::{ResHelper, ResourceName}; use std::{ - io::BufRead, - path::PathBuf, - process::{Child, Command, Stdio}, + io::BufRead, os::windows::process::CommandExt, path::PathBuf, process::{Child, Command, Stdio} }; use anyhow::{Context, Ok, Result}; @@ -89,7 +87,12 @@ pub struct Adb; /// But some output of command won't be output, like adb service startup information. impl Adb { fn cmd_base(res_dir: &PathBuf) -> Command { - Command::new(ResHelper::get_file_path(res_dir, ResourceName::Adb)) + let mut cmd = Command::new(ResHelper::get_file_path(res_dir, ResourceName::Adb)); + + #[cfg(target_os = "windows")] + cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW + + cmd } /// execute "adb devices" and return devices list diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index da93279..e9b5aca 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -130,6 +130,32 @@ async fn main() { .join("resource"), ) .unwrap(); + + let main_window = app.get_webview_window("main").unwrap(); + let scale_factor = main_window.scale_factor().unwrap(); + main_window + .set_size(tauri::Size::Physical(tauri::PhysicalSize { + width: 1350, + height: 750, + })) + .unwrap(); + + let zoomfactor = 1.0 / scale_factor; + main_window + .with_webview(move |webview| { + #[cfg(target_os = "windows")] + unsafe { + // see https://docs.rs/webview2-com/0.19.1/webview2_com/Microsoft/Web/WebView2/Win32/struct.ICoreWebView2Controller.html + webview.controller().SetZoomFactor(zoomfactor).unwrap(); + } + + // #[cfg(target_os = "macos")] + // unsafe { + // let () = msg_send![webview.inner(), setPageZoom: 4.]; + // } + }) + .unwrap(); + Ok(()) }) .plugin(tauri_plugin_shell::init()) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 38bb2d5..ede5a75 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -31,8 +31,6 @@ "icons/icon.icns", "icons/icon.ico" ], - "resources":[ - "resource/*" - ] + "resources": ["resource/*"] } } diff --git a/src/components/setting/Mask.vue b/src/components/setting/Mask.vue index 137a518..1e285bf 100644 --- a/src/components/setting/Mask.vue +++ b/src/components/setting/Mask.vue @@ -12,10 +12,9 @@ import { NIcon, FormInst, useMessage, + NP, } from "naive-ui"; import { - LogicalPosition, - LogicalSize, PhysicalPosition, PhysicalSize, getCurrent, @@ -27,21 +26,17 @@ let unlistenResize: UnlistenFn = () => {}; let unlistenMove: UnlistenFn = () => {}; async function refreshAreaModel(size?: PhysicalSize, pos?: PhysicalPosition) { - const factor = await getCurrent().scaleFactor(); - - const logicalSize = size?.toLogical(factor); - const logicalPos = pos?.toLogical(factor); // header size and sidebar size const mt = 30; const ml = 70; - if (logicalPos !== undefined) { - areaModel.value.posX = Math.floor(logicalPos.x + ml); - areaModel.value.posY = Math.floor(logicalPos.y + mt); + if (size !== undefined) { + areaModel.value.sizeW = Math.floor(size.width - ml); + areaModel.value.sizeH = Math.floor(size.height - mt); } - if (logicalSize !== undefined) { - areaModel.value.sizeW = Math.floor(logicalSize.width - ml); - areaModel.value.sizeH = Math.floor(logicalSize.height - mt); + if (pos !== undefined) { + areaModel.value.posX = Math.floor(pos.x + ml); + areaModel.value.posY = Math.floor(pos.y + mt); } } @@ -106,16 +101,12 @@ async function adjustMaskArea() { const appWindow = getCurrent(); - const pos = new LogicalPosition( + const pos = new PhysicalPosition( areaModel.value.posX - ml, areaModel.value.posY - mt ); - if (pos.x <= 0 || pos.y <= 0) { - message.warning("蒙版区域坐标过小,可能导致其他部分不可见"); - } - - const size = new LogicalSize( + const size = new PhysicalSize( areaModel.value.sizeW + ml, areaModel.value.sizeH + mt ); @@ -194,6 +185,7 @@ onUnmounted(() => { /> + 提示:使用物理坐标、尺寸