Skip to content

Commit

Permalink
Fixed Window Size (v1.1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
inulute committed Dec 14, 2023
1 parent e502946 commit cc56857
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
62 changes: 46 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { BrowserWindow } = require("electron");

exports.createBrowserWindow = () => {
return new BrowserWindow({
width: 1024,
width: 1000,
height: 768,
minWidth: 400,
minHeight: 600,
Expand Down

0 comments on commit cc56857

Please sign in to comment.