hardware-example 1.0.39-alpha.5 → 1.0.39-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.ts +46 -2
- package/src/preload.ts +19 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "hardware-example",
|
|
3
3
|
"productName": "HardwareExample",
|
|
4
4
|
"executableName": "onekey-hardware-example",
|
|
5
|
-
"version": "1.0.39-alpha.
|
|
5
|
+
"version": "1.0.39-alpha.7",
|
|
6
6
|
"author": "OneKey",
|
|
7
7
|
"description": "End-to-end encrypted workspaces for teams",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"resolutions": {
|
|
42
42
|
"**/node-gyp": "^10.0.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "df213188c56438b560e062822171c705d2bd9595"
|
|
45
45
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { screen, app, BrowserWindow, session, ipcMain } from 'electron';
|
|
1
|
+
import { screen, app, BrowserWindow, session, ipcMain, shell } from 'electron';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import isDevelopment from 'electron-is-dev';
|
|
4
4
|
import { format as formatUrl } from 'url';
|
|
5
5
|
import log from 'electron-log';
|
|
6
6
|
import { autoUpdater } from 'electron-updater';
|
|
7
|
+
import { exec } from 'child_process';
|
|
7
8
|
import { initNobleBleSupport } from '@onekeyfe/hd-transport-electron';
|
|
8
9
|
import initProcess, { restartBridge } from './process';
|
|
9
10
|
import { ipcMessageKeys } from './config';
|
|
@@ -297,6 +298,49 @@ ipcMain.on(ipcMessageKeys.APP_RELOAD_BRIDGE_PROCESS, () => {
|
|
|
297
298
|
restartBridge();
|
|
298
299
|
});
|
|
299
300
|
|
|
301
|
+
// Simplified Bluetooth System API Implementation
|
|
302
|
+
class BluetoothSystemManager {
|
|
303
|
+
openBluetoothSettings(): void {
|
|
304
|
+
try {
|
|
305
|
+
if (process.platform === 'darwin') {
|
|
306
|
+
exec('open "/System/Library/PreferencePanes/Bluetooth.prefPane"');
|
|
307
|
+
} else if (process.platform === 'win32') {
|
|
308
|
+
shell.openExternal('ms-settings:bluetooth');
|
|
309
|
+
} else {
|
|
310
|
+
log.warn('Opening Bluetooth settings not supported on this platform');
|
|
311
|
+
}
|
|
312
|
+
} catch (error) {
|
|
313
|
+
log.error('Failed to open Bluetooth settings:', error);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
openPrivacySettings(): void {
|
|
318
|
+
try {
|
|
319
|
+
if (process.platform === 'darwin') {
|
|
320
|
+
exec('open "x-apple.systempreferences:com.apple.preference.security?Privacy_Bluetooth"');
|
|
321
|
+
} else if (process.platform === 'win32') {
|
|
322
|
+
shell.openExternal('ms-settings:privacy-bluetooth');
|
|
323
|
+
} else {
|
|
324
|
+
log.warn('Opening privacy settings not supported on this platform');
|
|
325
|
+
}
|
|
326
|
+
} catch (error) {
|
|
327
|
+
log.error('Failed to open privacy settings:', error);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Create global instance
|
|
333
|
+
const bluetoothManager = new BluetoothSystemManager();
|
|
334
|
+
|
|
335
|
+
// Register simplified IPC handlers for Bluetooth system API
|
|
336
|
+
ipcMain.handle('bluetooth-open-bluetooth-settings', () => {
|
|
337
|
+
bluetoothManager.openBluetoothSettings();
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
ipcMain.handle('bluetooth-open-privacy-settings', () => {
|
|
341
|
+
bluetoothManager.openPrivacySettings();
|
|
342
|
+
});
|
|
343
|
+
|
|
300
344
|
// 配置 GitHub 发布提供者
|
|
301
345
|
autoUpdater.setFeedURL({
|
|
302
346
|
provider: 'github',
|
|
@@ -324,7 +368,7 @@ app.on('ready', () => {
|
|
|
324
368
|
}, 5000);
|
|
325
369
|
});
|
|
326
370
|
|
|
327
|
-
//
|
|
371
|
+
// quit when all windows are closed, except on macOS. There, it's common
|
|
328
372
|
// for applications and their menu bar to stay active until the user quits
|
|
329
373
|
// explicitly with Cmd + Q
|
|
330
374
|
app.on('window-all-closed', (event: Event) => {
|
package/src/preload.ts
CHANGED
|
@@ -5,6 +5,13 @@ import { EOneKeyBleMessageKeys } from '@onekeyfe/hd-shared';
|
|
|
5
5
|
import type { DesktopAPI as BaseDesktopAPI, NobleBleAPI } from '@onekeyfe/hd-transport-electron';
|
|
6
6
|
import { ipcMessageKeys } from './config';
|
|
7
7
|
|
|
8
|
+
// Simplified Bluetooth system API - only for opening settings
|
|
9
|
+
export interface BluetoothSystemAPI {
|
|
10
|
+
// System integration
|
|
11
|
+
openBluetoothSettings: () => void;
|
|
12
|
+
openPrivacySettings: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
// Extend the base DesktopAPI with this specific application's needs
|
|
9
16
|
export interface DesktopAPI extends BaseDesktopAPI {
|
|
10
17
|
restart: () => void;
|
|
@@ -17,6 +24,9 @@ export interface DesktopAPI extends BaseDesktopAPI {
|
|
|
17
24
|
|
|
18
25
|
// Make nobleBle required for this app
|
|
19
26
|
nobleBle: NobleBleAPI;
|
|
27
|
+
|
|
28
|
+
// Simplified Bluetooth system management
|
|
29
|
+
bluetoothSystem: BluetoothSystemAPI;
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
declare global {
|
|
@@ -97,6 +107,15 @@ const desktopApi = {
|
|
|
97
107
|
ipcRenderer.removeListener(EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, subscription);
|
|
98
108
|
};
|
|
99
109
|
},
|
|
110
|
+
checkAvailability: () => ipcRenderer.invoke(EOneKeyBleMessageKeys.BLE_AVAILABILITY_CHECK),
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
// Simplified Bluetooth system management
|
|
114
|
+
bluetoothSystem: {
|
|
115
|
+
// Open Bluetooth settings when Bluetooth is off
|
|
116
|
+
openBluetoothSettings: () => ipcRenderer.invoke('bluetooth-open-bluetooth-settings'),
|
|
117
|
+
// Open Privacy & Security settings for Bluetooth permission
|
|
118
|
+
openPrivacySettings: () => ipcRenderer.invoke('bluetooth-open-privacy-settings'),
|
|
100
119
|
},
|
|
101
120
|
};
|
|
102
121
|
|