coreybutler / fenix

A simple and visual static web server with collaboration features.
https://preview.fenixwebserver.com
GNU General Public License v3.0
1.65k stars 135 forks source link

How make splash screen from a package nw or not unpackaged all #60

Closed estvmachine closed 9 years ago

estvmachine commented 9 years ago

Hi, im here because of this issue: https://github.com/nwjs/nw.js/issues/151.

I'm trying to do a splash screen for my app constucted in node.js and packaged in nodewebkit, my question is how you do it?. I read you dont unpackaged all. Thanks thats all!

coreybutler commented 9 years ago

Hi @estvmachine -

High Level

I didn't use the packaging option with node-webkit because it took way too long to unpackage and display everything. Instead, my installer just extracts everything so node-webkit doesn't have to extract it every time it opens. To mimic a splash screen, I launch a hidden window that triggers everything else. The hidden window first launches a splash screen, then it launches the main application and waits until it is loaded. Once it's loaded, it removes the splash screen and shows the app.

Detail

First, you need to make sure your package.json options have show: false, which you can see in the Fenix package.json file. Notice line 2 of that same file, which launches index.html. index.html runs, but is not displayed... i.e. mimicking a background process.

The index.html file is incredibly simple. It includes a single bootstrap JS file, which is where the real magic happens. My file is a slightly more complicated than what most apps need, but the relevant code is here. Launching the splash screen is very quick because there isn't much in it and the app is unpackaged. I just use a CSS animation as a loading screen with some text on the screen. So that's how to mimic a splash screen.

Next, the main application is launched as another window. Once it is ready, the splash screen is closed. Again, my code is a little more verbose than most apps, but I accomplish this in lines 122-156 of the same JS file.

I hope that helps, and good luck!

estvmachine commented 9 years ago

Sorry man, dont work for me :(, maybe in other moment i try again. The code is clean at least. Thanks! and good luck!