Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
File Chrome打包应用程序从命令行传递文件(通过launchData)_File_Command Line Arguments_Google Chrome App - Fatal编程技术网

File Chrome打包应用程序从命令行传递文件(通过launchData)

File Chrome打包应用程序从命令行传递文件(通过launchData),file,command-line-arguments,google-chrome-app,File,Command Line Arguments,Google Chrome App,我正在尝试编写一个Chrome打包的应用程序,它最终将从命令行接受文件作为参数,但我不知道如何使它工作。以下是我正在做的: manifest.json: ... "file_handlers" : { "text" : { "types" : [ "*" ], "title" : "File Opener" } }, ... chrome.app.runtime.onLaunched.addListener(function (launchDat

我正在尝试编写一个Chrome打包的应用程序,它最终将从命令行接受文件作为参数,但我不知道如何使它工作。以下是我正在做的:

manifest.json

...
"file_handlers" : {
    "text" : {
        "types" : [ "*" ],
        "title" : "File Opener"
    }
},
...
chrome.app.runtime.onLaunched.addListener(function (launchData) {
    chrome.app.window.create('my-file.html', { ... }, function (win) {
        win.contentWindow.launchData = launchData;
    });
});
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app-id=my-app-id "C:\path\to\file.txt"
我的背景页面.js

...
"file_handlers" : {
    "text" : {
        "types" : [ "*" ],
        "title" : "File Opener"
    }
},
...
chrome.app.runtime.onLaunched.addListener(function (launchData) {
    chrome.app.window.create('my-file.html', { ... }, function (win) {
        win.contentWindow.launchData = launchData;
    });
});
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app-id=my-app-id "C:\path\to\file.txt"
(我希望
launchData
能够填写通过命令行传递的文件的数据。)

命令

...
"file_handlers" : {
    "text" : {
        "types" : [ "*" ],
        "title" : "File Opener"
    }
},
...
chrome.app.runtime.onLaunched.addListener(function (launchData) {
    chrome.app.window.create('my-file.html', { ... }, function (win) {
        win.contentWindow.launchData = launchData;
    });
});
"C:\Program Files\Google\Chrome\Application\chrome.exe" --app-id=my-app-id "C:\path\to\file.txt"
当我执行上面的命令时,打包的应用程序会打开,但是
launchData
是未定义的

我是不是漏掉了什么明显的东西?我在Windows7上运行Chrome27,我真的很想让它运行起来


谢谢…

结果是这样的:我通过命令行传递的文件有一个Chrome(27)所不知道的MIME类型,目前当这种情况发生时,该文件从
启动数据中被忽略。幸运的是,Chrome 28(我相信)已经修复了这个问题,而且我已经确认该应用程序可以在Chrome Canary(目前已达到29个测试版)中运行

有关更多参考,请参阅问题