chore: linting
This commit is contained in:
@@ -459,9 +459,10 @@ export default class App extends Vue {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverSubscription = typeof subscription === "object" && subscription !== null
|
const serverSubscription =
|
||||||
? { ...subscription }
|
typeof subscription === "object" && subscription !== null
|
||||||
: {};
|
? { ...subscription }
|
||||||
|
: {};
|
||||||
if (!allGoingOff) {
|
if (!allGoingOff) {
|
||||||
serverSubscription["notifyType"] = notification.title;
|
serverSubscription["notifyType"] = notification.title;
|
||||||
logger.log(
|
logger.log(
|
||||||
|
|||||||
@@ -1,35 +1,59 @@
|
|||||||
import { app, BrowserWindow, ipcMain } from "electron";
|
import { app, BrowserWindow, ipcMain } from "electron";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { CapacitorSQLiteElectron } from '@capacitor-community/sqlite/electron/dist/plugin';
|
import { CapacitorSQLiteElectron } from "@capacitor-community/sqlite/electron/dist/plugin";
|
||||||
|
|
||||||
// Initialize SQLite plugin for Electron
|
|
||||||
const sqlitePlugin = new CapacitorSQLiteElectron();
|
|
||||||
|
|
||||||
// Set up IPC handler for SQLite
|
|
||||||
ipcMain.handle('capacitor-sqlite', async (_event, ...args) => {
|
|
||||||
return sqlitePlugin.handle(_event, ...args);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize SQLite when app is ready
|
|
||||||
app.whenReady().then(() => {
|
|
||||||
createWindow();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Simple logger implementation
|
// Simple logger implementation
|
||||||
const logger = {
|
const logger = {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
log: (...args: unknown[]) => console.log(...args),
|
log: (...args: unknown[]) => console.log("[Main]", ...args),
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
error: (...args: unknown[]) => console.error(...args),
|
error: (...args: unknown[]) => console.error("[Main]", ...args),
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
info: (...args: unknown[]) => console.info(...args),
|
info: (...args: unknown[]) => console.info("[Main]", ...args),
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
warn: (...args: unknown[]) => console.warn(...args),
|
warn: (...args: unknown[]) => console.warn("[Main]", ...args),
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
debug: (...args: unknown[]) => console.debug(...args),
|
debug: (...args: unknown[]) => console.debug("[Main]", ...args),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Initialize SQLite plugin for Electron
|
||||||
|
let sqlitePlugin: CapacitorSQLiteElectron | null = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.info("Initializing SQLite plugin...");
|
||||||
|
sqlitePlugin = new CapacitorSQLiteElectron();
|
||||||
|
logger.info("SQLite plugin initialized successfully");
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Failed to initialize SQLite plugin:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up IPC handler for SQLite
|
||||||
|
ipcMain.handle("capacitor-sqlite", async (_event, ...args) => {
|
||||||
|
if (!sqlitePlugin) {
|
||||||
|
const error = new Error("SQLite plugin not initialized");
|
||||||
|
logger.error(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.debug("Handling SQLite request:", args);
|
||||||
|
const result = await sqlitePlugin.handle(_event, ...args);
|
||||||
|
logger.debug("SQLite request completed successfully");
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("SQLite request failed:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize app when ready
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
logger.info("App is ready, creating window...");
|
||||||
|
createWindow();
|
||||||
|
});
|
||||||
|
|
||||||
// Check if running in dev mode
|
// Check if running in dev mode
|
||||||
const isDev = process.argv.includes("--inspect");
|
const isDev = process.argv.includes("--inspect");
|
||||||
|
|
||||||
@@ -38,7 +62,7 @@ function createWindow(): void {
|
|||||||
const preloadPath = app.isPackaged
|
const preloadPath = app.isPackaged
|
||||||
? path.join(process.resourcesPath, "preload.js")
|
? path.join(process.resourcesPath, "preload.js")
|
||||||
: path.join(__dirname, "preload.js");
|
: path.join(__dirname, "preload.js");
|
||||||
|
|
||||||
logger.log("[Electron] Preload path:", preloadPath);
|
logger.log("[Electron] Preload path:", preloadPath);
|
||||||
logger.log("[Electron] Preload exists:", fs.existsSync(preloadPath));
|
logger.log("[Electron] Preload exists:", fs.existsSync(preloadPath));
|
||||||
|
|
||||||
@@ -133,11 +157,15 @@ function createWindow(): void {
|
|||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
// In production, files are inside the asar archive or extraResources
|
// In production, files are inside the asar archive or extraResources
|
||||||
indexPath = path.join(process.resourcesPath, "www", "index.html");
|
indexPath = path.join(process.resourcesPath, "www", "index.html");
|
||||||
logger.info("[Electron] App is packaged. Using process.resourcesPath for index.html");
|
logger.info(
|
||||||
|
"[Electron] App is packaged. Using process.resourcesPath for index.html",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// In dev, use the local path
|
// In dev, use the local path
|
||||||
indexPath = path.resolve(__dirname, "www", "index.html");
|
indexPath = path.resolve(__dirname, "www", "index.html");
|
||||||
logger.info("[Electron] App is not packaged. Using __dirname for index.html");
|
logger.info(
|
||||||
|
"[Electron] App is not packaged. Using __dirname for index.html",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("[Electron] Resolved index.html path:", indexPath);
|
logger.info("[Electron] Resolved index.html path:", indexPath);
|
||||||
@@ -150,7 +178,9 @@ function createWindow(): void {
|
|||||||
|
|
||||||
// Removed fs.existsSync check to allow Electron to attempt loading regardless
|
// Removed fs.existsSync check to allow Electron to attempt loading regardless
|
||||||
|
|
||||||
logger.info("[Electron] Attempting to load index.html via mainWindow.loadFile");
|
logger.info(
|
||||||
|
"[Electron] Attempting to load index.html via mainWindow.loadFile",
|
||||||
|
);
|
||||||
mainWindow
|
mainWindow
|
||||||
.loadFile(indexPath)
|
.loadFile(indexPath)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -165,9 +195,14 @@ function createWindow(): void {
|
|||||||
logger.error("[Electron] Attempted path:", indexPath);
|
logger.error("[Electron] Attempted path:", indexPath);
|
||||||
try {
|
try {
|
||||||
const exists = fs.existsSync(indexPath);
|
const exists = fs.existsSync(indexPath);
|
||||||
logger.error(`[Electron] fs.existsSync after loadFile error: ${exists}`);
|
logger.error(
|
||||||
|
`[Electron] fs.existsSync after loadFile error: ${exists}`,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("[Electron] Error checking fs.existsSync after loadFile error:", e);
|
logger.error(
|
||||||
|
"[Electron] Error checking fs.existsSync after loadFile error:",
|
||||||
|
e,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { initializeApp } from "./main.common";
|
import { initializeApp } from "./main.common";
|
||||||
import { logger } from "./utils/logger";
|
import { logger } from "./utils/logger";
|
||||||
import { Capacitor } from '@capacitor/core';
|
import { Capacitor } from "@capacitor/core";
|
||||||
import { CapacitorSQLite } from '@capacitor-community/sqlite';
|
import { CapacitorSQLite } from "@capacitor-community/sqlite";
|
||||||
|
|
||||||
// Initialize Capacitor for Electron
|
// Initialize Capacitor for Electron
|
||||||
Object.defineProperty(Capacitor, 'isNativePlatform', {
|
Object.defineProperty(Capacitor, "isNativePlatform", {
|
||||||
get: () => true,
|
get: () => true,
|
||||||
configurable: true
|
configurable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize SQLite plugin for Electron
|
// Initialize SQLite plugin for Electron
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== "undefined") {
|
||||||
// Register the plugin globally
|
// Register the plugin globally
|
||||||
window.CapacitorSQLite = CapacitorSQLite;
|
window.CapacitorSQLite = CapacitorSQLite;
|
||||||
logger.info("[Electron] SQLite plugin initialized in native mode");
|
logger.info("[Electron] SQLite plugin initialized in native mode");
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class ElectronPlatformService implements PlatformService {
|
|||||||
false,
|
false,
|
||||||
"no-encryption",
|
"no-encryption",
|
||||||
1,
|
1,
|
||||||
true // Use native implementation
|
true, // Use native implementation
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.db.open();
|
await this.db.open();
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ export default defineConfig(async ({ mode }) => {
|
|||||||
main: path.resolve(__dirname, 'src/electron/main.ts'),
|
main: path.resolve(__dirname, 'src/electron/main.ts'),
|
||||||
preload: path.resolve(__dirname, 'src/electron/preload.js'),
|
preload: path.resolve(__dirname, 'src/electron/preload.js'),
|
||||||
},
|
},
|
||||||
external: ['electron'],
|
external: [
|
||||||
|
'electron',
|
||||||
|
'@capacitor-community/sqlite',
|
||||||
|
'@capacitor-community/sqlite/electron',
|
||||||
|
'better-sqlite3-multiple-ciphers'
|
||||||
|
],
|
||||||
output: {
|
output: {
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
entryFileNames: '[name].js',
|
entryFileNames: '[name].js',
|
||||||
|
|||||||
Reference in New Issue
Block a user