如何在Windows上使用参数打开Chrome Packaged应用程序? [英] How to open a Chrome Packaged App with a parameter on Windows?

查看:235
本文介绍了如何在Windows上使用参数打开Chrome Packaged应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的应用程序上创建一个文件处理程序,我没有Chrome操作系统,所以唯一的方法来尝试我的代码是从命令行启动应用程序与参数文件。我的问题是:怎么样?

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. My question is: how?

我试过
chrome --appid = [TheIdOfMyApp] - [打开文件的路径] 但它只是打开应用程序,从我的功能的条目是相同的,当我打开没有参数的Mado。

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.app.runtime.onLaunched.addListener(function(items) { 
  console.log(items);
  // The code to open the app's window...
});

它总是返回我 Object {isKioskSession:false}

[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"
]

[更新结束]

知道如何检查应用程序的文件处理程序是否在Windows上正常工作?我的代码是否正确?

Does anyone know how to check if an app's file handler is working on Windows? Is my code correct?

感谢您的帮助。

推荐答案

感谢Ben Wells,它现在工作。代码(如果某人有一天有相同的问题):

Thanks Ben Wells, it's working now. The code (if someone has the same problem one day):

在manifest.json中:

In manifest.json:

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

命令行(如果你在32位Windows上,则删除(x86)):

And what to do on the command line (remove (x86) if you're on a 32-bit Windows):

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

如果要查看您的应用程序是否检测到参数,请添加上面的代码以 chrome.app.runtime.onLaunched 开头的背景javascript。

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.

这篇关于如何在Windows上使用参数打开Chrome Packaged应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆