Javascript 打开一个&x201C;设置”;首次使用私有企业Chrome应用程序扩展名中的.crx文件安装Chrome扩展名后的页面

Javascript 打开一个&x201C;设置”;首次使用私有企业Chrome应用程序扩展名中的.crx文件安装Chrome扩展名后的页面,javascript,google-chrome-app,Javascript,Google Chrome App,在使用扩展名为.crx的文件安装chrome插件时,我只想第一次显示设置页面。需要填写以下字段: 1)TID(textbox) 2)SID(textbox) 3)TLocation(textbox) 4)BaseURL(for web service API) 此数据将被存储,用户也可以在将来更改此设置 如何在安装时使用.crx文件显示此页面,此应用程序将仅为私人应用程序。 目前我正在使用webview在chrome应用程序中显示我们的网站,如下所示: <webview src="ht

在使用扩展名为.crx的文件安装chrome插件时,我只想第一次显示设置页面。需要填写以下字段:

1)TID(textbox)
2)SID(textbox)
3)TLocation(textbox) 
4)BaseURL(for web service API)
此数据将被存储,用户也可以在将来更改此设置

如何在安装时使用.crx文件显示此页面,此应用程序将仅为私人应用程序。

目前我正在使用webview在chrome应用程序中显示我们的网站,如下所示:

<webview src="http://yoursite.com/chromeapp" style="width:100%; height:90%"></webview> 
我的JS文件代码:

 chrome.app.runtime.onLaunched.addListener(function() {
  runApp();
 });


 chrome.app.runtime.onRestarted.addListener(function() {
  runApp();
  });

chrome.runtime.onInstalled.addListener(function (object) {
  chrome.tabs.create({url: "http://yoursite.com/setting.html"}, function (tab) 
  {
    console.log("called: http://yoursite.com/setting.html");
  });
  });

  function runApp() {
       chrome.app.window.create('browser.html', {
          bounds: {
          'width': 1024,
          'height': 768
         }
         });
       }

如果有人做过此类工作,请提供帮助。

请尝试下面的代码,它肯定适用于您的场景

Background.js

chrome.runtime.onInstalled.addListener(function (details) {
  if (details.reason == "install") {
    runSettingApp();
  } else {
    runApp();
    }
});
创建两个函数。第一个将在第一次安装时打开设置屏幕,第二个将在启动时打开主页

function runApp() {
chrome.app.window.create('home.html', {
bounds: {
  'width': 1024,
  'height': 768
  }
 });
}

function runSettingApp() {
chrome.app.window.create('setting.html', {
bounds: {
  'width': 1024,
  'height': 768
 }

 });
}

chrome.runtime.onInstalled.addListener
应该很好。你说它不工作是什么意思?总是webview页面在第一次打开时显示,但通过调用chrome.runtime.onInstalled.addListener上的方法不显示,此方法将在chrome扩展名中的.crx文件安装中工作?我想在应用程序第一次打开时显示页面。之后,应用程序应使用webview URL正常工作。请帮忙
function runApp() {
chrome.app.window.create('home.html', {
bounds: {
  'width': 1024,
  'height': 768
  }
 });
}

function runSettingApp() {
chrome.app.window.create('setting.html', {
bounds: {
  'width': 1024,
  'height': 768
 }

 });
}