fix(layout): 🐛 修复窗体高度整体变大bug

修复窗体高度整体变大bug
This commit is contained in:
ZOL4789 2024-10-21 22:27:32 +08:00
parent 33cc8bd8d7
commit 396a103a24
2 changed files with 29 additions and 25 deletions

View File

@ -1,7 +1,6 @@
use tauri::{LogicalSize, Manager, Runtime, WindowEvent};
use tauri_plugin_autostart::MacosLauncher;
pub trait CustomInit {
fn init_plugin(self) -> Self;
@ -14,15 +13,18 @@ impl<R: Runtime> CustomInit for tauri::Builder<R> {
// 初始化插件
fn init_plugin(self) -> Self {
self.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_websocket::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_upload::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1"])))
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_websocket::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_upload::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_autostart::init(
MacosLauncher::LaunchAgent,
Some(vec!["--flag1"]),
))
}
// 初始化web窗口事件
@ -42,21 +44,24 @@ impl<R: Runtime> CustomInit for tauri::Builder<R> {
.app_handle()
.get_webview_window("tray")
.unwrap()
.hide().unwrap();
.hide()
.unwrap();
}
if window.label() == "tray" && !flag {
window.hide().unwrap();
}
}
WindowEvent::Resized(ps) => {
let ls = ps.to_logical(window.scale_factor().unwrap());
// TODO 根据显示菜单模式不同,设定不同高度
let h = 495;
if ls.height < h {
window.set_size(LogicalSize::new(ls.width, h)).unwrap();
if window.label().eq("home") {
let ls = ps.to_logical(window.scale_factor().unwrap());
// TODO 根据显示菜单模式不同,设定不同高度
let h = 495;
if ls.height < h {
window.set_size(LogicalSize::new(ls.width, h)).unwrap();
}
}
}
_ => (),
})
}
}
}

View File

@ -224,14 +224,13 @@ const updateHoverClasses = () => {
onMounted(() => {
allPlugins.value = pluginsList.value.map((i) => {
const p = plugins.value.find((z) => z.title === i.title)
if (p) {
return {
...i,
state: p.state,
isAdd: p.isAdd
}
}
return i
return p
? {
...i,
state: p.state,
isAdd: p.isAdd
}
: i
})
updateHoverClasses()
window.addEventListener('click', closeMenu, true)