Add ImEX Media Protocol Handler
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { electronApp, is, optimizer } from "@electron-toolkit/utils";
|
import { is, optimizer } from "@electron-toolkit/utils";
|
||||||
import Sentry from "@sentry/electron/main";
|
import Sentry from "@sentry/electron/main";
|
||||||
import {
|
import {
|
||||||
app,
|
app,
|
||||||
@@ -20,7 +20,6 @@ import {
|
|||||||
import ipcTypes from "../util/ipcTypes.json";
|
import ipcTypes from "../util/ipcTypes.json";
|
||||||
import ImportJob from "./decoder/decoder";
|
import ImportJob from "./decoder/decoder";
|
||||||
import LocalServer from "./http-server/http-server";
|
import LocalServer from "./http-server/http-server";
|
||||||
import { TestQB } from "./quickbooks-desktop/quickbooks-desktop";
|
|
||||||
import store from "./store/store";
|
import store from "./store/store";
|
||||||
import { GetAllEnvFiles } from "./watcher/watcher";
|
import { GetAllEnvFiles } from "./watcher/watcher";
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ Sentry.init({
|
|||||||
|
|
||||||
log.initialize();
|
log.initialize();
|
||||||
const isMac: boolean = process.platform === "darwin";
|
const isMac: boolean = process.platform === "darwin";
|
||||||
const protocol: string = "shopprt";
|
const protocol: string = "imexmedia";
|
||||||
let isAppQuitting = false; //Needed on Mac as an override to allow us to fully quit the app.
|
let isAppQuitting = false; //Needed on Mac as an override to allow us to fully quit the app.
|
||||||
// Initialize the server
|
// Initialize the server
|
||||||
const localServer = new LocalServer();
|
const localServer = new LocalServer();
|
||||||
@@ -147,18 +146,74 @@ function createWindow(): void {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Connect to Test",
|
label: "Development",
|
||||||
checked: store.get("app.isTest") as boolean,
|
id: "development",
|
||||||
visible: false,
|
visible: import.meta.env.DEV,
|
||||||
type: "checkbox",
|
submenu: [
|
||||||
id: "toggleTest",
|
{
|
||||||
click: (): void => {
|
label: "Connect to Test",
|
||||||
const currentSetting = store.get("app.isTest") as boolean;
|
checked: store.get("app.isTest") as boolean,
|
||||||
store.set("app.isTest", !currentSetting);
|
visible: false,
|
||||||
log.info("Setting isTest to: ", !currentSetting);
|
type: "checkbox",
|
||||||
app.relaunch(); // Relaunch the app
|
id: "toggleTest",
|
||||||
app.exit(0); // Exit the current instance
|
click: (): void => {
|
||||||
},
|
const currentSetting = store.get("app.isTest") as boolean;
|
||||||
|
store.set("app.isTest", !currentSetting);
|
||||||
|
log.info("Setting isTest to: ", !currentSetting);
|
||||||
|
app.relaunch(); // Relaunch the app
|
||||||
|
app.exit(0); // Exit the current instance
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Check for updates",
|
||||||
|
click: (): void => {
|
||||||
|
autoUpdater.checkForUpdates();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Open Log File",
|
||||||
|
click: (): void => {
|
||||||
|
/* action for item 1 */
|
||||||
|
shell.openPath(log.transports.file.getFile().path);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Clear Log",
|
||||||
|
click: (): void => {
|
||||||
|
log.transports.file.getFile().clear();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Open Config Folder",
|
||||||
|
click: (): void => {
|
||||||
|
shell.openPath(path.dirname(store.path));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Log the Store",
|
||||||
|
click: (): void => {
|
||||||
|
log.debug(
|
||||||
|
"Store Contents" + JSON.stringify(store.store, null, 4),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "separator",
|
||||||
|
},
|
||||||
|
|
||||||
|
// {
|
||||||
|
// label: "Decode Hardcoded Estimate",
|
||||||
|
// click: (): void => {
|
||||||
|
// ImportJob(`C:\\EMS\\CCC\\9ee762f4.ENV`);
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
label: "Add All Estimates in watched directories",
|
||||||
|
click: (): void => {
|
||||||
|
GetAllEnvFiles().forEach((file) => ImportJob(file));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -178,64 +233,6 @@ function createWindow(): void {
|
|||||||
: [{ role: "close" }]),
|
: [{ role: "close" }]),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
label: "Development",
|
|
||||||
submenu: [
|
|
||||||
{
|
|
||||||
label: "Check for updates",
|
|
||||||
click: (): void => {
|
|
||||||
autoUpdater.checkForUpdates();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Open Log Folder",
|
|
||||||
click: (): void => {
|
|
||||||
/* action for item 1 */
|
|
||||||
shell.openPath(log.transports.file.getFile().path);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Clear Log",
|
|
||||||
click: (): void => {
|
|
||||||
log.transports.file.getFile().clear();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Open Config",
|
|
||||||
click: (): void => {
|
|
||||||
shell.openPath(path.dirname(store.path));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Log the Store",
|
|
||||||
click: (): void => {
|
|
||||||
log.debug("Store Contents" + JSON.stringify(store.store, null, 4));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "separator",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Temp Test Action",
|
|
||||||
click: (): void => {
|
|
||||||
TestQB();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Decode Hardcoded Estimate",
|
|
||||||
click: (): void => {
|
|
||||||
ImportJob(`C:\\EMS\\CCC\\9ee762f4.ENV`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Add All Estimes in watched directories",
|
|
||||||
click: (): void => {
|
|
||||||
GetAllEnvFiles().forEach((file) => ImportJob(file));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const menu: Electron.Menu = Menu.buildFromTemplate(template);
|
const menu: Electron.Menu = Menu.buildFromTemplate(template);
|
||||||
@@ -249,8 +246,10 @@ function createWindow(): void {
|
|||||||
// Find the menu item dynamically by its id
|
// Find the menu item dynamically by its id
|
||||||
const fileMenu = template.find((item) => item.label === "Application");
|
const fileMenu = template.find((item) => item.label === "Application");
|
||||||
const hiddenItem = fileMenu?.submenu?.find(
|
const hiddenItem = fileMenu?.submenu?.find(
|
||||||
(item) => item.id === "toggleTest",
|
(item) => item.id === "development",
|
||||||
);
|
);
|
||||||
|
//Adjust the development menu as well.
|
||||||
|
|
||||||
if (hiddenItem) {
|
if (hiddenItem) {
|
||||||
hiddenItem.visible = true; // Update the visibility dynamically
|
hiddenItem.visible = true; // Update the visibility dynamically
|
||||||
const menu: Electron.Menu = Menu.buildFromTemplate(template);
|
const menu: Electron.Menu = Menu.buildFromTemplate(template);
|
||||||
@@ -311,9 +310,6 @@ if (!gotTheLock) {
|
|||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
// Set app user model id for windows
|
|
||||||
electronApp.setAppUserModelId("com.convenient-brands.partner");
|
|
||||||
|
|
||||||
// Default open or close DevTools by F12 in development
|
// Default open or close DevTools by F12 in development
|
||||||
// and ignore CommandOrControl + R in production.
|
// and ignore CommandOrControl + R in production.
|
||||||
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
||||||
@@ -334,8 +330,7 @@ app.whenReady().then(async () => {
|
|||||||
openMainWindow();
|
openMainWindow();
|
||||||
const url = argv.find((arg) => arg.startsWith(`${protocol}://`));
|
const url = argv.find((arg) => arg.startsWith(`${protocol}://`));
|
||||||
if (url) {
|
if (url) {
|
||||||
console.log("App launched with URL:", url);
|
openInExplorer(url);
|
||||||
// Handle the URL. Not doing anything for now.
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -419,15 +414,11 @@ app.whenReady().then(async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on(
|
app.on("open-url", (event: Electron.Event, url: string) => {
|
||||||
"open-url",
|
event.preventDefault();
|
||||||
(
|
//Don't do anything for now. We just want to open the app.
|
||||||
event: Electron.Event, //, _url: string
|
openInExplorer(url);
|
||||||
) => {
|
});
|
||||||
event.preventDefault();
|
|
||||||
//Don't do anythign for now. We just want to open the app.
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
// for applications and their menu bar to stay active until the user quits
|
// for applications and their menu bar to stay active until the user quits
|
||||||
@@ -461,3 +452,9 @@ function openMainWindow(): void {
|
|||||||
createWindow();
|
createWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openInExplorer(url: string): void {
|
||||||
|
const folderPath: string = decodeURIComponent(url.split(`${protocol}://`)[1]);
|
||||||
|
log.info("Opening folder in explorer", path.dirname(folderPath));
|
||||||
|
shell.openPath(path.dirname(folderPath));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user