1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

fix: if webcontents with id 1 not found use first webcontents

This commit is contained in:
Bagus Indrayana
2025-04-28 11:47:20 +08:00
parent 6c9792f512
commit b3cf20101b
2 changed files with 1219 additions and 454 deletions

1667
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,8 @@ export type LoggerLevel = 'query' | 'error'
export const ipcLogger = ({ content, cUid, level }: {content: string; cUid: string; level: LoggerLevel}) => {
if (level === 'error') {
if (process.type !== undefined) {
const mainWindow = require('electron').webContents.fromId(1);
const contents = require('electron').webContents.getAllWebContents();
const mainWindow = require('electron').webContents.fromId(1) ?? contents[0];
mainWindow.send('non-blocking-exception', { cUid, message: content, date: new Date() });
}
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(content);
@@ -12,7 +13,8 @@ export const ipcLogger = ({ content, cUid, level }: {content: string; cUid: stri
// Remove comments, newlines and multiple spaces
const escapedSql = content.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '').replace(/\s\s+/g, ' ');
if (process.type !== undefined) {
const mainWindow = require('electron').webContents.fromId(1);
const contents = require('electron').webContents.getAllWebContents();
const mainWindow = require('electron').webContents.fromId(1) ?? contents[0];
mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() });
}
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(escapedSql);