0

参考这个问题:How to make the Web Bluetooth Pair button work when run as chrome app

在我的测试中,调用 navigator.bluetooth.requestDevice 时弹出的窗口非常大,覆盖了完全调用它的 html 窗口,并且包含 Pair 和 Cancel 按钮的窗口底部不在底部屏幕等不可见。

是否可以控制 requestDevice 窗口的位置和位置?

包含基本 html 的窗口

requestDevice 窗口覆盖原始并延伸到屏幕外

<html>
  <head>
   <script type="text/javascript" src="bluetoothle.js"></script> 
   <script type="text/javascript" src="popup.js"></script>
  </head>
  <body>
    <h1>Hello Bluetooth</h1>
    <h2>Device Discovery</h2>
    <button id="btn_discover">Discover Devices</button>
    <div id="devices"></div>
  </body>
</html>

navigator.bluetooth.requestDevice(options)
  .then(device => {
    console.log('> Name:             ' + device.name);
    console.log('> Id:               ' + device.id);
    console.log('> Connected:        ' + device.gatt.connected);
    bluetoothle.selected_device = device;
    console.log(bluetoothle.selected_device);
  })
  .catch(error => {
    console.log('ERROR: '+ error);
  });
4

2 回答 2

0

不,无法控制 requestDevice() 打开的设备选择器窗口的大小。它将使用固定的最大尺寸。(在这里写作时,我手头没有这些尺寸。)chrome.app.window可以最大化地打开以在短期内解决这个问题。

(此外,虽然可能有理由开发 chrome 应用程序或将网络蓝牙改造成以前的应用程序,但如果您还没有看到 Chrome 应用程序在 Windows、macOS、Linux 上被弃用,您应该阅读公告。)

于 2017-08-08T03:59:24.250 回答
0

看起来https://bugs.chromium.org/p/chromium/issues/detail?id=751819已提交调查此问题。

于 2017-08-17T12:53:12.450 回答