mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2024-11-14 05:21:42 +08:00
bug(windows): hide cmd window and adjust size type
This commit is contained in:
parent
2c3a04bad3
commit
a1719ae8bf
@ -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
|
||||
|
@ -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())
|
||||
|
@ -31,8 +31,6 @@
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources":[
|
||||
"resource/*"
|
||||
]
|
||||
"resources": ["resource/*"]
|
||||
}
|
||||
}
|
||||
|
@ -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(() => {
|
||||
/>
|
||||
</NFormItemGi>
|
||||
</NGrid>
|
||||
<NP>提示:使用物理坐标、尺寸</NP>
|
||||
</NForm>
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user