Skip to content

Commit

Permalink
Revert on_page_load
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxianqiao committed Jun 29, 2022
1 parent 72016b4 commit 894342e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/tauriapp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "app"
version = "0.1.1"
version = "1.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
Expand Down
3 changes: 2 additions & 1 deletion packages/tauriapp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate objc;

#[cfg(target_os = "macos")]
use tauri::Menu;
use tauri::{generate_handler, Manager};
use tauri::{generate_handler, Manager, Window};
#[cfg(target_os = "macos")]
use window_ext::WindowExt;

Expand Down Expand Up @@ -45,6 +45,7 @@ fn main() {
// main_window.open_devtools();
Ok(())
})
.on_page_load(|w: Window, _| w.get_window("main").unwrap().show().unwrap())
.plugin(preload::PreloadPlugin::new())
.invoke_handler(generate_handler![play_sound, set_badge])
.run(context)
Expand Down
28 changes: 14 additions & 14 deletions packages/tauriapp/src/window_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ impl WindowExt for Window {
unsafe {
let id = self.ns_window().unwrap() as cocoa::base::id;

let color = NSColor::colorWithSRGBRed_green_blue_alpha_(nil, 0.0, 0.0, 0.0, 1.0);
let _: cocoa::base::id = msg_send![id, setBackgroundColor: color];

// https://github.com/tauri-apps/tauri/issues/1564
// https://github.com/tauri-apps/wry/blob/765fe5ae413a1c13ad99802b49f3af859a2445d5/src/webview/macos/mod.rs#L180
self.with_webview(|webview| {
// !!! has delay
let id = webview.inner();
let no: cocoa::base::id = msg_send![class!(NSNumber), numberWithBool:0];
let _: cocoa::base::id =
msg_send![id, setValue:no forKey: NSString::alloc(nil).init_str("drawsBackground")];
})
.ok();

let mut style_mask = id.styleMask();
style_mask.set(
NSWindowStyleMask::NSFullSizeContentViewWindowMask,
Expand Down Expand Up @@ -47,20 +61,6 @@ impl WindowExt for Window {

// https://github.com/tauri-apps/tauri/issues/2663#issuecomment-1151240533
id.setToolbar_(msg_send![class!(NSToolbar), new]);

// https://github.com/tauri-apps/tauri/issues/1564
// https://github.com/tauri-apps/wry/blob/765fe5ae413a1c13ad99802b49f3af859a2445d5/src/webview/macos/mod.rs#L180
self
.with_webview(|webview| {
let id = webview.inner();
let no: cocoa::base::id = msg_send![class!(NSNumber), numberWithBool:0];
let _: cocoa::base::id =
msg_send![id, setValue:no forKey: NSString::alloc(nil).init_str("drawsBackground")];
})
.ok();

let color = NSColor::colorWithSRGBRed_green_blue_alpha_(nil, 0.0, 0.0, 0.0, 1.0);
let _: cocoa::base::id = msg_send![id, setBackgroundColor: color];
}
}
}
5 changes: 1 addition & 4 deletions packages/tauriapp/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"package": {
"productName": "NESBox",
"version": "0.1.2"
"version": "1.0.0"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -60,11 +60,8 @@
},
"windows": [
{
"title": "NESBox",
"width": 1024,
"height": 640,
"fullscreen": false,
"resizable": true,
"visible": true
}
]
Expand Down
11 changes: 11 additions & 0 deletions packages/tauriapp/tauri.macos.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"tauri": {
"windows": [
{
"width": 1024,
"height": 640,
"visible": false
}
]
}
}

0 comments on commit 894342e

Please sign in to comment.