Need help working on my Linux store


#1

Hey guys I am working on a web store for Linux, I have been working on a website for it all and have been having issues with it in the desktop application I am making where it doesn’t render the website at all and looking in the console hardly shows any of the actual website code which is a Wix domain, does anyone have any ideas why this would happen?


#2

Hard to say without seeing both the code and the result.


#3

Show us the code. :eyes: :eyes: :eyes: :eyes:


#4

Sure here is the code of the application

and the index.html

and what happens when I open it in the application

as well as what it’s suppose to look like when viewed in chrome for example


#5

The code in index.html redirects the page to your “store”, why would you want to do that? Just do
mainWindow.loadURL('https://cdfrosty.wixsite.com/store') and let me know if it works.
And please read this


#6

The reason is for the splash screen I have for the application which uses a CSS file unless you know how I can combine the main.js code to use that css than redirect to the the page? I will try that out without it and see how it goes.

EDIT:

The page still doesn’t load


#7

You can use a BrowserWindow for splash screen and then load the main window using setTimeout maybe?

Oh dang.


#8

I see the example on it using a message but how would I make that do a redirect instead or show a image first then redirect? also what should I do about this issue?


#9

Try this:

mainWindow.loadURL('https://cdfrosty.wixsite.com/splashscreen.html') // Load splash screen

setTimeout(function () {
  mainWindow.loadURL('https://cdfrosty.wixsite.com/store')
}, 5000) // Load store page after 5 secs

#10

How could I set it to load just the index.html file instead but remove the redirect in the code or just use the CSS for the splash for it?

EDIT don’t worry figured it out, now to fix this rendering bug…


#11

Which version of electron are you on? Have you tried different versions? Maybe it’s a bug.


#12

The latest version 1.6.2, I have tried it many times in the past on older versions and it still has this issue.


#13

I peeked in the console and there was a lot of errors logged, maybe it’s a problem with Wix.


#14

Hmm yeah it might be, I got a question how do I set the size of a new window that opens like for example if I clicked on a link and it opens a window the window will be in I assume 800x600 but I would like to change that window size for all new windows opened


#15

The link would probably load in the same BrowserWindow it was clicked in, Listen to will-navigate and new-window events and open the link in a new BrowserWindow


#16

So if I added

myBrowserWindow.webContents.on(‘new-window’, (event, url) => {
event.preventDefault()
const win = new BrowserWindow({show: false})
win.once(‘ready-to-show’, () => win.show())
win.loadURL(url)
event.newGuest = win
})

it will set the new window size to the same size as the parent window?


#17

I’m not sure, probably not. Use .getSize() to get the parent window size and set the size of the child window to that.

EDIT: So the code would be:

myBrowserWindow.webContents.on('new-window', (event, url) => {
  event.preventDefault()
  let pSize = myBrowserWindow.getSize()
  const win = new BrowserWindow({show: false, width: pSize[0], height: pSize[1]})
  win.once('ready-to-show', () => win.show())
  win.loadURL(url)
  event.newGuest = win
})

I haven’t tried it, it should work but if it doesn’t let me know


#18

Where exactly do I place this snippet of code?


#19

Try pasting that after your createWindow() function


#20

I don’t have createWindow() function in my code

var app = require(‘electron’).app
var BrowserWindow = require(‘electron’).BrowserWindow
// Report crashes to our server.

// Keep a global reference of the window object, if you don’t, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

// Quit when all windows are closed.
app.on(‘window-all-closed’, function() {
if (process.platform != ‘darwin’)
app.quit();
});

// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on(‘ready’, function() {
// In the main process.
const {BrowserWindow} = require(‘electron’)

mainWindow = new BrowserWindow({width: 1350, height: 900,icon: __dirname + ‘/node_modules/icon.png’});
mainWindow.loadURL(‘file://’ + __dirname + ‘/node_modules/index.html’); // Load splash screen

setTimeout(function () {
mainWindow.loadURL(‘https://plus.google.com’)
}, 3000) // Load store page after 5 secs
// Emitted when the window is closed.
mainWindow.on(‘closed’, function() {
// Remove mainWindow.on(‘closed’, function() { if you want the menu back
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});

the code currently