Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为节点webkit创建加载屏幕?_Javascript_Node Webkit_Nw.js - Fatal编程技术网

Javascript 如何为节点webkit创建加载屏幕?

Javascript 如何为节点webkit创建加载屏幕?,javascript,node-webkit,nw.js,Javascript,Node Webkit,Nw.js,我已经创建了一个桌面应用程序,但在单击.exe后需要很长时间才能加载。有没有办法显示加载屏幕。我正在寻找一个解决方案,但我没有得到一个。 < P>当你的主应用程序屏幕正在加载时,显示一个加载屏幕或一个飞溅屏幕,考虑以下步骤: 在主窗口设置为“隐藏”的情况下启动应用程序 由于主窗口是隐藏的,请打开另一个窗口,该窗口将充当启动屏幕或加载屏幕 当主应用程序完全加载并准备就绪后,关闭启动屏幕窗口并显示隐藏的主窗口 步骤1在主窗口隐藏的情况下启动应用程序: 在窗口中设置窗口属性的show:false “

我已经创建了一个桌面应用程序,但在单击
.exe
后需要很长时间才能加载。有没有办法显示加载屏幕。我正在寻找一个解决方案,但我没有得到一个。

< P>当你的主应用程序屏幕正在加载时,显示一个加载屏幕或一个飞溅屏幕,考虑以下步骤:

  • 在主窗口设置为“隐藏”的情况下启动应用程序
  • 由于主窗口是隐藏的,请打开另一个窗口,该窗口将充当启动屏幕或加载屏幕
  • 当主应用程序完全加载并准备就绪后,关闭启动屏幕窗口并显示隐藏的主窗口

  • 步骤1在主窗口隐藏的情况下启动应用程序:

    在窗口中设置窗口属性的
    show:false

    “show”:false
    属性在应用程序启动时不会显示主窗口

    步骤2打开加载或飞溅窗口:

    在index.html中编写一个脚本,它将打开另一个窗口,作为启动屏幕

    var guiWin = require('nw.gui');   
    this.splashScreen = guiWin.open('path/to/splash.html', {
                    "transparent": true,
                    'frame': false,
                    "icon": "path/to/icon.png",
                    'position': 'center',
                    'always-on-top': true,
                    "width": 475,
                    "height": 250,
                    "resizable": false,
                    "toolbar": false,
                    "fullscreen": false
                });
    
    步骤3。当应用程序准备就绪时,关闭启动屏幕并显示主窗口:

    当主应用程序完全加载后,可以通过调用此方法关闭启动窗口并显示主窗口

    function hideSplash() {
        this._splashScreen.close(true);
        guiWin.get().show();            // get the current window and show
        this.splashScreen = null;            
    }
    

    谢谢你的回复。!!!但它不起作用,因为我的应用程序包含一些接近1GB的资产文件夹。加载index.html本身需要时间。我想在这之后,只有它会执行步骤2。我的包裹太重了。由于某些内容安全性,我将我的资产文件夹保存在.exe中。我不知道如何克服这个问题是nwjs加载index.html太晚了,还是加载所有资源太晚了?您是否可以尝试在中编写该脚本,以便它首先打开新窗口,然后加载其他资源
    function hideSplash() {
        this._splashScreen.close(true);
        guiWin.get().show();            // get the current window and show
        this.splashScreen = null;            
    }