refactor: create IPC_MESSAGES enum for IPC message channels (#25694)
This commit is contained in:
parent
8dfb1cf78f
commit
2c68bad631
26 changed files with 225 additions and 126 deletions
|
@ -1,5 +1,6 @@
|
|||
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
|
||||
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
|
||||
import { IPC_MESSAGES } from '../common/ipc-messages';
|
||||
|
||||
window.onload = function () {
|
||||
// Use menu API to show context menu.
|
||||
|
@ -20,7 +21,7 @@ function completeURL (project: string, path: string) {
|
|||
|
||||
// The DOM implementation expects (message?: string) => boolean
|
||||
window.confirm = function (message?: string, title?: string) {
|
||||
return ipcRendererUtils.invokeSync('ELECTRON_INSPECTOR_CONFIRM', message, title) as boolean;
|
||||
return ipcRendererUtils.invokeSync(IPC_MESSAGES.INSPECTOR_CONFIRM, message, title) as boolean;
|
||||
};
|
||||
|
||||
const useEditMenuItems = function (x: number, y: number, items: ContextMenuItem[]) {
|
||||
|
@ -33,7 +34,7 @@ const useEditMenuItems = function (x: number, y: number, items: ContextMenuItem[
|
|||
|
||||
const createMenu = function (x: number, y: number, items: ContextMenuItem[]) {
|
||||
const isEditMenu = useEditMenuItems(x, y, items);
|
||||
ipcRendererInternal.invoke<number>('ELECTRON_INSPECTOR_CONTEXT_MENU', items, isEditMenu).then(id => {
|
||||
ipcRendererInternal.invoke<number>(IPC_MESSAGES.INSPECTOR_CONTEXT_MENU, items, isEditMenu).then(id => {
|
||||
if (typeof id === 'number') {
|
||||
window.DevToolsAPI!.contextMenuItemSelected(id);
|
||||
}
|
||||
|
@ -42,7 +43,7 @@ const createMenu = function (x: number, y: number, items: ContextMenuItem[]) {
|
|||
};
|
||||
|
||||
const showFileChooserDialog = function (callback: (blob: File) => void) {
|
||||
ipcRendererInternal.invoke<[ string, any ]>('ELECTRON_INSPECTOR_SELECT_FILE').then(([path, data]) => {
|
||||
ipcRendererInternal.invoke<[ string, any ]>(IPC_MESSAGES.INSPECTOR_SELECT_FILE).then(([path, data]) => {
|
||||
if (path && data) {
|
||||
callback(dataToHtml5FileObject(path, data));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue