mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-27 20:17:17 +08:00
Fix: Web page has been loaded before Alas started
This commit is contained in:
@@ -2,6 +2,7 @@ import {app, BrowserWindow, ipcMain, globalShortcut} from 'electron';
|
|||||||
import {URL} from 'url';
|
import {URL} from 'url';
|
||||||
import {PyShell} from '/@/pyshell';
|
import {PyShell} from '/@/pyshell';
|
||||||
import {webuiArgs, webuiPath} from '/@/config';
|
import {webuiArgs, webuiPath} from '/@/config';
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const isSingleInstance = app.requestSingleInstanceLock();
|
const isSingleInstance = app.requestSingleInstanceLock();
|
||||||
@@ -100,7 +101,10 @@ const createWindow = async () => {
|
|||||||
alas.kill();
|
alas.kill();
|
||||||
setTimeout(() => mainWindow?.close(), 500); // Wait taskkill to finish
|
setTimeout(() => mainWindow?.close(), 500); // Wait taskkill to finish
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function loadURL() {
|
||||||
/**
|
/**
|
||||||
* URL for main window.
|
* URL for main window.
|
||||||
* Vite dev server for development.
|
* Vite dev server for development.
|
||||||
@@ -110,8 +114,21 @@ const createWindow = async () => {
|
|||||||
? import.meta.env.VITE_DEV_SERVER_URL
|
? import.meta.env.VITE_DEV_SERVER_URL
|
||||||
: new URL('../renderer/dist/index.html', 'file://' + __dirname).toString();
|
: new URL('../renderer/dist/index.html', 'file://' + __dirname).toString();
|
||||||
|
|
||||||
await mainWindow.loadURL(pageUrl);
|
mainWindow?.loadURL(pageUrl);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
alas.on('stderr', function (message: string) {
|
||||||
|
/**
|
||||||
|
* Receive logs, judge if Alas is ready
|
||||||
|
* For starlette backend, there will have:
|
||||||
|
* `INFO: Uvicorn running on http://0.0.0.0:22267 (Press CTRL+C to quit)`
|
||||||
|
*/
|
||||||
|
if (message.includes('running on')) {
|
||||||
|
alas.removeAllListeners('stderr');
|
||||||
|
loadURL()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
app.on('second-instance', () => {
|
app.on('second-instance', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user