Skip to content

Commit 74e1024

Browse files
committed
fix: browser load fail after tauri shell adapter init
1 parent 52c6a80 commit 74e1024

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/phoenix/tauriShell.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*globals __TAURI__*/
20+
/*globals*/
21+
const TAURI = window.__TAURI__;
2122

2223
const TAURI_KEYS = {
2324
LAST_WINDOW_WIDTH: "tauri.LAST_WINDOW_WIDTH",
2425
LAST_WINDOW_HEIGHT: "tauri.LAST_WINDOW_HEIGHT"
2526
};
2627

27-
const appWindow = __TAURI__.window.appWindow;
28+
const appWindow = TAURI && TAURI.window.appWindow;
2829

2930
function _setupWindowResizeListeners() {
3031
appWindow.onResized(async ({ payload: size }) => {
@@ -40,7 +41,7 @@ async function positionWindow() {
4041
const phoenixAspectRatio = 1.6, // phoenix looks good in aspect ratio 1.6w:1h
4142
minWidth = 800,
4243
minHeight = 600;
43-
let monitorSize = (await __TAURI__.window.currentMonitor()).size,
44+
let monitorSize = (await TAURI.window.currentMonitor()).size,
4445
targetWindowHeight = monitorSize.height * 2/3,
4546
targetWindowWidth = targetWindowHeight * phoenixAspectRatio;
4647
let targetHeight = parseInt(localStorage.getItem(TAURI_KEYS.LAST_WINDOW_HEIGHT) || `${targetWindowHeight}`),
@@ -57,7 +58,7 @@ async function positionWindow() {
5758
if(targetWidth < minWidth){
5859
targetWidth = minWidth;
5960
}
60-
await appWindow.setSize(new __TAURI__.window.PhysicalSize(targetWidth, targetHeight));
61+
await appWindow.setSize(new TAURI.window.PhysicalSize(targetWidth, targetHeight));
6162
_setupWindowResizeListeners();
6263
}
6364

0 commit comments

Comments
 (0)