Optimization window

This commit is contained in:
fanchenio 2023-11-07 10:33:42 +08:00
parent 80f1c40ad7
commit f6fe6c9558
9 changed files with 37 additions and 14 deletions

View File

@ -30,6 +30,7 @@ features = [
"Win32_System_Environment",
"Win32_UI_Input_Ime",
"Win32_Globalization",
"Win32_Graphics_Dwm",
]
[build-dependencies]

View File

@ -18,7 +18,6 @@ function createWindow() {
parent: global.mainWindow,
height: 212,
width: 600,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,

View File

@ -43,7 +43,6 @@ function createAddEditWindow(id: number | null, parentId: number | null) {
parent: global.mainWindow,
height: 174,
width: 400,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,
@ -108,7 +107,6 @@ function createSetIconWindow(id: number) {
parent: global.mainWindow,
height: 500,
width: 358,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,
@ -168,7 +166,6 @@ function createAssociateFolderWindow(id: number) {
parent: global.mainWindow,
height: 249,
width: 400,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,
@ -233,7 +230,6 @@ function createAggregateWindow(id: number) {
parent: global.mainWindow,
height: 144,
width: 400,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,

View File

@ -19,7 +19,6 @@ function createBackupRestoreDataWindow() {
parent: global.mainWindow,
height: 108,
width: 400,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,

View File

@ -51,7 +51,6 @@ async function createAddEditWindow(
parent: global.mainWindow,
height: 500,
width: 600,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,
@ -112,7 +111,6 @@ async function createNetworkIconWindow() {
parent: global.itemAddEditWindow,
height: 230,
width: 400,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,
@ -164,7 +162,6 @@ async function createSVGIconWindow() {
parent: global.itemAddEditWindow,
height: 230,
width: 400,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,

View File

@ -30,7 +30,6 @@ function createMainWindow() {
title: "Dawn Launcher",
width: 800,
height: 600,
type: "toolbar",
frame: false,
show: false,
maximizable: false,
@ -56,6 +55,10 @@ function createMainWindow() {
}
// 加载完毕
mainWindow.webContents.on("did-finish-load", () => {
// 设置窗口无动画
global.addon.removeWindowAnimation(
mainWindow.getNativeWindowHandle().readInt32LE(0)
);
// 恢复上一次的位置
let bounds = cacheData.cacheStore.get("mainWindowBounds");
if (bounds) {

View File

@ -28,7 +28,6 @@ function createSettingWindow() {
parent: global.mainWindow,
height: 500,
width: 600,
type: "toolbar",
maximizable: false,
minimizable: false,
resizable: false,

View File

@ -165,3 +165,12 @@ pub fn get_clipboard_bitmap_base64() -> Option<String> {
pub fn empty_recycle_bin(window: i32) {
windows::empty_recycle_bin(window)
}
/**
*
*/
#[allow(dead_code)]
#[napi]
pub fn remove_window_animation(window: i32) {
windows::remove_window_animation(window);
}

View File

@ -18,9 +18,12 @@ use windows::{
w,
Win32::{
Foundation::{HWND, LPARAM, LRESULT, MAX_PATH, POINT, RECT, SIZE, WPARAM},
Graphics::Gdi::{
GetMonitorInfoW, GetObjectW, MonitorFromWindow, BITMAP, MONITORINFO,
MONITOR_DEFAULTTONEAREST,
Graphics::{
Dwm::{DwmSetWindowAttribute, DWMWA_TRANSITIONS_FORCEDISABLED},
Gdi::{
GetMonitorInfoW, GetObjectW, MonitorFromWindow, BITMAP, MONITORINFO,
MONITOR_DEFAULTTONEAREST,
},
},
Storage::FileSystem::SearchPathW,
System::{
@ -671,3 +674,20 @@ pub fn empty_recycle_bin(window: i32) {
let _ = SHEmptyRecycleBinW(hwnd, None, SHERB_NOSOUND);
};
}
/**
*
*/
pub fn remove_window_animation(window: i32) {
// HWND
let hwnd = HWND(window as isize);
let pvattribute = &mut true as *mut _ as *const _;
unsafe {
let _ = DwmSetWindowAttribute(
hwnd,
DWMWA_TRANSITIONS_FORCEDISABLED,
pvattribute,
std::mem::size_of_val(&pvattribute) as u32,
);
};
}