mirror of
https://github.com/HuLaSpark/HuLa.git
synced 2026-09-24 23:11:59 +08:00
feat(view): ✨ 保持窗口位置和大小 (#287)
* feat(view): ✨ 保持窗口位置和大小 * fix(view): 🐛 修复窗口时短暂白屏 --------- Co-authored-by: Dawn <2439646234@qq.com>
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
"@tauri-apps/plugin-shell": "^2.2.1",
|
||||
"@tauri-apps/plugin-sql": "^2.2.0",
|
||||
"@tauri-apps/plugin-updater": "2.7.1",
|
||||
"@tauri-apps/plugin-window-state": "^2.2.2",
|
||||
"colorthief": "^2.6.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.11",
|
||||
|
||||
Generated
+16
@@ -2243,6 +2243,7 @@ dependencies = [
|
||||
"tauri-plugin-sql",
|
||||
"tauri-plugin-updater",
|
||||
"tauri-plugin-upload",
|
||||
"tauri-plugin-window-state",
|
||||
"tokio",
|
||||
"tungstenite",
|
||||
]
|
||||
@@ -6008,6 +6009,21 @@ dependencies = [
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-window-state"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a27a3fe49de72adbe0d84aee33c89a0b059722cd0b42aaeab29eaaee7f7535cd"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime"
|
||||
version = "2.6.0"
|
||||
|
||||
@@ -72,6 +72,9 @@ rand = "0.8.5"
|
||||
cocoa = "0.26.0"
|
||||
objc = "0.2.7"
|
||||
|
||||
[target."cfg(any(target_os = \"macos\", target_os = \"windows\", target_os = \"linux\"))".dependencies]
|
||||
tauri-plugin-window-state = "2.2.2"
|
||||
|
||||
[features]
|
||||
# by default Tauri runs in production mode
|
||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is a URL
|
||||
|
||||
@@ -91,6 +91,9 @@
|
||||
"notification:allow-delete-channel",
|
||||
"notification:allow-create-channel",
|
||||
"notification:allow-permission-state",
|
||||
"window-state:allow-filename",
|
||||
"window-state:allow-restore-state",
|
||||
"window-state:allow-save-window-state",
|
||||
{
|
||||
"identifier": "shell:allow-execute",
|
||||
"allow": [
|
||||
|
||||
@@ -47,6 +47,8 @@ fn setup_desktop() {
|
||||
.init_window_event()
|
||||
.setup(move |app| {
|
||||
tray::create_tray(app.handle())?;
|
||||
#[cfg(desktop)]
|
||||
let _ = app.handle().plugin(tauri_plugin_window_state::Builder::default().build());
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
|
||||
@@ -358,6 +358,7 @@ onMounted(async () => {
|
||||
// 监听home窗口被聚焦的事件,当窗口被聚焦时自动关闭状态栏通知
|
||||
const homeWindow = await WebviewWindow.getByLabel('home')
|
||||
if (homeWindow) {
|
||||
homeWindow.show()
|
||||
homeWindow.onFocusChanged(({ payload: focused }) => {
|
||||
// 当窗口获得焦点时,关闭通知提示
|
||||
if (focused) {
|
||||
|
||||
@@ -406,7 +406,7 @@ const normalLogin = async (auto = false) => {
|
||||
}
|
||||
|
||||
const openHomeWindow = async () => {
|
||||
await createWebviewWindow('HuLa', 'home', 960, 720, 'login', true, undefined, 480)
|
||||
await createWebviewWindow('HuLa', 'home', 960, 720, 'login', true, undefined, 480, undefined, false)
|
||||
}
|
||||
|
||||
/** 移除已登录账号 */
|
||||
|
||||
Reference in New Issue
Block a user