我正在尝试从串行设备 arduino(串行监视器)读取数据。但我不希望应用程序在新窗口中打开。它应该在 chrome 选项卡中打开。
//manifest.json
{
"manifest_version": 2,
"name": "Serial Monitor",
"description": "Monitors your serial port and allows you to read and write to it like you could with Arduino's IDE.",
"version": "1.0.4",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {
"16": "extentionAssets/icon-16x16.jpeg",
"128": "extentionAssets/icon-128x128.jpeg"
},
"permissions": [
"tabs","serial"
]
}
//background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('demo.html', {
bounds: {
width: 1160,
height: 960,
left: 100,
top: 100
},
minWidth: 1160,
minHeight: 960
});
});
chrome.runtime.onSuspend.addListener(function() {
// Do some simple clean-up tasks.
});
chrome.runtime.onInstalled.addListener(function() {
// chrome.storage.local.set(object items, function callback);
});
我也使用chrome.create.tabs
了功能,但它没有帮助..新标签立即打开和关闭。