-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: 🚀 Extended floating control bar function
- Loading branch information
Showing
15 changed files
with
313 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { BrowserWindow, ipcMain, Menu } from 'electron' | ||
import { openControlWindow } from '$control/electron/helpers/index.js' | ||
|
||
export default function (controlWindow) { | ||
ipcMain.handle('open-control-device-menu', (event, deviceList) => { | ||
const template = deviceList.map((item) => { | ||
let label = item.$remark || item.$name | ||
|
||
if (item.$wifi) { | ||
label += ` (WIFI)` | ||
} | ||
|
||
return { | ||
label, | ||
click: () => { | ||
openControlWindow(controlWindow, item) | ||
}, | ||
} | ||
}) | ||
|
||
const menu = Menu.buildFromTemplate(template) | ||
menu.popup(BrowserWindow.fromWebContents(event.sender)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BrowserWindow, ipcMain, Menu } from 'electron' | ||
|
||
export default function (controlWindow) { | ||
ipcMain.handle('open-device-gnirehtet-menu', openDeviceGnirehtetMenu) | ||
|
||
function openDeviceGnirehtetMenu(event, args = {}) { | ||
const { options = [] } = args | ||
|
||
const template = options.map((item) => { | ||
return { | ||
label: item.label, | ||
click() { | ||
controlWindow.webContents.send(item.value) | ||
}, | ||
} | ||
}) | ||
|
||
const menu = Menu.buildFromTemplate(template) | ||
menu.popup(BrowserWindow.fromWebContents(event.sender)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { default as devices } from './devices/index.js' | ||
export { default as gnirehtet } from './gnirehtet/index.js' | ||
export { default as rotation } from './rotation/index.js' | ||
export { default as volume } from './volume/index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { BrowserWindow, ipcMain, Menu } from 'electron' | ||
|
||
export default function (controlWindow) { | ||
ipcMain.handle('open-device-rotation-menu', openDeviceRotationMenu) | ||
|
||
function openDeviceRotationMenu(event, args = {}) { | ||
const { options = [] } = args | ||
|
||
const template = options.map((item) => { | ||
return { | ||
label: item.label, | ||
click: () => { | ||
controlWindow.webContents.send( | ||
'execute-device-rotation-shell', | ||
item.value, | ||
) | ||
}, | ||
} | ||
}) | ||
|
||
const menu = Menu.buildFromTemplate(template) | ||
menu.popup(BrowserWindow.fromWebContents(event.sender)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BrowserWindow, ipcMain, Menu } from 'electron' | ||
|
||
export default function (controlWindow) { | ||
ipcMain.handle('open-device-volume-menu', openDeviceVolumeMenu) | ||
|
||
function openDeviceVolumeMenu(event, args = {}) { | ||
const { options = [] } = args | ||
|
||
const template = options.map((item) => { | ||
return { | ||
label: item.label, | ||
click() { | ||
controlWindow.webContents.send('execute-device-volume-shell', item.value) | ||
}, | ||
} | ||
}) | ||
|
||
const menu = Menu.buildFromTemplate(template) | ||
menu.popup(BrowserWindow.fromWebContents(event.sender)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,41 @@ | ||
import { BrowserWindow, ipcMain, Menu } from 'electron' | ||
import { BrowserWindow, ipcMain } from 'electron' | ||
import { initControlWindow, openControlWindow } from './helpers/index.js' | ||
|
||
import { devices, gnirehtet, rotation, volume } from './events/index.js' | ||
|
||
function onControlMounted(controlWindow) { | ||
ipcMain.on('language-change', (event, data) => { | ||
controlWindow.webContents.send('language-change', data) | ||
}) | ||
|
||
ipcMain.on('theme-change', (event, data) => { | ||
controlWindow.webContents.send('theme-change', data) | ||
}) | ||
|
||
rotation(controlWindow) | ||
devices(controlWindow) | ||
volume(controlWindow) | ||
gnirehtet(controlWindow) | ||
} | ||
|
||
export default (mainWindow) => { | ||
let controlWindow | ||
|
||
ipcMain.on('open-control-window', (event, data) => { | ||
ipcMain.handle('open-control-window', (event, data) => { | ||
controlWindow = BrowserWindow.getAllWindows().find( | ||
win => win.customId === 'control', | ||
) | ||
|
||
if (!controlWindow) { | ||
controlWindow = initControlWindow(mainWindow) | ||
|
||
ipcMain.on('control-mounted', () => { | ||
openControlWindow(controlWindow, data) | ||
}) | ||
|
||
return false | ||
} | ||
|
||
openControlWindow(controlWindow, data) | ||
}) | ||
|
||
ipcMain.on('language-change', (event, data) => { | ||
if (controlWindow) { | ||
controlWindow.webContents.send('language-change', data) | ||
} | ||
}) | ||
|
||
ipcMain.on('theme-change', (event, data) => { | ||
if (controlWindow) { | ||
controlWindow.webContents.send('theme-change', data) | ||
openControlWindow(controlWindow, data) | ||
return false | ||
} | ||
}) | ||
|
||
ipcMain.on('show-device-list', (event, deviceList) => { | ||
const template = deviceList.map((item) => { | ||
let label = item.$remark || item.$name | ||
|
||
if (item.$wifi) { | ||
label += ` (WIFI)` | ||
} | ||
controlWindow = initControlWindow(mainWindow) | ||
|
||
return { | ||
label, | ||
click: () => { | ||
openControlWindow(controlWindow, item) | ||
}, | ||
} | ||
ipcMain.on('control-mounted', () => { | ||
onControlMounted(controlWindow) | ||
openControlWindow(controlWindow, data) | ||
}) | ||
|
||
const menu = Menu.buildFromTemplate(template) | ||
menu.popup(BrowserWindow.fromWebContents(event.sender)) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.