Configuration file Package.json
NW When starting the application, first to read the Package.json file, initialize the basic properties, let us look at the full parameters of Package.json. Each parameter configuration is marked with a comment.
[Plain]View PlainCopy
- {
- /** Specifies the start page of the program. */
- "Main": "Index.html",
- The/** string must be a lowercase letter or a number that can contain. Or _ or-no spaces are allowed. Name must be globally unique. */
- "Name": "Demo",
- /** Program Description */
- "description": "Demo app of Node-webkit",
- /** Program Version number */
- "Version": "0.1.0",
- /** keywords */
- "keywords": ["Demo", "Node-webkit"],
- The/**bool value, if set to False, disables the WebKit node support. */
- "Nodejs": true,
- /**
- * Specify a node. js file that will be run when the program starts, and the boot time is earlier than Node-webkit loading HTML.
- * It runs in the node context and can be used to implement functions like a background thread.
- * (no need to annotate)
- */
- "Node-main": "Js/node.js",
- /**
- * BOOL value. By default, if you package a Node-webkit program for publishing, you can only start an instance of the app.
- * Set this value to False if you want to allow multiple instances to be started at the same time.
- */
- "Single-instance": true,
- /** Window Property Settings */
- "Window": {
- /** string, sets the default title. */
- "Title": "Demo",
- Icon for the/** window. */
- "Icon": "Link.png",
- The/**bool value. Whether to display the navigation bar. */
- "Toolbar": false,
- The/**bool value. Whether to allow resizing of the window. */
- "Resizable": true,
- /** is full screen */
- "fullscreen": false,
- /** If the icon is displayed in the WIN task bar */
- "Show_in_taskbar": true,
- The/**bool value. If set to False, the program will display without Borders. */
- "Frame": true,
- The/** string. The position of the window when it is opened can be set to "null", "center", or "mouse". */
- "Position": "Center",
- /** the width of the main window. */
- "width": 800,
- /** the height of the main window. */
- "Height": 670,
- The minimum width of the/** window. */
- "Min_width": 400,
- The minimum height of the/** window. */
- "Min_height": 335,
- The/** window displays the maximum width, which is not set. */
- "Max_width": 800,
- /** the maximum height displayed by the window is not set. */
- "Max_height": 670,
- The/**bool value, if set to false, when the window is not visible at startup. */
- "Show": true,
- /** whether the icon is displayed on the taskbar. */
- "Show_in_taskbar": true,
- /**
- * BOOL value. Whether to use Kiosk mode. If kiosk mode is used,
- * The app will display full screen and prevent users from leaving the app.
- * */
- "Kiosk": false
- },
- /**webkit Settings */
- "WebKit": {
- /**bool value, whether the plug-in is loaded, such as Flash, the default value is False. */
- "Plugin": true,
- /**bool value, whether Java applets is loaded, default is False. */
- "Java": false,
- /**bool value, whether page caching is enabled, false by default. */
- "Page-cache": false
- }
- }
In the above configuration, main and name are required properties. Other simple and straightforward to read the comments directly, Bo main talk about a few more difficult to understand the parameters configuration.
(1) "Node-main" configuration: Specify a JS file, the JS file is the first to run the program when the file, in the Node-main script can also access the global "Window" object, which points to the Dom window, but if the page navigation has changed, The Window object accessed is also changed. Because it executes before the DOM is loaded, the "window" object cannot be used until the page has finished loading. Also, in the DOM page, you can get node-main information through Process.mainmodule.
(2) "single-instance" configuration: Simply speaking, whether to allow multiple NW applications to be opened at the same time.
(3) "Kiosk" configuration: If the configuration is set to Ture, it is displayed in full screen mode and the block off button, that is, the display will remain in the NW application display interface, similar to the bank queue waiting for business of the ticket machine interface.
NWJS configuration file Package.json reprint