bug: fix build issues, fix datatypes
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { app, BrowserWindow, Tray, Menu, nativeImage } from 'electron';
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import * as dotenv from 'dotenv';
|
||||
import { setupIpcHandlers, cleanupIpcHandlers } from './ipc-handlers';
|
||||
import { initDatabase, closeDatabase } from './database';
|
||||
import { setupIpcHandlers, cleanupIpcHandlers } from './ipc-handlers.js';
|
||||
import { initDatabase, closeDatabase } from './database.js';
|
||||
|
||||
// ES module equivalent of __dirname
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// Load environment variables from .env file
|
||||
// In dev: __dirname = dist/main, so go up to electron-app root
|
||||
@@ -45,11 +50,13 @@ function createWindow(): void {
|
||||
frame: false,
|
||||
backgroundColor: '#0a0e27',
|
||||
icon: iconPath,
|
||||
show: false, // Don't show until loaded
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
sandbox: true,
|
||||
devTools: true, // Enable dev tools in production for debugging
|
||||
},
|
||||
title: 'rmtPocketWatcher',
|
||||
});
|
||||
@@ -58,13 +65,27 @@ function createWindow(): void {
|
||||
setupIpcHandlers(mainWindow);
|
||||
|
||||
// Load the app
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (isDev) {
|
||||
mainWindow.loadURL('http://localhost:5173');
|
||||
mainWindow.webContents.openDevTools();
|
||||
} else {
|
||||
mainWindow.loadFile(path.join(__dirname, '../../renderer/index.html'));
|
||||
const rendererPath = path.join(__dirname, '../renderer/index.html');
|
||||
console.log('Loading renderer from:', rendererPath);
|
||||
mainWindow.loadFile(rendererPath).catch(err => {
|
||||
console.error('Failed to load renderer:', err);
|
||||
});
|
||||
}
|
||||
|
||||
// Show window and open dev tools to see errors
|
||||
mainWindow.webContents.on('did-fail-load', (_event, errorCode, errorDescription) => {
|
||||
console.error('Failed to load:', errorCode, errorDescription);
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('did-finish-load', () => {
|
||||
console.log('Window loaded successfully');
|
||||
mainWindow?.show();
|
||||
});
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
cleanupIpcHandlers();
|
||||
mainWindow = null;
|
||||
@@ -95,6 +116,22 @@ function createTray(): void {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Open DevTools',
|
||||
click: () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Reload',
|
||||
click: () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
click: () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ipcMain, BrowserWindow } from 'electron';
|
||||
import { WebSocketClient } from './websocket-client';
|
||||
import { PriceIndex } from '../shared/types';
|
||||
import * as db from './database';
|
||||
import { WebSocketClient } from './websocket-client.js';
|
||||
import { PriceIndex } from '../shared/types.js';
|
||||
import * as db from './database.js';
|
||||
|
||||
let wsClient: WebSocketClient | null = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import WebSocket from 'ws';
|
||||
import { EventEmitter } from 'events';
|
||||
import { PriceIndex, WebSocketMessage, HistoricalData } from '../shared/types';
|
||||
import { PriceIndex, WebSocketMessage, HistoricalData } from '../shared/types.js';
|
||||
|
||||
export class WebSocketClient extends EventEmitter {
|
||||
private ws: WebSocket | null = null;
|
||||
|
||||
@@ -465,7 +465,7 @@ export function App() {
|
||||
<div style={{ flex: 1, backgroundColor: '#1a1f3a', padding: '15px', borderRadius: '8px' }}>
|
||||
<div style={{ fontSize: '12px', color: '#888', marginBottom: '5px' }}>LOWEST PRICE</div>
|
||||
<div style={{ fontSize: '24px', fontWeight: 'bold', color: '#50e3c2' }}>
|
||||
${latestPrice.lowestPrice.toFixed(4)}
|
||||
${latestPrice.lowestPrice.toFixed(9)}
|
||||
</div>
|
||||
<div style={{ fontSize: '12px', color: '#888' }}>per 1M AUEC</div>
|
||||
</div>
|
||||
@@ -552,7 +552,7 @@ export function App() {
|
||||
{alert.auecAmount.toLocaleString()} AUEC for ${alert.maxPrice.toFixed(2)}
|
||||
</div>
|
||||
<div style={{ fontSize: '12px', color: '#888' }}>
|
||||
${(alert.maxPrice / (alert.auecAmount / 1000000)).toFixed(4)} per 1M AUEC
|
||||
${(alert.maxPrice / (alert.auecAmount / 1000000)).toFixed(9)} per 1M AUEC
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '8px' }}>
|
||||
@@ -727,7 +727,7 @@ export function App() {
|
||||
}
|
||||
return label;
|
||||
}}
|
||||
formatter={(value: any, name: string) => [`$${Number(value).toFixed(4)}`, name]}
|
||||
formatter={(value: any, name: string) => [`$${Number(value).toFixed(9)}`, name]}
|
||||
wrapperStyle={{ zIndex: 1000 }}
|
||||
/>
|
||||
<Legend
|
||||
@@ -791,7 +791,7 @@ export function App() {
|
||||
<td style={{ padding: '12px' }}>{price.platform}</td>
|
||||
<td style={{ padding: '12px' }}>{price.sellerName}</td>
|
||||
<td style={{ textAlign: 'right', padding: '12px', color: '#50e3c2', fontWeight: 'bold' }}>
|
||||
${price.pricePerMillion.toFixed(4)}
|
||||
${price.pricePerMillion.toFixed(9)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user