trodi / electron-splashscreen

Simple splashscreen for electron applications.
MIT License
170 stars 29 forks source link

JavaScript implementation #28

Closed TechStudent10 closed 3 years ago

TechStudent10 commented 3 years ago

I tried to convert the code example in the README to JavaScript, but I cannot figure it out. Can someone please show me a JavaScript implementation?

trodi commented 3 years ago

@TechStudent11, I can't be sure what issue you are running in to. Typescript is just a superset of Javascript. Your Javascript will ultimately depend on the Javascript engine you are running on. The two main pieces are to remove all the type annotations and handle the imports correctly. Depending on the JS engine, you'll have access to different set of features.

You can look at the Javascript generated from the Typescript transpilation done on the example uses I provide. Here is a JS translation of the example Typescript.

// import the module
var Splashscreen = require("@trodi/electron-splashscreen");
const mainOpts = <... insert your options ...>
// configure the splashscreen
var config = {
    windowOpts: mainOpts;
    templateUrl: `${__dirname}/splash-screen.html`;
    splashScreenOpts: {
        width: 425,
        height: 325,
    },
};
// initialize the splashscreen handling
const main = Splashscreen.initSplashScreen(config);
// load your browser window per usual
main.loadURL(`file://index.html`);
TechStudent10 commented 3 years ago

@trodi thanks!