简体   繁体   English

如何在Windows上打开带有参数的Chrome打包应用程序?

[英]How to open a Chrome Packaged App with a parameter on Windows?

I'm trying to create a file handler on my app, I've not Chrome OS so the only way to try my code is to launch the app from command line with a file in parameter. 我正在尝试在我的应用上创建文件处理程序,我不是Chrome操作系统,所以尝试我的代码的唯一方法是从命令行启动应用程序,并在参数中添加文件。 My question is: how? 我的问题是:怎么样?

I've tried chrome --appid=[TheIdOfMyApp] --[Path of the file to open] but it just opens the app and the entry from my function is the same as when I open Mado with no parameters. 我已经尝试了chrome --appid=[TheIdOfMyApp] --[Path of the file to open]但它只是打开应用程序,我的功能中的条目与我打开没有参数的Mado时相同。

To check if I have an entry I do that : 要检查我是否有条目我这样做:

chrome.app.runtime.onLaunched.addListener(function(items) { 
  console.log(items);
  // The code to open the app's window...
});

It always returns me Object {isKioskSession: false} . 它总是返回Object {isKioskSession: false}

[UPDATE] [UPDATE]

My manifest looks like (these are just the file handlers and the permissions parts): 我的清单看起来像(这些只是文件处理程序和权限部分):

"file_handlers": {
    "text": {
        "types": ["text/md"],
        "title": "MyApp"
    }
},
"permissions": [
    {"fileSystem": ["write", "retainEntries"]},
    {"mediaGalleries": ["read", "allAutoDetected"]},
    "storage",
    "webview"
]

[END OF THE UPDATE] [更新完]

Does anyone know how to check if an app's file handler is working on Windows? 有谁知道如何检查应用程序的文件处理程序是否在Windows上运行? Is my code correct? 我的代码是否正确?

Thanks for your help. 谢谢你的帮助。

Thanks Ben Wells, it's working now. 谢谢Ben Wells,它现在正在运作。 The code (if someone has the same problem one day): 代码(如果某人有一天有同样的问题):

In manifest.json: 在manifest.json中:

"file_handlers": {
    "text": {
        "extensions": [
            "md"
        ],
        "title": "YourApp"
    }
},

And what to do on the command line (remove (x86) if you're on a 32-bit Windows): 以及如何在命令行上执行(如果您使用的是32位Windows,请删除(x86) ):

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --app-id=YourAppId "C:\Path\To\document.md"

If you want to see if your app has detect a parameter, add the code above (the block who begins with chrome.app.runtime.onLaunched ) to your background javascript. 如果您想查看您的应用是否检测到参数,请将上面的代码(以chrome.app.runtime.onLaunched开头的块)添加到您的后台javascript中。

Command line parameters to packaged apps do not seem to be implemented yet. 打包应用程序的命令行参数似乎尚未实现。

The open issue 165573 "Allow launch arguments to be passed to platform apps" states "We need to figure out ... if / how to pass these via the command line". 开放式问题165573 “允许将启动参数传递给平台应用程序”声明“我们需要弄清楚......是否/如何通过命令行传递这些参数”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM