From cc56857d353b5f483d7f9a565190224b42513cc9 Mon Sep 17 00:00:00 2001 From: inulute <110729127+inulute@users.noreply.github.com> Date: Thu, 14 Dec 2023 21:49:38 +0530 Subject: [PATCH] Fixed Window Size (v1.1.0) --- main.js | 62 ++++++++++++++++++++++++++++++++++++++------------- package.json | 2 +- src/view.js | 2 +- src/window.js | 2 +- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/main.js b/main.js index 8e4f2db..18993c4 100644 --- a/main.js +++ b/main.js @@ -1,28 +1,58 @@ const { app, BrowserWindow, dialog } = require("electron"); +const path = require("path"); app.allowRendererProcessReuse = true; + +let mainWindow; +let dialogWindow; + app.on("ready", () => { - const mainWindow = new BrowserWindow(); + const window = require("./src/window"); + mainWindow = window.createBrowserWindow(app); mainWindow.setMenu(null); - // Load HTTPS URLs - const promptObject = { - type: "question", - title: "Choose an AI to navigate", - message: "Choose an AI to navigate:", - buttons: ["Perplexity AI: AI Search", "Labs Perplexity AI: AI Chat"], + const createCustomDialog = () => { + dialogWindow = new BrowserWindow({ + parent: mainWindow, + modal: true, + show: false, + width: 400, + height: 570, + backgroundColor: "#272829", + webPreferences: { + preload: path.join(__dirname, "preload.js"), + nodeIntegration: false, + contextIsolation: true, + }, + }); + + // Load HTTPS URLs + const promptObject = { + type: "question", + title: "Choose an AI to navigate", + message: "Choose an AI to navigate:", + buttons: ["Perplexity AI: AI Search", "Labs Perplexity AI: AI Chat"], + }; + + dialog.showMessageBox(mainWindow, promptObject) + .then((response) => { + const chosenWebsite = promptObject.buttons[response.response]; + if (chosenWebsite === "Perplexity AI: AI Search") { + mainWindow.loadURL("https://perplexity.ai"); + } else if (chosenWebsite === "Labs Perplexity AI: AI Chat") { + mainWindow.loadURL("https://labs.perplexity.ai"); + } + }) + .catch((error) => { + console.error(error); + }); }; - dialog.showMessageBox(mainWindow, promptObject).then((response) => { - const chosenWebsite = promptObject.buttons[response.response]; - if (chosenWebsite === "Perplexity AI: AI Search") { - mainWindow.loadURL("https://perplexity.ai"); - } else if (chosenWebsite === "Labs Perplexity AI: AI Chat") { - mainWindow.loadURL("https://labs.perplexity.ai"); - } - }); + // Load dialog window on app ready + createCustomDialog(); + + // Rest of your code... - const print = require("./src/print"); }); app.on("window-all-closed", () => { diff --git a/package.json b/package.json index d6953cc..8a0f609 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "perplexity-ai-app", "productName": "Perplexity AI", - "version": "1.0.0", + "version": "1.1.0", "description": "Perplexity AI desktop application built with Electron.", "main": "main.js", "scripts": { diff --git a/src/view.js b/src/view.js index e220ddb..5353362 100644 --- a/src/view.js +++ b/src/view.js @@ -3,7 +3,7 @@ const { BrowserView } = require("electron"); exports.createBrowserView = (mainWindow) => { const view = new BrowserView(); mainWindow.setBrowserView(view); - view.setBounds({ x: 0, y: 0, width: 1024, height: 768 }); + view.setBounds({ x: 0, y: 0, width: 1000, height: 768 }); // Get the selected website from the dropdown menu const selectedWebsite = mainWindow.webContents.getViewById("websiteDropdown").value; diff --git a/src/window.js b/src/window.js index ea7f860..7cd1ec4 100644 --- a/src/window.js +++ b/src/window.js @@ -3,7 +3,7 @@ const { BrowserWindow } = require("electron"); exports.createBrowserWindow = () => { return new BrowserWindow({ - width: 1024, + width: 1000, height: 768, minWidth: 400, minHeight: 600,