From 3ba46a3565845943a34ccc8ac7c362af7e472cad Mon Sep 17 00:00:00 2001 From: yaofeng Date: Fri, 9 Feb 2018 23:22:03 +0800 Subject: [PATCH 01/14] 1 --- ElectronNET.CLI/ElectronNET.CLI.csproj | 3 +- ElectronNET.Host/api/app.js | 68 ++++++------- ElectronNET.Host/api/browserWindows.js | 132 ++++++++++++------------- ElectronNET.Host/api/clipboard.js | 12 +-- ElectronNET.Host/api/dialog.js | 10 +- ElectronNET.Host/api/globalShortcut.js | 4 +- ElectronNET.Host/api/ipc.js | 14 +-- ElectronNET.Host/api/menu.js | 4 +- ElectronNET.Host/api/notification.js | 12 +-- ElectronNET.Host/api/screen.js | 18 ++-- ElectronNET.Host/api/shell.js | 14 +-- ElectronNET.Host/api/tray.js | 16 +-- ElectronNET.Host/api/webContents.js | 8 +- ElectronNET.Host/main.js | 13 +-- 14 files changed, 164 insertions(+), 164 deletions(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index e2f4202..97526d0 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -5,7 +5,6 @@ netcoreapp2.0 dotnet-electronize - DotnetCliTool true ..\artifacts ElectronNET.CLI @@ -17,7 +16,7 @@ This package contains the dotnet tooling to electronize your application. https://github.com/ElectronNET/Electron.NET/blob/master/LICENSE https://github.com/ElectronNET/Electron.NET/ - https://github.com/ElectronNET/Electron.NET/ + electron aspnetcore Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png diff --git a/ElectronNET.Host/api/app.js b/ElectronNET.Host/api/app.js index 997591b..8638b5b 100644 --- a/ElectronNET.Host/api/app.js +++ b/ElectronNET.Host/api/app.js @@ -16,44 +16,44 @@ module.exports = function (socket, app) { }); socket.on('register-app-window-all-closed-event', function (id) { app.on('window-all-closed', function () { - socket.emit('app-window-all-closed' + id); + global.elesocket.emit('app-window-all-closed' + id); }); }); socket.on('register-app-before-quit-event', function (id) { app.on('before-quit', function (event) { event.preventDefault(); - socket.emit('app-before-quit' + id); + global.elesocket.emit('app-before-quit' + id); }); }); socket.on('register-app-will-quit-event', function (id) { app.on('will-quit', function (event) { event.preventDefault(); - socket.emit('app-will-quit' + id); + global.elesocket.emit('app-will-quit' + id); }); }); socket.on('register-app-browser-window-blur-event', function (id) { app.on('browser-window-blur', function () { - socket.emit('app-browser-window-blur' + id); + global.elesocket.emit('app-browser-window-blur' + id); }); }); socket.on('register-app-browser-window-focus-event', function (id) { app.on('browser-window-focus', function () { - socket.emit('app-browser-window-focus' + id); + global.elesocket.emit('app-browser-window-focus' + id); }); }); socket.on('register-app-browser-window-created-event', function (id) { app.on('browser-window-created', function () { - socket.emit('app-browser-window-created' + id); + global.elesocket.emit('app-browser-window-created' + id); }); }); socket.on('register-app-web-contents-created-event', function (id) { app.on('web-contents-created', function () { - socket.emit('app-web-contents-created' + id); + global.elesocket.emit('app-web-contents-created' + id); }); }); socket.on('register-app-accessibility-support-changed-event', function (id) { app.on('accessibility-support-changed', function (event, accessibilitySupportEnabled) { - socket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled); + global.elesocket.emit('app-accessibility-support-changed' + id, accessibilitySupportEnabled); }); }); socket.on('appQuit', function () { @@ -77,11 +77,11 @@ module.exports = function (socket, app) { }); socket.on('appGetAppPath', function () { var path = app.getAppPath(); - socket.emit('appGetAppPathCompleted', path); + global.elesocket.emit('appGetAppPathCompleted', path); }); socket.on('appGetPath', function (name) { var path = app.getPath(name); - socket.emit('appGetPathCompleted', path); + global.elesocket.emit('appGetPathCompleted', path); }); // const nativeImages = {}; // function addNativeImage(nativeImage: Electron.NativeImage) { @@ -95,12 +95,12 @@ module.exports = function (socket, app) { socket.on('appGetFileIcon', function (path, options) { if (options) { app.getFileIcon(path, options, function (error, nativeImage) { - socket.emit('appGetFileIconCompleted', [error, nativeImage]); + global.elesocket.emit('appGetFileIconCompleted', [error, nativeImage]); }); } else { app.getFileIcon(path, function (error, nativeImage) { - socket.emit('appGetFileIconCompleted', [error, nativeImage]); + global.elesocket.emit('appGetFileIconCompleted', [error, nativeImage]); }); } }); @@ -109,18 +109,18 @@ module.exports = function (socket, app) { }); socket.on('appGetVersion', function () { var version = app.getVersion(); - socket.emit('appGetVersionCompleted', version); + global.elesocket.emit('appGetVersionCompleted', version); }); socket.on('appGetName', function () { var name = app.getName(); - socket.emit('appGetNameCompleted', name); + global.elesocket.emit('appGetNameCompleted', name); }); socket.on('appSetName', function (name) { app.setName(name); }); socket.on('appGetLocale', function () { var locale = app.getLocale(); - socket.emit('appGetLocaleCompleted', locale); + global.elesocket.emit('appGetLocaleCompleted', locale); }); socket.on('appAddRecentDocument', function (path) { app.addRecentDocument(path); @@ -130,32 +130,32 @@ module.exports = function (socket, app) { }); socket.on('appSetAsDefaultProtocolClient', function (protocol, path, args) { var success = app.setAsDefaultProtocolClient(protocol, path, args); - socket.emit('appSetAsDefaultProtocolClientCompleted', success); + global.elesocket.emit('appSetAsDefaultProtocolClientCompleted', success); }); socket.on('appRemoveAsDefaultProtocolClient', function (protocol, path, args) { var success = app.removeAsDefaultProtocolClient(protocol, path, args); - socket.emit('appRemoveAsDefaultProtocolClientCompleted', success); + global.elesocket.emit('appRemoveAsDefaultProtocolClientCompleted', success); }); socket.on('appIsDefaultProtocolClient', function (protocol, path, args) { var success = app.isDefaultProtocolClient(protocol, path, args); - socket.emit('appIsDefaultProtocolClientCompleted', success); + global.elesocket.emit('appIsDefaultProtocolClientCompleted', success); }); socket.on('appSetUserTasks', function (tasks) { var success = app.setUserTasks(tasks); - socket.emit('appSetUserTasksCompleted', success); + global.elesocket.emit('appSetUserTasksCompleted', success); }); socket.on('appGetJumpListSettings', function () { var jumpListSettings = app.getJumpListSettings(); - socket.emit('appGetJumpListSettingsCompleted', jumpListSettings); + global.elesocket.emit('appGetJumpListSettingsCompleted', jumpListSettings); }); socket.on('appSetJumpList', function (categories) { app.setJumpList(categories); }); socket.on('appMakeSingleInstance', function () { var success = app.makeSingleInstance(function (args, workingDirectory) { - socket.emit('newInstanceOpened', [args, workingDirectory]); + global.elesocket.emit('newInstanceOpened', [args, workingDirectory]); }); - socket.emit('appMakeSingleInstanceCompleted', success); + global.elesocket.emit('appMakeSingleInstanceCompleted', success); }); socket.on('appReleaseSingleInstance', function () { app.releaseSingleInstance(); @@ -165,48 +165,48 @@ module.exports = function (socket, app) { }); socket.on('appGetCurrentActivityType', function () { var activityType = app.getCurrentActivityType(); - socket.emit('appGetCurrentActivityTypeCompleted', activityType); + global.elesocket.emit('appGetCurrentActivityTypeCompleted', activityType); }); socket.on('appSetAppUserModelId', function (id) { app.setAppUserModelId(id); }); socket.on('appImportCertificate', function (options) { app.importCertificate(options, function (result) { - socket.emit('appImportCertificateCompleted', result); + global.elesocket.emit('appImportCertificateCompleted', result); }); }); socket.on('appGetAppMetrics', function () { var processMetrics = app.getAppMetrics(); - socket.emit('appGetAppMetricsCompleted', processMetrics); + global.elesocket.emit('appGetAppMetricsCompleted', processMetrics); }); socket.on('appGetGpuFeatureStatus', function () { // TS Workaround - TS say getGpuFeatureStatus - but it is getGPUFeatureStatus var x = app; var gpuFeatureStatus = x.getGPUFeatureStatus(); - socket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus); + global.elesocket.emit('appGetGpuFeatureStatusCompleted', gpuFeatureStatus); }); socket.on('appSetBadgeCount', function (count) { var success = app.setBadgeCount(count); - socket.emit('appSetBadgeCountCompleted', success); + global.elesocket.emit('appSetBadgeCountCompleted', success); }); socket.on('appGetBadgeCount', function () { var count = app.getBadgeCount(); - socket.emit('appGetBadgeCountCompleted', count); + global.elesocket.emit('appGetBadgeCountCompleted', count); }); socket.on('appIsUnityRunning', function () { var isUnityRunning = app.isUnityRunning(); - socket.emit('appIsUnityRunningCompleted', isUnityRunning); + global.elesocket.emit('appIsUnityRunningCompleted', isUnityRunning); }); socket.on('appGetLoginItemSettings', function (options) { var loginItemSettings = app.getLoginItemSettings(options); - socket.emit('appGetLoginItemSettingsCompleted', loginItemSettings); + global.elesocket.emit('appGetLoginItemSettingsCompleted', loginItemSettings); }); socket.on('appSetLoginItemSettings', function (settings) { app.setLoginItemSettings(settings); }); socket.on('appIsAccessibilitySupportEnabled', function () { var isAccessibilitySupportEnabled = app.isAccessibilitySupportEnabled(); - socket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled); + global.elesocket.emit('appIsAccessibilitySupportEnabledCompleted', isAccessibilitySupportEnabled); }); socket.on('appSetAboutPanelOptions', function (options) { app.setAboutPanelOptions(options); @@ -222,7 +222,7 @@ module.exports = function (socket, app) { }); socket.on('appDockBounce', function (type) { var id = app.dock.bounce(type); - socket.emit('appDockBounceCompleted', id); + global.elesocket.emit('appDockBounceCompleted', id); }); socket.on('appDockCancelBounce', function (id) { app.dock.cancelBounce(id); @@ -235,7 +235,7 @@ module.exports = function (socket, app) { }); socket.on('appDockGetBadge', function () { var text = app.dock.getBadge(); - socket.emit('appDockGetBadgeCompleted', text); + global.elesocket.emit('appDockGetBadgeCompleted', text); }); socket.on('appDockHide', function () { app.dock.hide(); @@ -245,7 +245,7 @@ module.exports = function (socket, app) { }); socket.on('appDockIsVisible', function () { var isVisible = app.dock.isVisible(); - socket.emit('appDockIsVisibleCompleted', isVisible); + global.elesocket.emit('appDockIsVisibleCompleted', isVisible); }); // TODO: Menü Lösung muss noch implementiert werden socket.on('appDockSetMenu', function (menu) { diff --git a/ElectronNET.Host/api/browserWindows.js b/ElectronNET.Host/api/browserWindows.js index 8ccc9a6..755cd76 100644 --- a/ElectronNET.Host/api/browserWindows.js +++ b/ElectronNET.Host/api/browserWindows.js @@ -6,152 +6,152 @@ var windows = []; module.exports = function (socket) { socket.on('register-browserWindow-ready-to-show', function (id) { getWindowById(id).on('ready-to-show', function () { - socket.emit('browserWindow-ready-to-show' + id); + global.elesocket.emit('browserWindow-ready-to-show' + id); }); }); socket.on('register-browserWindow-page-title-updated', function (id) { getWindowById(id).on('page-title-updated', function (event, title) { - socket.emit('browserWindow-page-title-updated' + id, title); + global.elesocket.emit('browserWindow-page-title-updated' + id, title); }); }); socket.on('register-browserWindow-close', function (id) { getWindowById(id).on('close', function () { - socket.emit('browserWindow-close' + id); + global.elesocket.emit('browserWindow-close' + id); }); }); socket.on('register-browserWindow-closed', function (id) { getWindowById(id).on('closed', function () { - socket.emit('browserWindow-closed' + id); + global.elesocket.emit('browserWindow-closed' + id); }); }); socket.on('register-browserWindow-session-end', function (id) { getWindowById(id).on('session-end', function () { - socket.emit('browserWindow-session-end' + id); + global.elesocket.emit('browserWindow-session-end' + id); }); }); socket.on('register-browserWindow-unresponsive', function (id) { getWindowById(id).on('unresponsive', function () { - socket.emit('browserWindow-unresponsive' + id); + global.elesocket.emit('browserWindow-unresponsive' + id); }); }); socket.on('register-browserWindow-responsive', function (id) { getWindowById(id).on('responsive', function () { - socket.emit('browserWindow-responsive' + id); + global.elesocket.emit('browserWindow-responsive' + id); }); }); socket.on('register-browserWindow-blur', function (id) { getWindowById(id).on('blur', function () { - socket.emit('browserWindow-blur' + id); + global.elesocket.emit('browserWindow-blur' + id); }); }); socket.on('register-browserWindow-focus', function (id) { getWindowById(id).on('focus', function () { - socket.emit('browserWindow-focus' + id); + global.elesocket.emit('browserWindow-focus' + id); }); }); socket.on('register-browserWindow-show', function (id) { getWindowById(id).on('show', function () { - socket.emit('browserWindow-show' + id); + global.elesocket.emit('browserWindow-show' + id); }); }); socket.on('register-browserWindow-hide', function (id) { getWindowById(id).on('hide', function () { - socket.emit('browserWindow-hide' + id); + global.elesocket.emit('browserWindow-hide' + id); }); }); socket.on('register-browserWindow-maximize', function (id) { getWindowById(id).on('maximize', function () { - socket.emit('browserWindow-maximize' + id); + global.elesocket.emit('browserWindow-maximize' + id); }); }); socket.on('register-browserWindow-unmaximize', function (id) { getWindowById(id).on('unmaximize', function () { - socket.emit('browserWindow-unmaximize' + id); + global.elesocket.emit('browserWindow-unmaximize' + id); }); }); socket.on('register-browserWindow-minimize', function (id) { getWindowById(id).on('minimize', function () { - socket.emit('browserWindow-minimize' + id); + global.elesocket.emit('browserWindow-minimize' + id); }); }); socket.on('register-browserWindow-restore', function (id) { getWindowById(id).on('restore', function () { - socket.emit('browserWindow-restore' + id); + global.elesocket.emit('browserWindow-restore' + id); }); }); socket.on('register-browserWindow-resize', function (id) { getWindowById(id).on('resize', function () { - socket.emit('browserWindow-resize' + id); + global.elesocket.emit('browserWindow-resize' + id); }); }); socket.on('register-browserWindow-move', function (id) { getWindowById(id).on('move', function () { - socket.emit('browserWindow-move' + id); + global.elesocket.emit('browserWindow-move' + id); }); }); socket.on('register-browserWindow-moved', function (id) { getWindowById(id).on('moved', function () { - socket.emit('browserWindow-moved' + id); + global.elesocket.emit('browserWindow-moved' + id); }); }); socket.on('register-browserWindow-enter-full-screen', function (id) { getWindowById(id).on('enter-full-screen', function () { - socket.emit('browserWindow-enter-full-screen' + id); + global.elesocket.emit('browserWindow-enter-full-screen' + id); }); }); socket.on('register-browserWindow-leave-full-screen', function (id) { getWindowById(id).on('leave-full-screen', function () { - socket.emit('browserWindow-leave-full-screen' + id); + global.elesocket.emit('browserWindow-leave-full-screen' + id); }); }); socket.on('register-browserWindow-enter-html-full-screen', function (id) { getWindowById(id).on('enter-html-full-screen', function () { - socket.emit('browserWindow-enter-html-full-screen' + id); + global.elesocket.emit('browserWindow-enter-html-full-screen' + id); }); }); socket.on('register-browserWindow-leave-html-full-screen', function (id) { getWindowById(id).on('leave-html-full-screen', function () { - socket.emit('browserWindow-leave-html-full-screen' + id); + global.elesocket.emit('browserWindow-leave-html-full-screen' + id); }); }); socket.on('register-browserWindow-app-command', function (id) { getWindowById(id).on('app-command', function (event, command) { - socket.emit('browserWindow-app-command' + id, command); + global.elesocket.emit('browserWindow-app-command' + id, command); }); }); socket.on('register-browserWindow-scroll-touch-begin', function (id) { getWindowById(id).on('scroll-touch-begin', function () { - socket.emit('browserWindow-scroll-touch-begin' + id); + global.elesocket.emit('browserWindow-scroll-touch-begin' + id); }); }); socket.on('register-browserWindow-scroll-touch-end', function (id) { getWindowById(id).on('scroll-touch-end', function () { - socket.emit('browserWindow-scroll-touch-end' + id); + global.elesocket.emit('browserWindow-scroll-touch-end' + id); }); }); socket.on('register-browserWindow-scroll-touch-edge', function (id) { getWindowById(id).on('scroll-touch-edge', function () { - socket.emit('browserWindow-scroll-touch-edge' + id); + global.elesocket.emit('browserWindow-scroll-touch-edge' + id); }); }); socket.on('register-browserWindow-swipe', function (id) { getWindowById(id).on('swipe', function (event, direction) { - socket.emit('browserWindow-swipe' + id, direction); + global.elesocket.emit('browserWindow-swipe' + id, direction); }); }); socket.on('register-browserWindow-sheet-begin', function (id) { getWindowById(id).on('sheet-begin', function () { - socket.emit('browserWindow-sheet-begin' + id); + global.elesocket.emit('browserWindow-sheet-begin' + id); }); }); socket.on('register-browserWindow-sheet-end', function (id) { getWindowById(id).on('sheet-end', function () { - socket.emit('browserWindow-sheet-end' + id); + global.elesocket.emit('browserWindow-sheet-end' + id); }); }); socket.on('register-browserWindow-new-window-for-tab', function (id) { getWindowById(id).on('new-window-for-tab', function () { - socket.emit('browserWindow-new-window-for-tab' + id); + global.elesocket.emit('browserWindow-new-window-for-tab' + id); }); }); socket.on('createBrowserWindow', function (options, loadUrl) { @@ -167,7 +167,7 @@ module.exports = function (socket) { windows.splice(index, 1); var ids_1 = []; windows.forEach(function (x) { return ids_1.push(x.id); }); - socket.emit('BrowserWindowClosed', ids_1); + global.elesocket.emit('BrowserWindowClosed', ids_1); } } }; @@ -180,7 +180,7 @@ module.exports = function (socket) { window.loadURL(loadUrl); } windows.push(window); - socket.emit('BrowserWindowCreated', window.id); + global.elesocket.emit('BrowserWindowCreated', window.id); }); socket.on('browserWindowDestroy', function (id) { getWindowById(id).destroy(); @@ -196,11 +196,11 @@ module.exports = function (socket) { }); socket.on('browserWindowIsFocused', function (id) { var isFocused = getWindowById(id).isFocused(); - socket.emit('browserWindow-isFocused-completed', isFocused); + global.elesocket.emit('browserWindow-isFocused-completed', isFocused); }); socket.on('browserWindowIsDestroyed', function (id) { var isDestroyed = getWindowById(id).isDestroyed(); - socket.emit('browserWindow-isDestroyed-completed', isDestroyed); + global.elesocket.emit('browserWindow-isDestroyed-completed', isDestroyed); }); socket.on('browserWindowShow', function (id) { getWindowById(id).show(); @@ -213,11 +213,11 @@ module.exports = function (socket) { }); socket.on('browserWindowIsVisible', function (id) { var isVisible = getWindowById(id).isVisible(); - socket.emit('browserWindow-isVisible-completed', isVisible); + global.elesocket.emit('browserWindow-isVisible-completed', isVisible); }); socket.on('browserWindowIsModal', function (id) { var isModal = getWindowById(id).isModal(); - socket.emit('browserWindow-isModal-completed', isModal); + global.elesocket.emit('browserWindow-isModal-completed', isModal); }); socket.on('browserWindowMaximize', function (id) { getWindowById(id).maximize(); @@ -227,7 +227,7 @@ module.exports = function (socket) { }); socket.on('browserWindowIsMaximized', function (id) { var isMaximized = getWindowById(id).isMaximized(); - socket.emit('browserWindow-isMaximized-completed', isMaximized); + global.elesocket.emit('browserWindow-isMaximized-completed', isMaximized); }); socket.on('browserWindowMinimize', function (id) { getWindowById(id).minimize(); @@ -237,14 +237,14 @@ module.exports = function (socket) { }); socket.on('browserWindowIsMinimized', function (id) { var isMinimized = getWindowById(id).isMinimized(); - socket.emit('browserWindow-isMinimized-completed', isMinimized); + global.elesocket.emit('browserWindow-isMinimized-completed', isMinimized); }); socket.on('browserWindowSetFullScreen', function (id, fullscreen) { getWindowById(id).setFullScreen(fullscreen); }); socket.on('browserWindowIsFullScreen', function (id) { var isFullScreen = getWindowById(id).isFullScreen(); - socket.emit('browserWindow-isFullScreen-completed', isFullScreen); + global.elesocket.emit('browserWindow-isFullScreen-completed', isFullScreen); }); socket.on('browserWindowSetAspectRatio', function (id, aspectRatio, extraSize) { getWindowById(id).setAspectRatio(aspectRatio, extraSize); @@ -260,91 +260,91 @@ module.exports = function (socket) { }); socket.on('browserWindowGetBounds', function (id) { var rectangle = getWindowById(id).getBounds(); - socket.emit('browserWindow-getBounds-completed', rectangle); + global.elesocket.emit('browserWindow-getBounds-completed', rectangle); }); socket.on('browserWindowSetContentBounds', function (id, bounds, animate) { getWindowById(id).setContentBounds(bounds, animate); }); socket.on('browserWindowGetContentBounds', function (id) { var rectangle = getWindowById(id).getContentBounds(); - socket.emit('browserWindow-getContentBounds-completed', rectangle); + global.elesocket.emit('browserWindow-getContentBounds-completed', rectangle); }); socket.on('browserWindowSetSize', function (id, width, height, animate) { getWindowById(id).setSize(width, height, animate); }); socket.on('browserWindowGetSize', function (id) { var size = getWindowById(id).getSize(); - socket.emit('browserWindow-getSize-completed', size); + global.elesocket.emit('browserWindow-getSize-completed', size); }); socket.on('browserWindowSetContentSize', function (id, width, height, animate) { getWindowById(id).setContentSize(width, height, animate); }); socket.on('browserWindowGetContentSize', function (id) { var size = getWindowById(id).getContentSize(); - socket.emit('browserWindow-getContentSize-completed', size); + global.elesocket.emit('browserWindow-getContentSize-completed', size); }); socket.on('browserWindowSetMinimumSize', function (id, width, height) { getWindowById(id).setMinimumSize(width, height); }); socket.on('browserWindowGetMinimumSize', function (id) { var size = getWindowById(id).getMinimumSize(); - socket.emit('browserWindow-getMinimumSize-completed', size); + global.elesocket.emit('browserWindow-getMinimumSize-completed', size); }); socket.on('browserWindowSetMaximumSize', function (id, width, height) { getWindowById(id).setMaximumSize(width, height); }); socket.on('browserWindowGetMaximumSize', function (id) { var size = getWindowById(id).getMaximumSize(); - socket.emit('browserWindow-getMaximumSize-completed', size); + global.elesocket.emit('browserWindow-getMaximumSize-completed', size); }); socket.on('browserWindowSetResizable', function (id, resizable) { getWindowById(id).setResizable(resizable); }); socket.on('browserWindowIsResizable', function (id) { var resizable = getWindowById(id).isResizable(); - socket.emit('browserWindow-isResizable-completed', resizable); + global.elesocket.emit('browserWindow-isResizable-completed', resizable); }); socket.on('browserWindowSetMovable', function (id, movable) { getWindowById(id).setMovable(movable); }); socket.on('browserWindowIsMovable', function (id) { var movable = getWindowById(id).isMovable(); - socket.emit('browserWindow-isMovable-completed', movable); + global.elesocket.emit('browserWindow-isMovable-completed', movable); }); socket.on('browserWindowSetMinimizable', function (id, minimizable) { getWindowById(id).setMinimizable(minimizable); }); socket.on('browserWindowIsMinimizable', function (id) { var minimizable = getWindowById(id).isMinimizable(); - socket.emit('browserWindow-isMinimizable-completed', minimizable); + global.elesocket.emit('browserWindow-isMinimizable-completed', minimizable); }); socket.on('browserWindowSetMaximizable', function (id, maximizable) { getWindowById(id).setMaximizable(maximizable); }); socket.on('browserWindowIsMaximizable', function (id) { var maximizable = getWindowById(id).isMaximizable(); - socket.emit('browserWindow-isMaximizable-completed', maximizable); + global.elesocket.emit('browserWindow-isMaximizable-completed', maximizable); }); socket.on('browserWindowSetFullScreenable', function (id, fullscreenable) { getWindowById(id).setFullScreenable(fullscreenable); }); socket.on('browserWindowIsFullScreenable', function (id) { var fullscreenable = getWindowById(id).isFullScreenable(); - socket.emit('browserWindow-isFullScreenable-completed', fullscreenable); + global.elesocket.emit('browserWindow-isFullScreenable-completed', fullscreenable); }); socket.on('browserWindowSetClosable', function (id, closable) { getWindowById(id).setClosable(closable); }); socket.on('browserWindowIsClosable', function (id) { var closable = getWindowById(id).isClosable(); - socket.emit('browserWindow-isClosable-completed', closable); + global.elesocket.emit('browserWindow-isClosable-completed', closable); }); socket.on('browserWindowSetAlwaysOnTop', function (id, flag, level, relativeLevel) { getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel); }); socket.on('browserWindowIsAlwaysOnTop', function (id) { var isAlwaysOnTop = getWindowById(id).isAlwaysOnTop(); - socket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop); + global.elesocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop); }); socket.on('browserWindowCenter', function (id) { getWindowById(id).center(); @@ -354,14 +354,14 @@ module.exports = function (socket) { }); socket.on('browserWindowGetPosition', function (id) { var position = getWindowById(id).getPosition(); - socket.emit('browserWindow-getPosition-completed', position); + global.elesocket.emit('browserWindow-getPosition-completed', position); }); socket.on('browserWindowSetTitle', function (id, title) { getWindowById(id).setTitle(title); }); socket.on('browserWindowGetTitle', function (id) { var title = getWindowById(id).getTitle(); - socket.emit('browserWindow-getTitle-completed', title); + global.elesocket.emit('browserWindow-getTitle-completed', title); }); socket.on('browserWindowSetTitle', function (id, title) { getWindowById(id).setTitle(title); @@ -385,21 +385,21 @@ module.exports = function (socket) { }); socket.on('browserWindowIsKiosk', function (id) { var isKiosk = getWindowById(id).isKiosk(); - socket.emit('browserWindow-isKiosk-completed', isKiosk); + global.elesocket.emit('browserWindow-isKiosk-completed', isKiosk); }); socket.on('browserWindowSetRepresentedFilename', function (id, filename) { getWindowById(id).setRepresentedFilename(filename); }); socket.on('browserWindowGetRepresentedFilename', function (id) { var pathname = getWindowById(id).getRepresentedFilename(); - socket.emit('browserWindow-getRepresentedFilename-completed', pathname); + global.elesocket.emit('browserWindow-getRepresentedFilename-completed', pathname); }); socket.on('browserWindowSetDocumentEdited', function (id, edited) { getWindowById(id).setDocumentEdited(edited); }); socket.on('browserWindowIsDocumentEdited', function (id) { var edited = getWindowById(id).isDocumentEdited(); - socket.emit('browserWindow-isDocumentEdited-completed', edited); + global.elesocket.emit('browserWindow-isDocumentEdited-completed', edited); }); socket.on('browserWindowFocusOnWebView', function (id) { getWindowById(id).focusOnWebView(); @@ -418,7 +418,7 @@ module.exports = function (socket) { if (menuItems) { menu = electron_1.Menu.buildFromTemplate(menuItems); addMenuItemClickConnector(menu.items, function (id) { - socket.emit("windowMenuItemClicked", id); + global.elesocket.emit("windowMenuItemClicked", id); }); } getWindowById(id).setMenu(menu); @@ -441,18 +441,18 @@ module.exports = function (socket) { }); socket.on('browserWindowHasShadow', function (id) { var hasShadow = getWindowById(id).hasShadow(); - socket.emit('browserWindow-hasShadow-completed', hasShadow); + global.elesocket.emit('browserWindow-hasShadow-completed', hasShadow); }); socket.on('browserWindowSetThumbarButtons', function (id, thumbarButtons) { thumbarButtons.forEach(function (thumbarButton) { var imagePath = path.join(__dirname.replace('api', ''), 'bin', thumbarButton.icon.toString()); thumbarButton.icon = electron_1.nativeImage.createFromPath(imagePath); thumbarButton.click = function () { - socket.emit("thumbarButtonClicked", thumbarButton["id"]); + global.elesocket.emit("thumbarButtonClicked", thumbarButton["id"]); }; }); var success = getWindowById(id).setThumbarButtons(thumbarButtons); - socket.emit('browserWindowSetThumbarButtons-completed', success); + global.elesocket.emit('browserWindowSetThumbarButtons-completed', success); }); socket.on('browserWindowSetThumbnailClip', function (id, rectangle) { getWindowById(id).setThumbnailClip(rectangle); @@ -471,21 +471,21 @@ module.exports = function (socket) { }); socket.on('browserWindowIsMenuBarAutoHide', function (id) { var isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide(); - socket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide); + global.elesocket.emit('browserWindow-isMenuBarAutoHide-completed', isMenuBarAutoHide); }); socket.on('browserWindowSetMenuBarVisibility', function (id, visible) { getWindowById(id).setMenuBarVisibility(visible); }); socket.on('browserWindowIsMenuBarVisible', function (id) { var isMenuBarVisible = getWindowById(id).isMenuBarVisible(); - socket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible); + global.elesocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible); }); socket.on('browserWindowSetVisibleOnAllWorkspaces', function (id, visible) { getWindowById(id).setVisibleOnAllWorkspaces(visible); }); socket.on('browserWindowIsVisibleOnAllWorkspaces', function (id) { var isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces(); - socket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces); + global.elesocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces); }); socket.on('browserWindowSetIgnoreMouseEvents', function (id, ignore) { getWindowById(id).setIgnoreMouseEvents(ignore); @@ -502,7 +502,7 @@ module.exports = function (socket) { }); socket.on('browserWindowGetParentWindow', function (id) { var browserWindow = getWindowById(id).getParentWindow(); - socket.emit('browserWindow-getParentWindow-completed', browserWindow.id); + global.elesocket.emit('browserWindow-getParentWindow-completed', browserWindow.id); }); socket.on('browserWindowGetChildWindows', function (id) { var browserWindows = getWindowById(id).getChildWindows(); @@ -510,7 +510,7 @@ module.exports = function (socket) { browserWindows.forEach(function (x) { ids.push(x.id); }); - socket.emit('browserWindow-getChildWindows-completed', ids); + global.elesocket.emit('browserWindow-getChildWindows-completed', ids); }); socket.on('browserWindowSetAutoHideCursor', function (id, autoHide) { getWindowById(id).setAutoHideCursor(autoHide); diff --git a/ElectronNET.Host/api/clipboard.js b/ElectronNET.Host/api/clipboard.js index 2f86a6d..d2b83ac 100644 --- a/ElectronNET.Host/api/clipboard.js +++ b/ElectronNET.Host/api/clipboard.js @@ -4,35 +4,35 @@ var electron_1 = require("electron"); module.exports = function (socket) { socket.on('clipboard-readText', function (type) { var text = electron_1.clipboard.readText(type); - socket.emit('clipboard-readText-Completed', text); + global.elesocket.emit('clipboard-readText-Completed', text); }); socket.on('clipboard-writeText', function (text, type) { electron_1.clipboard.writeText(text, type); }); socket.on('clipboard-readHTML', function (type) { var content = electron_1.clipboard.readHTML(type); - socket.emit('clipboard-readHTML-Completed', content); + global.elesocket.emit('clipboard-readHTML-Completed', content); }); socket.on('clipboard-writeHTML', function (markup, type) { electron_1.clipboard.writeHTML(markup, type); }); socket.on('clipboard-readRTF', function (type) { var content = electron_1.clipboard.readRTF(type); - socket.emit('clipboard-readRTF-Completed', content); + global.elesocket.emit('clipboard-readRTF-Completed', content); }); socket.on('clipboard-writeRTF', function (text, type) { electron_1.clipboard.writeHTML(text, type); }); socket.on('clipboard-readBookmark', function () { var bookmark = electron_1.clipboard.readBookmark(); - socket.emit('clipboard-readBookmark-Completed', bookmark); + global.elesocket.emit('clipboard-readBookmark-Completed', bookmark); }); socket.on('clipboard-writeBookmark', function (title, url, type) { electron_1.clipboard.writeBookmark(title, url, type); }); socket.on('clipboard-readFindText', function () { var content = electron_1.clipboard.readFindText(); - socket.emit('clipboard-readFindText-Completed', content); + global.elesocket.emit('clipboard-readFindText-Completed', content); }); socket.on('clipboard-writeFindText', function (text) { electron_1.clipboard.writeFindText(text); @@ -42,7 +42,7 @@ module.exports = function (socket) { }); socket.on('clipboard-availableFormats', function (type) { var formats = electron_1.clipboard.availableFormats(type); - socket.emit('clipboard-availableFormats-Completed', formats); + global.elesocket.emit('clipboard-availableFormats-Completed', formats); }); socket.on('clipboard-write', function (data, type) { electron_1.clipboard.write(data, type); diff --git a/ElectronNET.Host/api/dialog.js b/ElectronNET.Host/api/dialog.js index 1e3ef93..4d93400 100644 --- a/ElectronNET.Host/api/dialog.js +++ b/ElectronNET.Host/api/dialog.js @@ -6,27 +6,27 @@ module.exports = function (socket) { if ("id" in browserWindow) { var window = electron_1.BrowserWindow.fromId(browserWindow.id); electron_1.dialog.showMessageBox(window, options, function (response, checkboxChecked) { - socket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]); + global.elesocket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]); }); } else { var message = browserWindow; var id_1 = guid || options; electron_1.dialog.showMessageBox(browserWindow, function (response, checkboxChecked) { - socket.emit('showMessageBoxComplete' + id_1, [response, checkboxChecked]); + global.elesocket.emit('showMessageBoxComplete' + id_1, [response, checkboxChecked]); }); } }); socket.on('showOpenDialog', function (browserWindow, options, guid) { var window = electron_1.BrowserWindow.fromId(browserWindow.id); electron_1.dialog.showOpenDialog(window, options, function (filePaths) { - socket.emit('showOpenDialogComplete' + guid, filePaths || []); + global.elesocket.emit('showOpenDialogComplete' + guid, filePaths || []); }); }); socket.on('showSaveDialog', function (browserWindow, options, guid) { var window = electron_1.BrowserWindow.fromId(browserWindow.id); electron_1.dialog.showSaveDialog(window, options, function (filename) { - socket.emit('showSaveDialogComplete' + guid, filename || ''); + global.elesocket.emit('showSaveDialogComplete' + guid, filename || ''); }); }); socket.on('showErrorBox', function (title, content) { @@ -35,7 +35,7 @@ module.exports = function (socket) { socket.on('showCertificateTrustDialog', function (browserWindow, options, guid) { var window = electron_1.BrowserWindow.fromId(browserWindow.id); electron_1.dialog.showCertificateTrustDialog(window, options, function () { - socket.emit('showCertificateTrustDialogComplete' + guid); + global.elesocket.emit('showCertificateTrustDialogComplete' + guid); }); }); }; diff --git a/ElectronNET.Host/api/globalShortcut.js b/ElectronNET.Host/api/globalShortcut.js index b1f63a5..bd7aa0b 100644 --- a/ElectronNET.Host/api/globalShortcut.js +++ b/ElectronNET.Host/api/globalShortcut.js @@ -4,12 +4,12 @@ var electron_1 = require("electron"); module.exports = function (socket) { socket.on('globalShortcut-register', function (accelerator) { electron_1.globalShortcut.register(accelerator, function () { - socket.emit('globalShortcut-pressed', accelerator); + global.elesocket.emit('globalShortcut-pressed', accelerator); }); }); socket.on('globalShortcut-isRegistered', function (accelerator) { var isRegistered = electron_1.globalShortcut.isRegistered(accelerator); - socket.emit('globalShortcut-isRegisteredCompleted', isRegistered); + global.elesocket.emit('globalShortcut-isRegisteredCompleted', isRegistered); }); socket.on('globalShortcut-unregister', function (accelerator) { electron_1.globalShortcut.unregister(accelerator); diff --git a/ElectronNET.Host/api/ipc.js b/ElectronNET.Host/api/ipc.js index 8bb0fa5..2d127c2 100644 --- a/ElectronNET.Host/api/ipc.js +++ b/ElectronNET.Host/api/ipc.js @@ -2,24 +2,24 @@ exports.__esModule = true; var electron_1 = require("electron"); module.exports = function (socket) { - socket.on('registerIpcMainChannel', function (channel) { - electron_1.ipcMain.on(channel, function (event, args) { - socket.emit(channel, [event.preventDefault(), args]); + socket.on('registerIpcMainChannel', function (channel) { // ע + electron_1.ipcMain.on(channel, function (event, args) { // ǰ˵ + global.elesocket.emit(channel, [event.preventDefault(), args]); // ͵ }); }); socket.on('registerSyncIpcMainChannel', function (channel) { electron_1.ipcMain.on(channel, function (event, args) { - var x = socket; + var x = global.elesocket; x.removeAllListeners(channel + 'Sync'); - socket.on(channel + 'Sync', function (result) { + global.elesocket.on(channel + 'Sync', function (result) { event.returnValue = result; }); - socket.emit(channel, [event.preventDefault(), args]); + global.elesocket.emit(channel, [event.preventDefault(), args]); }); }); socket.on('registerOnceIpcMainChannel', function (channel) { electron_1.ipcMain.once(channel, function (event, args) { - socket.emit(channel, [event.preventDefault(), args]); + global.elesocket.emit(channel, [event.preventDefault(), args]); }); }); socket.on('removeAllListenersIpcMainChannel', function (channel) { diff --git a/ElectronNET.Host/api/menu.js b/ElectronNET.Host/api/menu.js index cc6a8c9..93680e3 100644 --- a/ElectronNET.Host/api/menu.js +++ b/ElectronNET.Host/api/menu.js @@ -6,7 +6,7 @@ module.exports = function (socket) { socket.on('menu-setContextMenu', function (browserWindowId, menuItems) { var menu = electron_1.Menu.buildFromTemplate(menuItems); addContextMenuItemClickConnector(menu.items, browserWindowId, function (id, browserWindowId) { - socket.emit("contextMenuItemClicked", [id, browserWindowId]); + global.elesocket.emit("contextMenuItemClicked", [id, browserWindowId]); }); contextMenuItems.push({ menu: menu, @@ -34,7 +34,7 @@ module.exports = function (socket) { socket.on('menu-setApplicationMenu', function (menuItems) { var menu = electron_1.Menu.buildFromTemplate(menuItems); addMenuItemClickConnector(menu.items, function (id) { - socket.emit("menuItemClicked", id); + global.elesocket.emit("menuItemClicked", id); }); electron_1.Menu.setApplicationMenu(menu); }); diff --git a/ElectronNET.Host/api/notification.js b/ElectronNET.Host/api/notification.js index 020a153..f4e6b15 100644 --- a/ElectronNET.Host/api/notification.js +++ b/ElectronNET.Host/api/notification.js @@ -9,31 +9,31 @@ module.exports = function (socket) { if (options.showID) { haveEvent = true; notification.on('show', function () { - socket.emit('NotificationEventShow', options.showID); + global.elesocket.emit('NotificationEventShow', options.showID); }); } if (options.clickID) { haveEvent = true; notification.on('click', function () { - socket.emit('NotificationEventClick', options.clickID); + global.elesocket.emit('NotificationEventClick', options.clickID); }); } if (options.closeID) { haveEvent = true; notification.on('close', function () { - socket.emit('NotificationEventClose', options.closeID); + global.elesocket.emit('NotificationEventClose', options.closeID); }); } if (options.replyID) { haveEvent = true; notification.on('reply', function (event, value) { - socket.emit('NotificationEventReply', [options.replyID, value]); + global.elesocket.emit('NotificationEventReply', [options.replyID, value]); }); } if (options.actionID) { haveEvent = true; notification.on('action', function (event, value) { - socket.emit('NotificationEventAction', [options.actionID, value]); + global.elesocket.emit('NotificationEventAction', [options.actionID, value]); }); } if (haveEvent) { @@ -43,7 +43,7 @@ module.exports = function (socket) { }); socket.on('notificationIsSupported', function (options) { var isSupported = electron_1.Notification.isSupported; - socket.emit('notificationIsSupportedComplete', isSupported); + global.elesocket.emit('notificationIsSupportedComplete', isSupported); }); }; //# sourceMappingURL=notification.js.map \ No newline at end of file diff --git a/ElectronNET.Host/api/screen.js b/ElectronNET.Host/api/screen.js index dee3ea8..440c4d8 100644 --- a/ElectronNET.Host/api/screen.js +++ b/ElectronNET.Host/api/screen.js @@ -4,42 +4,42 @@ var electron_1 = require("electron"); module.exports = function (socket) { socket.on('register-screen-display-added', function (id) { electron_1.screen.on('display-added', function (event, display) { - socket.emit('screen-display-added-event' + id, display); + global.elesocket.emit('screen-display-added-event' + id, display); }); }); socket.on('register-screen-display-removed', function (id) { electron_1.screen.on('display-removed', function (event, display) { - socket.emit('screen-display-removed-event' + id, display); + global.elesocket.emit('screen-display-removed-event' + id, display); }); }); socket.on('register-screen-display-metrics-changed', function (id) { electron_1.screen.on('display-metrics-changed', function (event, display, changedMetrics) { - socket.emit('screen-display-metrics-changed-event' + id, [display, changedMetrics]); + global.elesocket.emit('screen-display-metrics-changed-event' + id, [display, changedMetrics]); }); }); socket.on('screen-getCursorScreenPoint', function () { var point = electron_1.screen.getCursorScreenPoint(); - socket.emit('screen-getCursorScreenPointCompleted', point); + global.elesocket.emit('screen-getCursorScreenPointCompleted', point); }); socket.on('screen-getMenuBarHeight', function () { var height = electron_1.screen.getMenuBarHeight(); - socket.emit('screen-getMenuBarHeightCompleted', height); + global.elesocket.emit('screen-getMenuBarHeightCompleted', height); }); socket.on('screen-getPrimaryDisplay', function () { var display = electron_1.screen.getPrimaryDisplay(); - socket.emit('screen-getPrimaryDisplayCompleted', display); + global.elesocket.emit('screen-getPrimaryDisplayCompleted', display); }); socket.on('screen-getAllDisplays', function () { var display = electron_1.screen.getAllDisplays(); - socket.emit('screen-getAllDisplaysCompleted', display); + global.elesocket.emit('screen-getAllDisplaysCompleted', display); }); socket.on('screen-getDisplayNearestPoint', function (point) { var display = electron_1.screen.getDisplayNearestPoint(point); - socket.emit('screen-getDisplayNearestPointCompleted', display); + global.elesocket.emit('screen-getDisplayNearestPointCompleted', display); }); socket.on('screen-getDisplayMatching', function (rectangle) { var display = electron_1.screen.getDisplayMatching(rectangle); - socket.emit('screen-getDisplayMatchingCompleted', display); + global.elesocket.emit('screen-getDisplayMatchingCompleted', display); }); }; //# sourceMappingURL=screen.js.map \ No newline at end of file diff --git a/ElectronNET.Host/api/shell.js b/ElectronNET.Host/api/shell.js index e88c11b..6191c96 100644 --- a/ElectronNET.Host/api/shell.js +++ b/ElectronNET.Host/api/shell.js @@ -4,17 +4,17 @@ var electron_1 = require("electron"); module.exports = function (socket) { socket.on('shell-showItemInFolder', function (fullPath) { var success = electron_1.shell.showItemInFolder(fullPath); - socket.emit('shell-showItemInFolderCompleted', success); + global.elesocket.emit('shell-showItemInFolderCompleted', success); }); socket.on('shell-openItem', function (fullPath) { var success = electron_1.shell.openItem(fullPath); - socket.emit('shell-openItemCompleted', success); + global.elesocket.emit('shell-openItemCompleted', success); }); socket.on('shell-openExternal', function (url, options, callback) { var success = false; if (options && callback) { success = electron_1.shell.openExternal(url, options, function (error) { - socket.emit('shell-openExternalCallback', [url, error]); + global.elesocket.emit('shell-openExternalCallback', [url, error]); }); } else if (options) { @@ -23,22 +23,22 @@ module.exports = function (socket) { else { success = electron_1.shell.openExternal(url); } - socket.emit('shell-openExternalCompleted', success); + global.elesocket.emit('shell-openExternalCompleted', success); }); socket.on('shell-moveItemToTrash', function (fullPath) { var success = electron_1.shell.moveItemToTrash(fullPath); - socket.emit('shell-moveItemToTrashCompleted', success); + global.elesocket.emit('shell-moveItemToTrashCompleted', success); }); socket.on('shell-beep', function () { electron_1.shell.beep(); }); socket.on('shell-writeShortcutLink', function (shortcutPath, operation, options) { var success = electron_1.shell.writeShortcutLink(shortcutPath, operation, options); - socket.emit('shell-writeShortcutLinkCompleted', success); + global.elesocket.emit('shell-writeShortcutLinkCompleted', success); }); socket.on('shell-readShortcutLink', function (shortcutPath) { var shortcutDetails = electron_1.shell.readShortcutLink(shortcutPath); - socket.emit('shell-readShortcutLinkCompleted', shortcutDetails); + global.elesocket.emit('shell-readShortcutLinkCompleted', shortcutDetails); }); }; //# sourceMappingURL=shell.js.map \ No newline at end of file diff --git a/ElectronNET.Host/api/tray.js b/ElectronNET.Host/api/tray.js index 26da2fe..ec729d4 100644 --- a/ElectronNET.Host/api/tray.js +++ b/ElectronNET.Host/api/tray.js @@ -7,49 +7,49 @@ module.exports = function (socket) { socket.on('register-tray-click', function (id) { if (tray) { tray.on('click', function (event, bounds) { - socket.emit('tray-click-event' + id, [event.__proto__, bounds]); + global.elesocket.emit('tray-click-event' + id, [event.__proto__, bounds]); }); } }); socket.on('register-tray-right-click', function (id) { if (tray) { tray.on('right-click', function (event, bounds) { - socket.emit('tray-right-click-event' + id, [event.__proto__, bounds]); + global.elesocket.emit('tray-right-click-event' + id, [event.__proto__, bounds]); }); } }); socket.on('register-tray-double-click', function (id) { if (tray) { tray.on('double-click', function (event, bounds) { - socket.emit('tray-double-click-event' + id, [event.__proto__, bounds]); + global.elesocket.emit('tray-double-click-event' + id, [event.__proto__, bounds]); }); } }); socket.on('register-tray-balloon-show', function (id) { if (tray) { tray.on('balloon-show', function () { - socket.emit('tray-balloon-show-event' + id); + global.elesocket.emit('tray-balloon-show-event' + id); }); } }); socket.on('register-tray-balloon-click', function (id) { if (tray) { tray.on('balloon-click', function () { - socket.emit('tray-balloon-click-event' + id); + global.elesocket.emit('tray-balloon-click-event' + id); }); } }); socket.on('register-tray-balloon-closed', function (id) { if (tray) { tray.on('balloon-closed', function () { - socket.emit('tray-balloon-closed-event' + id); + global.elesocket.emit('tray-balloon-closed-event' + id); }); } }); socket.on('create-tray', function (image, menuItems) { var menu = electron_1.Menu.buildFromTemplate(menuItems); addMenuItemClickConnector(menu.items, function (id) { - socket.emit("trayMenuItemClicked", id); + global.elesocket.emit("trayMenuItemClicked", id); }); var imagePath = path.join(__dirname.replace('api', ''), 'bin', image); tray = new electron_1.Tray(imagePath); @@ -94,7 +94,7 @@ module.exports = function (socket) { socket.on('tray-isDestroyed', function () { if (tray) { var isDestroyed = tray.isDestroyed(); - socket.emit('tray-isDestroyedCompleted', isDestroyed); + global.elesocket.emit('tray-isDestroyedCompleted', isDestroyed); } }); function addMenuItemClickConnector(menuItems, callback) { diff --git a/ElectronNET.Host/api/webContents.js b/ElectronNET.Host/api/webContents.js index 4a107b0..55bf478 100644 --- a/ElectronNET.Host/api/webContents.js +++ b/ElectronNET.Host/api/webContents.js @@ -7,14 +7,14 @@ module.exports = function (socket) { var browserWindow = getWindowById(id); browserWindow.webContents.removeAllListeners('crashed'); browserWindow.webContents.on('crashed', function (event, killed) { - socket.emit('webContents-crashed' + id, killed); + global.elesocket.emit('webContents-crashed' + id, killed); }); }); socket.on('register-webContents-didFinishLoad', function (id) { var browserWindow = getWindowById(id); browserWindow.webContents.removeAllListeners('did-finish-load'); browserWindow.webContents.on('did-finish-load', function () { - socket.emit('webContents-didFinishLoad' + id); + global.elesocket.emit('webContents-didFinishLoad' + id); }); }); socket.on('webContentsOpenDevTools', function (id, options) { @@ -32,10 +32,10 @@ module.exports = function (socket) { } fs.writeFile(path, data, function (error) { if (error) { - socket.emit('webContents-printToPDF-completed', false); + global.elesocket.emit('webContents-printToPDF-completed', false); } else { - socket.emit('webContents-printToPDF-completed', true); + global.elesocket.emit('webContents-printToPDF-completed', true); } }); }); diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index ee7c9c4..3386eb5 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -18,11 +18,12 @@ function startSocketApiBridge(port) { startAspCoreBackend(port); io.on('connection', (socket) => { - console.log('ASP.NET Core Application connected...'); - + global.elesocket = socket; + console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id); + appApi = require('./api/app')(socket, app); browserWindows = require('./api/browserWindows')(socket); - ipc = require('./api/ipc')(socket); + ipc = require('./api/ipc')(socket); menu = require('./api/menu')(socket); dialog = require('./api/dialog')(socket); notification = require('./api/notification')(socket); @@ -42,12 +43,12 @@ function startAspCoreBackend(electronPort) { const manifestFile = require("./bin/electron.manifest.json"); let binaryFile = manifestFile.executable; - + const os = require("os"); - if(os.platform() === "win32") { + if (os.platform() === "win32") { binaryFile = binaryFile + '.exe'; } - + const binFilePath = path.join(__dirname, 'bin', binaryFile); apiProcess = process(binFilePath, parameters); From e20dafbb665e055adccf495a8786d89b15abe457 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Wed, 28 Feb 2018 10:27:00 +0800 Subject: [PATCH 02/14] resume csproj --- ElectronNET.CLI/ElectronNET.CLI.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index 97526d0..e2f4202 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -5,6 +5,7 @@ netcoreapp2.0 dotnet-electronize + DotnetCliTool true ..\artifacts ElectronNET.CLI @@ -16,7 +17,7 @@ This package contains the dotnet tooling to electronize your application. https://github.com/ElectronNET/Electron.NET/blob/master/LICENSE https://github.com/ElectronNET/Electron.NET/ - + https://github.com/ElectronNET/Electron.NET/ electron aspnetcore Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png From 09972914842f47b67cbfa1459362869a71ef4bd4 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Wed, 18 Apr 2018 16:53:34 +0800 Subject: [PATCH 03/14] fix: possible eventemitter memory leak delected do: io.setMaxListeners(0); --- ElectronNET.CLI/ElectronNET.CLI.csproj | 2 +- ElectronNET.Host/api/ipc.js | 1 + ElectronNET.Host/main.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index e2f4202..be7bfef 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -9,7 +9,7 @@ true ..\artifacts ElectronNET.CLI - 1.0.0 + 1.0.1 Gregor Biswanger, Robert Muehsig Electron.NET diff --git a/ElectronNET.Host/api/ipc.js b/ElectronNET.Host/api/ipc.js index 2d127c2..c04b173 100644 --- a/ElectronNET.Host/api/ipc.js +++ b/ElectronNET.Host/api/ipc.js @@ -4,6 +4,7 @@ var electron_1 = require("electron"); module.exports = function (socket) { socket.on('registerIpcMainChannel', function (channel) { // ע electron_1.ipcMain.on(channel, function (event, args) { // ǰ˵ + console.log('ipc emit...', 'global.elesocket', global.elesocket.id, channel); global.elesocket.emit(channel, [event.preventDefault(), args]); // ͵ }); }); diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 3386eb5..a51d3ce 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -15,11 +15,13 @@ app.on('ready', () => { function startSocketApiBridge(port) { io = require('socket.io')(port); + // yf add + io.setMaxListeners(0); startAspCoreBackend(port); io.on('connection', (socket) => { global.elesocket = socket; - console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id); + console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id, new Date()); appApi = require('./api/app')(socket, app); browserWindows = require('./api/browserWindows')(socket); From ef1f0ab3307ca01145a69fa6cbbcc50d33216ea4 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Mon, 7 May 2018 17:18:17 +0800 Subject: [PATCH 04/14] registerIpcMainChannel remove channel --- ElectronNET.Host/api/ipc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ElectronNET.Host/api/ipc.js b/ElectronNET.Host/api/ipc.js index c04b173..ecb2817 100644 --- a/ElectronNET.Host/api/ipc.js +++ b/ElectronNET.Host/api/ipc.js @@ -3,6 +3,7 @@ exports.__esModule = true; var electron_1 = require("electron"); module.exports = function (socket) { socket.on('registerIpcMainChannel', function (channel) { // ע + electron_1.ipcMain.removeAllListeners(channel); // yf add ֹظ electron_1.ipcMain.on(channel, function (event, args) { // ǰ˵ console.log('ipc emit...', 'global.elesocket', global.elesocket.id, channel); global.elesocket.emit(channel, [event.preventDefault(), args]); // ͵ From e3eee0c32f0a78fc97e98b575a7f17707668379b Mon Sep 17 00:00:00 2001 From: yaofeng Date: Wed, 30 May 2018 10:38:41 +0800 Subject: [PATCH 05/14] 1 --- ElectronNET.CLI/ElectronNET.CLI.csproj | 2 +- ElectronNET.Host/api/ipc.js | 1 - ElectronNET.Host/main.js | 4 +++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index be7bfef..4b963b1 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -9,7 +9,7 @@ true ..\artifacts ElectronNET.CLI - 1.0.1 + 1.0.2 Gregor Biswanger, Robert Muehsig Electron.NET diff --git a/ElectronNET.Host/api/ipc.js b/ElectronNET.Host/api/ipc.js index ecb2817..9654982 100644 --- a/ElectronNET.Host/api/ipc.js +++ b/ElectronNET.Host/api/ipc.js @@ -5,7 +5,6 @@ module.exports = function (socket) { socket.on('registerIpcMainChannel', function (channel) { // ע electron_1.ipcMain.removeAllListeners(channel); // yf add ֹظ electron_1.ipcMain.on(channel, function (event, args) { // ǰ˵ - console.log('ipc emit...', 'global.elesocket', global.elesocket.id, channel); global.elesocket.emit(channel, [event.preventDefault(), args]); // ͵ }); }); diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index a51d3ce..09f4888 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -15,12 +15,14 @@ app.on('ready', () => { function startSocketApiBridge(port) { io = require('socket.io')(port); + // yf add - io.setMaxListeners(0); startAspCoreBackend(port); io.on('connection', (socket) => { + global.elesocket = socket; + global.elesocket.setMaxListeners(0); console.log('ASP.NET Core Application connected...', 'global.elesocket', global.elesocket.id, new Date()); appApi = require('./api/app')(socket, app); From 949741d992d95253c3ec3dc274b2665078adf6c3 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Wed, 30 May 2018 15:13:17 +0800 Subject: [PATCH 06/14] getWindowById(id) add undefined check --- ElectronNET.Host/api/browserWindows.js | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ElectronNET.Host/api/browserWindows.js b/ElectronNET.Host/api/browserWindows.js index 755cd76..c7e4363 100644 --- a/ElectronNET.Host/api/browserWindows.js +++ b/ElectronNET.Host/api/browserWindows.js @@ -183,16 +183,20 @@ module.exports = function (socket) { global.elesocket.emit('BrowserWindowCreated', window.id); }); socket.on('browserWindowDestroy', function (id) { - getWindowById(id).destroy(); + if (getWindowById(id)) + getWindowById(id).destroy(); }); socket.on('browserWindowClose', function (id) { - getWindowById(id).close(); + if (getWindowById(id)) + getWindowById(id).close(); }); socket.on('browserWindowFocus', function (id) { - getWindowById(id).focus(); + if (getWindowById(id)) + getWindowById(id).focus(); }); socket.on('browserWindowBlur', function (id) { - getWindowById(id).blur(); + if (getWindowById(id)) + getWindowById(id).blur(); }); socket.on('browserWindowIsFocused', function (id) { var isFocused = getWindowById(id).isFocused(); @@ -230,7 +234,8 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isMaximized-completed', isMaximized); }); socket.on('browserWindowMinimize', function (id) { - getWindowById(id).minimize(); + if (getWindowById(id)) + getWindowById(id).minimize(); }); socket.on('browserWindowRestore', function (id) { getWindowById(id).restore(); @@ -240,7 +245,8 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isMinimized-completed', isMinimized); }); socket.on('browserWindowSetFullScreen', function (id, fullscreen) { - getWindowById(id).setFullScreen(fullscreen); + if (getWindowById(id)) + getWindowById(id).setFullScreen(fullscreen); }); socket.on('browserWindowIsFullScreen', function (id) { var isFullScreen = getWindowById(id).isFullScreen(); @@ -312,7 +318,8 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isMovable-completed', movable); }); socket.on('browserWindowSetMinimizable', function (id, minimizable) { - getWindowById(id).setMinimizable(minimizable); + if (getWindowById(id)) + getWindowById(id).setMinimizable(minimizable); }); socket.on('browserWindowIsMinimizable', function (id) { var minimizable = getWindowById(id).isMinimizable(); @@ -347,7 +354,8 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop); }); socket.on('browserWindowCenter', function (id) { - getWindowById(id).center(); + if (getWindowById(id)) + getWindowById(id).center(); }); socket.on('browserWindowSetPosition', function (id, x, y, animate) { getWindowById(id).setPosition(x, y, animate); @@ -357,15 +365,13 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-getPosition-completed', position); }); socket.on('browserWindowSetTitle', function (id, title) { - getWindowById(id).setTitle(title); + if (getWindowById(id)) + getWindowById(id).setTitle(title); }); socket.on('browserWindowGetTitle', function (id) { var title = getWindowById(id).getTitle(); global.elesocket.emit('browserWindow-getTitle-completed', title); }); - socket.on('browserWindowSetTitle', function (id, title) { - getWindowById(id).setTitle(title); - }); socket.on('browserWindowSetSheetOffset', function (id, offsetY, offsetX) { if (offsetX) { getWindowById(id).setSheetOffset(offsetY, offsetX); From 1bf274a73c82ddea53cccae7d404bac41c005e3a Mon Sep 17 00:00:00 2001 From: yaofeng Date: Thu, 31 May 2018 11:05:36 +0800 Subject: [PATCH 07/14] 1. getWindowById(id) add undefined check 2. IpcMain add off --- ElectronNET.API/ElectronNET.API.csproj | 1 + ElectronNET.API/IpcMain.cs | 1 + ElectronNET.Host/api/browserWindows.js | 115 ++++++++++++------------- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/ElectronNET.API/ElectronNET.API.csproj b/ElectronNET.API/ElectronNET.API.csproj index 83e0847..236fb00 100644 --- a/ElectronNET.API/ElectronNET.API.csproj +++ b/ElectronNET.API/ElectronNET.API.csproj @@ -16,6 +16,7 @@ This package contains the API to access the "native" electron API. electron aspnetcore Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png + 1.0.1 diff --git a/ElectronNET.API/IpcMain.cs b/ElectronNET.API/IpcMain.cs index fedc900..2af381b 100644 --- a/ElectronNET.API/IpcMain.cs +++ b/ElectronNET.API/IpcMain.cs @@ -46,6 +46,7 @@ namespace ElectronNET.API public void On(string channel, Action listener) { BridgeConnector.Socket.Emit("registerIpcMainChannel", channel); + BridgeConnector.Socket.Off(channel); BridgeConnector.Socket.On(channel, (args) => { List objectArray = FormatArguments(args); diff --git a/ElectronNET.Host/api/browserWindows.js b/ElectronNET.Host/api/browserWindows.js index c7e4363..49284ad 100644 --- a/ElectronNET.Host/api/browserWindows.js +++ b/ElectronNET.Host/api/browserWindows.js @@ -183,20 +183,16 @@ module.exports = function (socket) { global.elesocket.emit('BrowserWindowCreated', window.id); }); socket.on('browserWindowDestroy', function (id) { - if (getWindowById(id)) - getWindowById(id).destroy(); + getWindowById(id) && getWindowById(id).destroy(); }); socket.on('browserWindowClose', function (id) { - if (getWindowById(id)) - getWindowById(id).close(); + getWindowById(id) && getWindowById(id).close(); }); socket.on('browserWindowFocus', function (id) { - if (getWindowById(id)) - getWindowById(id).focus(); + getWindowById(id) && getWindowById(id).focus(); }); socket.on('browserWindowBlur', function (id) { - if (getWindowById(id)) - getWindowById(id).blur(); + getWindowById(id) && getWindowById(id).blur(); }); socket.on('browserWindowIsFocused', function (id) { var isFocused = getWindowById(id).isFocused(); @@ -207,13 +203,13 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isDestroyed-completed', isDestroyed); }); socket.on('browserWindowShow', function (id) { - getWindowById(id).show(); + getWindowById(id) && getWindowById(id).show(); }); socket.on('browserWindowShowInactive', function (id) { - getWindowById(id).showInactive(); + getWindowById(id) && getWindowById(id).showInactive(); }); socket.on('browserWindowHide', function (id) { - getWindowById(id).hide(); + getWindowById(id) && getWindowById(id).hide(); }); socket.on('browserWindowIsVisible', function (id) { var isVisible = getWindowById(id).isVisible(); @@ -224,45 +220,43 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isModal-completed', isModal); }); socket.on('browserWindowMaximize', function (id) { - getWindowById(id).maximize(); + getWindowById(id) && getWindowById(id).maximize(); }); socket.on('browserWindowUnmaximize', function (id) { - getWindowById(id).unmaximize(); + getWindowById(id) && getWindowById(id).unmaximize(); }); socket.on('browserWindowIsMaximized', function (id) { var isMaximized = getWindowById(id).isMaximized(); global.elesocket.emit('browserWindow-isMaximized-completed', isMaximized); }); socket.on('browserWindowMinimize', function (id) { - if (getWindowById(id)) - getWindowById(id).minimize(); + getWindowById(id) && getWindowById(id).minimize(); }); socket.on('browserWindowRestore', function (id) { - getWindowById(id).restore(); + getWindowById(id) && getWindowById(id).restore(); }); socket.on('browserWindowIsMinimized', function (id) { var isMinimized = getWindowById(id).isMinimized(); global.elesocket.emit('browserWindow-isMinimized-completed', isMinimized); }); socket.on('browserWindowSetFullScreen', function (id, fullscreen) { - if (getWindowById(id)) - getWindowById(id).setFullScreen(fullscreen); + getWindowById(id) && getWindowById(id).setFullScreen(fullscreen); }); socket.on('browserWindowIsFullScreen', function (id) { var isFullScreen = getWindowById(id).isFullScreen(); global.elesocket.emit('browserWindow-isFullScreen-completed', isFullScreen); }); socket.on('browserWindowSetAspectRatio', function (id, aspectRatio, extraSize) { - getWindowById(id).setAspectRatio(aspectRatio, extraSize); + getWindowById(id) && getWindowById(id).setAspectRatio(aspectRatio, extraSize); }); socket.on('browserWindowPreviewFile', function (id, path, displayname) { - getWindowById(id).previewFile(path, displayname); + getWindowById(id) && getWindowById(id).previewFile(path, displayname); }); socket.on('browserWindowCloseFilePreview', function (id) { - getWindowById(id).closeFilePreview(); + getWindowById(id) && getWindowById(id).closeFilePreview(); }); socket.on('browserWindowSetBounds', function (id, bounds, animate) { - getWindowById(id).setBounds(bounds, animate); + getWindowById(id) && getWindowById(id).setBounds(bounds, animate); }); socket.on('browserWindowGetBounds', function (id) { var rectangle = getWindowById(id).getBounds(); @@ -276,97 +270,94 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-getContentBounds-completed', rectangle); }); socket.on('browserWindowSetSize', function (id, width, height, animate) { - getWindowById(id).setSize(width, height, animate); + getWindowById(id) && getWindowById(id).setSize(width, height, animate); }); socket.on('browserWindowGetSize', function (id) { var size = getWindowById(id).getSize(); global.elesocket.emit('browserWindow-getSize-completed', size); }); socket.on('browserWindowSetContentSize', function (id, width, height, animate) { - getWindowById(id).setContentSize(width, height, animate); + getWindowById(id) && getWindowById(id).setContentSize(width, height, animate); }); socket.on('browserWindowGetContentSize', function (id) { var size = getWindowById(id).getContentSize(); global.elesocket.emit('browserWindow-getContentSize-completed', size); }); socket.on('browserWindowSetMinimumSize', function (id, width, height) { - getWindowById(id).setMinimumSize(width, height); + getWindowById(id) && getWindowById(id).setMinimumSize(width, height); }); socket.on('browserWindowGetMinimumSize', function (id) { var size = getWindowById(id).getMinimumSize(); global.elesocket.emit('browserWindow-getMinimumSize-completed', size); }); socket.on('browserWindowSetMaximumSize', function (id, width, height) { - getWindowById(id).setMaximumSize(width, height); + getWindowById(id) && getWindowById(id).setMaximumSize(width, height); }); socket.on('browserWindowGetMaximumSize', function (id) { var size = getWindowById(id).getMaximumSize(); global.elesocket.emit('browserWindow-getMaximumSize-completed', size); }); socket.on('browserWindowSetResizable', function (id, resizable) { - getWindowById(id).setResizable(resizable); + getWindowById(id) && getWindowById(id).setResizable(resizable); }); socket.on('browserWindowIsResizable', function (id) { var resizable = getWindowById(id).isResizable(); global.elesocket.emit('browserWindow-isResizable-completed', resizable); }); socket.on('browserWindowSetMovable', function (id, movable) { - getWindowById(id).setMovable(movable); + getWindowById(id) && getWindowById(id).setMovable(movable); }); socket.on('browserWindowIsMovable', function (id) { var movable = getWindowById(id).isMovable(); global.elesocket.emit('browserWindow-isMovable-completed', movable); }); socket.on('browserWindowSetMinimizable', function (id, minimizable) { - if (getWindowById(id)) - getWindowById(id).setMinimizable(minimizable); + getWindowById(id) && getWindowById(id).setMinimizable(minimizable); }); socket.on('browserWindowIsMinimizable', function (id) { var minimizable = getWindowById(id).isMinimizable(); global.elesocket.emit('browserWindow-isMinimizable-completed', minimizable); }); socket.on('browserWindowSetMaximizable', function (id, maximizable) { - getWindowById(id).setMaximizable(maximizable); + getWindowById(id) && getWindowById(id).setMaximizable(maximizable); }); socket.on('browserWindowIsMaximizable', function (id) { var maximizable = getWindowById(id).isMaximizable(); global.elesocket.emit('browserWindow-isMaximizable-completed', maximizable); }); socket.on('browserWindowSetFullScreenable', function (id, fullscreenable) { - getWindowById(id).setFullScreenable(fullscreenable); + getWindowById(id) && getWindowById(id).setFullScreenable(fullscreenable); }); socket.on('browserWindowIsFullScreenable', function (id) { var fullscreenable = getWindowById(id).isFullScreenable(); global.elesocket.emit('browserWindow-isFullScreenable-completed', fullscreenable); }); socket.on('browserWindowSetClosable', function (id, closable) { - getWindowById(id).setClosable(closable); + getWindowById(id) && getWindowById(id).setClosable(closable); }); socket.on('browserWindowIsClosable', function (id) { var closable = getWindowById(id).isClosable(); global.elesocket.emit('browserWindow-isClosable-completed', closable); }); socket.on('browserWindowSetAlwaysOnTop', function (id, flag, level, relativeLevel) { - getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel); + getWindowById(id) && getWindowById(id).setAlwaysOnTop(flag, level, relativeLevel); }); socket.on('browserWindowIsAlwaysOnTop', function (id) { var isAlwaysOnTop = getWindowById(id).isAlwaysOnTop(); global.elesocket.emit('browserWindow-isAlwaysOnTop-completed', isAlwaysOnTop); }); socket.on('browserWindowCenter', function (id) { - if (getWindowById(id)) - getWindowById(id).center(); + getWindowById(id) && getWindowById(id).center(); }); socket.on('browserWindowSetPosition', function (id, x, y, animate) { - getWindowById(id).setPosition(x, y, animate); + getWindowById(id) && getWindowById(id).setPosition(x, y, animate); }); socket.on('browserWindowGetPosition', function (id) { var position = getWindowById(id).getPosition(); global.elesocket.emit('browserWindow-getPosition-completed', position); }); socket.on('browserWindowSetTitle', function (id, title) { - if (getWindowById(id)) - getWindowById(id).setTitle(title); + getWindowById(id) && getWindowById(id).setTitle(title); }); socket.on('browserWindowGetTitle', function (id) { var title = getWindowById(id).getTitle(); @@ -374,20 +365,20 @@ module.exports = function (socket) { }); socket.on('browserWindowSetSheetOffset', function (id, offsetY, offsetX) { if (offsetX) { - getWindowById(id).setSheetOffset(offsetY, offsetX); + getWindowById(id) && getWindowById(id).setSheetOffset(offsetY, offsetX); } else { - getWindowById(id).setSheetOffset(offsetY); + getWindowById(id) && getWindowById(id).setSheetOffset(offsetY); } }); socket.on('browserWindowFlashFrame', function (id, flag) { - getWindowById(id).flashFrame(flag); + getWindowById(id) && getWindowById(id).flashFrame(flag); }); socket.on('browserWindowSetSkipTaskbar', function (id, skip) { - getWindowById(id).setSkipTaskbar(skip); + getWindowById(id) && getWindowById(id).setSkipTaskbar(skip); }); socket.on('browserWindowSetKiosk', function (id, flag) { - getWindowById(id).setKiosk(flag); + getWindowById(id) && getWindowById(id).setKiosk(flag); }); socket.on('browserWindowIsKiosk', function (id) { var isKiosk = getWindowById(id).isKiosk(); @@ -401,23 +392,23 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-getRepresentedFilename-completed', pathname); }); socket.on('browserWindowSetDocumentEdited', function (id, edited) { - getWindowById(id).setDocumentEdited(edited); + getWindowById(id) && getWindowById(id).setDocumentEdited(edited); }); socket.on('browserWindowIsDocumentEdited', function (id) { var edited = getWindowById(id).isDocumentEdited(); global.elesocket.emit('browserWindow-isDocumentEdited-completed', edited); }); socket.on('browserWindowFocusOnWebView', function (id) { - getWindowById(id).focusOnWebView(); + getWindowById(id) && getWindowById(id).focusOnWebView(); }); socket.on('browserWindowBlurWebView', function (id) { - getWindowById(id).blurWebView(); + getWindowById(id) && getWindowById(id).blurWebView(); }); socket.on('browserWindowLoadURL', function (id, url, options) { getWindowById(id).loadURL(url, options); }); socket.on('browserWindowReload', function (id) { - getWindowById(id).reload(); + getWindowById(id) && getWindowById(id).reload(); }); socket.on('browserWindowSetMenu', function (id, menuItems) { var menu = null; @@ -440,10 +431,10 @@ module.exports = function (socket) { }); } socket.on('browserWindowSetProgressBar', function (id, progress) { - getWindowById(id).setProgressBar(progress); + getWindowById(id) && getWindowById(id).setProgressBar(progress); }); socket.on('browserWindowSetHasShadow', function (id, hasShadow) { - getWindowById(id).setHasShadow(hasShadow); + getWindowById(id) && getWindowById(id).setHasShadow(hasShadow); }); socket.on('browserWindowHasShadow', function (id) { var hasShadow = getWindowById(id).hasShadow(); @@ -461,19 +452,19 @@ module.exports = function (socket) { global.elesocket.emit('browserWindowSetThumbarButtons-completed', success); }); socket.on('browserWindowSetThumbnailClip', function (id, rectangle) { - getWindowById(id).setThumbnailClip(rectangle); + getWindowById(id) && getWindowById(id).setThumbnailClip(rectangle); }); socket.on('browserWindowSetThumbnailToolTip', function (id, toolTip) { - getWindowById(id).setThumbnailToolTip(toolTip); + getWindowById(id) && getWindowById(id).setThumbnailToolTip(toolTip); }); socket.on('browserWindowSetAppDetails', function (id, options) { - getWindowById(id).setAppDetails(options); + getWindowById(id) && getWindowById(id).setAppDetails(options); }); socket.on('browserWindowShowDefinitionForSelection', function (id) { - getWindowById(id).showDefinitionForSelection(); + getWindowById(id) && getWindowById(id).showDefinitionForSelection(); }); socket.on('browserWindowSetAutoHideMenuBar', function (id, hide) { - getWindowById(id).setAutoHideMenuBar(hide); + getWindowById(id) && getWindowById(id).setAutoHideMenuBar(hide); }); socket.on('browserWindowIsMenuBarAutoHide', function (id) { var isMenuBarAutoHide = getWindowById(id).isMenuBarAutoHide(); @@ -487,24 +478,24 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-isMenuBarVisible-completed', isMenuBarVisible); }); socket.on('browserWindowSetVisibleOnAllWorkspaces', function (id, visible) { - getWindowById(id).setVisibleOnAllWorkspaces(visible); + getWindowById(id) && getWindowById(id).setVisibleOnAllWorkspaces(visible); }); socket.on('browserWindowIsVisibleOnAllWorkspaces', function (id) { var isVisibleOnAllWorkspaces = getWindowById(id).isVisibleOnAllWorkspaces(); global.elesocket.emit('browserWindow-isVisibleOnAllWorkspaces-completed', isVisibleOnAllWorkspaces); }); socket.on('browserWindowSetIgnoreMouseEvents', function (id, ignore) { - getWindowById(id).setIgnoreMouseEvents(ignore); + getWindowById(id) && getWindowById(id).setIgnoreMouseEvents(ignore); }); socket.on('browserWindowSetContentProtection', function (id, enable) { - getWindowById(id).setContentProtection(enable); + getWindowById(id) && getWindowById(id).setContentProtection(enable); }); socket.on('browserWindowSetFocusable', function (id, focusable) { - getWindowById(id).setFocusable(focusable); + getWindowById(id) && getWindowById(id).setFocusable(focusable); }); socket.on('browserWindowSetParentWindow', function (id, parent) { var browserWindow = electron_1.BrowserWindow.fromId(parent.id); - getWindowById(id).setParentWindow(browserWindow); + getWindowById(id) && getWindowById(id).setParentWindow(browserWindow); }); socket.on('browserWindowGetParentWindow', function (id) { var browserWindow = getWindowById(id).getParentWindow(); @@ -519,10 +510,10 @@ module.exports = function (socket) { global.elesocket.emit('browserWindow-getChildWindows-completed', ids); }); socket.on('browserWindowSetAutoHideCursor', function (id, autoHide) { - getWindowById(id).setAutoHideCursor(autoHide); + getWindowById(id) && getWindowById(id).setAutoHideCursor(autoHide); }); socket.on('browserWindowSetVibrancy', function (id, type) { - getWindowById(id).setVibrancy(type); + getWindowById(id) && getWindowById(id).setVibrancy(type); }); function getWindowById(id) { for (var index = 0; index < windows.length; index++) { From 354b4f09e61ab6e69587e837fa2d84ab5b4697e2 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Wed, 13 Jun 2018 15:03:12 +0800 Subject: [PATCH 08/14] add loadingWindow --- ElectronNET.CLI/ElectronNET.CLI.csproj | 2 +- ElectronNET.Host/main.js | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index 4b963b1..0867fb6 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -9,7 +9,7 @@ true ..\artifacts ElectronNET.CLI - 1.0.2 + 1.0.4 Gregor Biswanger, Robert Muehsig Electron.NET diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 09f4888..92a75d4 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -1,4 +1,5 @@ const { app } = require('electron'); +const { BrowserWindow } = require('electron') const fs = require('fs'); const path = require('path'); const process = require('child_process').spawn; @@ -6,8 +7,13 @@ const portfinder = require('detect-port'); let io, browserWindows, ipc, apiProcess, loadURL; let appApi, menu, dialog, notification, tray, webContents; let globalShortcut, shell, screen, clipboard; +let loadingWindow; app.on('ready', () => { + + // yf add + startLoadingWindow(); + portfinder(8000, (error, port) => { startSocketApiBridge(port); }); @@ -59,10 +65,38 @@ function startAspCoreBackend(electronPort) { apiProcess.stdout.on('data', (data) => { var text = data.toString(); console.log(`stdout: ${data.toString()}`); + + if (data.toString().indexOf("MainWindowShowed") > -1 && loadingWindow && !loadingWindow.isDestroyed()) { + loadingWindow.close(); + } }); }); } +function startLoadingWindow() { + const manifestFile = require("./bin/electron.manifest.json"); + let loadingUrl = manifestFile.loadingUrl; + let icon = manifestFile.icon; + if (loadingUrl) { + loadingWindow = new BrowserWindow({ + width: 400, + height: 435, + transparent: true, + frame: false, + show: false, + devTools: true, + icon: path.join(__dirname, icon) + }) + loadingWindow.loadURL(loadingUrl); + loadingWindow.once('ready-to-show', () => { + loadingWindow.show() + }) + loadingWindow.on('closed', () => { + loadingWindow = null + }) + } +} + //app.on('activate', () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. From a874243c9d59316f17efa6409d22abd58c2ab473 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Wed, 13 Jun 2018 15:12:41 +0800 Subject: [PATCH 09/14] loadingWindow add devTools --- ElectronNET.Host/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 92a75d4..05fffba 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -79,14 +79,17 @@ function startLoadingWindow() { let icon = manifestFile.icon; if (loadingUrl) { loadingWindow = new BrowserWindow({ - width: 400, - height: 435, + width: manifestFile.width, + height: manifestFile.height, transparent: true, frame: false, show: false, devTools: true, icon: path.join(__dirname, icon) }) + if (manifestFile.devTools) { + loadingWindow.webContents.openDevTools(); + } loadingWindow.loadURL(loadingUrl); loadingWindow.once('ready-to-show', () => { loadingWindow.show() From 8e38c1f79dff64660ef35e1890a948504c0f8b40 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Thu, 14 Jun 2018 10:47:08 +0800 Subject: [PATCH 10/14] add makeSingleInstance --- ElectronNET.Host/main.js | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 05fffba..f54b930 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -1,5 +1,7 @@ const { app } = require('electron'); +// yf add const { BrowserWindow } = require('electron') + const fs = require('fs'); const path = require('path'); const process = require('child_process').spawn; @@ -7,7 +9,22 @@ const portfinder = require('detect-port'); let io, browserWindows, ipc, apiProcess, loadURL; let appApi, menu, dialog, notification, tray, webContents; let globalShortcut, shell, screen, clipboard; + +// yf add let loadingWindow; +let mainWindowId; + +// yf add +const manifestJsonFile = require("./bin/electron.manifest.json"); +if (manifestJsonFile.singleInstance) { + const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => { + mainWindowId && BrowserWindow.fromId(mainWindowId) && BrowserWindow.fromId(mainWindowId).show(); + }); + if (shouldQuit) { + app.quit(); + return; + } +} app.on('ready', () => { @@ -68,26 +85,26 @@ function startAspCoreBackend(electronPort) { if (data.toString().indexOf("MainWindowShowed") > -1 && loadingWindow && !loadingWindow.isDestroyed()) { loadingWindow.close(); + mainWindowId = parseInt(data.toString().replace("MainWindowShowed:", "").trim()) } }); }); } function startLoadingWindow() { - const manifestFile = require("./bin/electron.manifest.json"); - let loadingUrl = manifestFile.loadingUrl; - let icon = manifestFile.icon; + let loadingUrl = manifestJsonFile.loadingUrl; + let icon = manifestJsonFile.icon; if (loadingUrl) { loadingWindow = new BrowserWindow({ - width: manifestFile.width, - height: manifestFile.height, + width: manifestJsonFile.width, + height: manifestJsonFile.height, transparent: true, frame: false, show: false, devTools: true, icon: path.join(__dirname, icon) }) - if (manifestFile.devTools) { + if (manifestJsonFile.devTools) { loadingWindow.webContents.openDevTools(); } loadingWindow.loadURL(loadingUrl); From e7a9ee07e02bcbe12264680d80dbaadee94a71fe Mon Sep 17 00:00:00 2001 From: yaofeng Date: Thu, 14 Jun 2018 13:11:42 +0800 Subject: [PATCH 11/14] update manifestFile setting --- ElectronNET.Host/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index f54b930..31eb482 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -83,14 +83,18 @@ function startAspCoreBackend(electronPort) { var text = data.toString(); console.log(`stdout: ${data.toString()}`); - if (data.toString().indexOf("MainWindowShowed") > -1 && loadingWindow && !loadingWindow.isDestroyed()) { + // yf add + if (text.indexOf(manifestFile.mainWindowShowed) > -1 && + loadingWindow && !loadingWindow.isDestroyed()) { loadingWindow.close(); - mainWindowId = parseInt(data.toString().replace("MainWindowShowed:", "").trim()) + + mainWindowId = parseInt(text.replace(`${manifestFile.mainWindowShowed}:`, "").trim()); } }); }); } +// yf add function startLoadingWindow() { let loadingUrl = manifestJsonFile.loadingUrl; let icon = manifestJsonFile.icon; From fcbefa62caf8e0fa46ea28615f37db0c9e06068a Mon Sep 17 00:00:00 2001 From: yaofeng Date: Sat, 14 Jul 2018 13:50:45 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E4=B8=AD=E6=96=87=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ElectronNET.API/Dialog.cs | 9 ++++++++- ElectronNET.API/ElectronNET.API.csproj | 5 +++-- ElectronNET.CLI/ElectronNET.CLI.csproj | 2 +- ElectronNET.Host/api/dialog.js | 10 ++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ElectronNET.API/Dialog.cs b/ElectronNET.API/Dialog.cs index cb5b520..1398483 100644 --- a/ElectronNET.API/Dialog.cs +++ b/ElectronNET.API/Dialog.cs @@ -3,7 +3,9 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; using System; +using System.Collections.Generic; using System.Threading.Tasks; +using System.Web; namespace ElectronNET.API { @@ -54,7 +56,12 @@ namespace ElectronNET.API BridgeConnector.Socket.Off("showOpenDialogComplete" + guid); var result = ((JArray)filePaths).ToObject(); - taskCompletionSource.SetResult(result); + var list = new List(); + foreach (var item in result) + { + list.Add(HttpUtility.UrlDecode(item)); + } + taskCompletionSource.SetResult(list.ToArray()); }); diff --git a/ElectronNET.API/ElectronNET.API.csproj b/ElectronNET.API/ElectronNET.API.csproj index 236fb00..00eac8c 100644 --- a/ElectronNET.API/ElectronNET.API.csproj +++ b/ElectronNET.API/ElectronNET.API.csproj @@ -16,7 +16,7 @@ This package contains the API to access the "native" electron API. electron aspnetcore Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md https://raw.githubusercontent.com/ElectronNET/Electron.NET/master/assets/images/electron.net-logo-square.png - 1.0.1 + 1.0.0.2 @@ -32,8 +32,9 @@ This package contains the API to access the "native" electron API. + - + diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index 0867fb6..758973a 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -9,7 +9,7 @@ true ..\artifacts ElectronNET.CLI - 1.0.4 + 1.0.4.1 Gregor Biswanger, Robert Muehsig Electron.NET diff --git a/ElectronNET.Host/api/dialog.js b/ElectronNET.Host/api/dialog.js index 4d93400..0e762ff 100644 --- a/ElectronNET.Host/api/dialog.js +++ b/ElectronNET.Host/api/dialog.js @@ -20,13 +20,19 @@ module.exports = function (socket) { socket.on('showOpenDialog', function (browserWindow, options, guid) { var window = electron_1.BrowserWindow.fromId(browserWindow.id); electron_1.dialog.showOpenDialog(window, options, function (filePaths) { - global.elesocket.emit('showOpenDialogComplete' + guid, filePaths || []); + filePaths = filePaths || []; + var encodeFilePaths = []; + filePaths.forEach((item, index) => { + encodeFilePaths.push(encodeURIComponent(item)); + }); + global.elesocket.emit('showOpenDialogComplete' + guid, encodeFilePaths); }); }); socket.on('showSaveDialog', function (browserWindow, options, guid) { var window = electron_1.BrowserWindow.fromId(browserWindow.id); electron_1.dialog.showSaveDialog(window, options, function (filename) { - global.elesocket.emit('showSaveDialogComplete' + guid, filename || ''); + filename = encodeURIComponent(filename || ''); + global.elesocket.emit('showSaveDialogComplete' + guid, filename); }); }); socket.on('showErrorBox', function (title, content) { From 86aae5ee18163c5ca57c1a98db11ae5a59ee9142 Mon Sep 17 00:00:00 2001 From: yaofeng Date: Sat, 14 Jul 2018 15:55:09 +0800 Subject: [PATCH 13/14] finish pack check --- ElectronNET.CLI/ElectronNET.CLI.csproj | 2 +- ElectronNET.Host/main.js | 45 ++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index 758973a..c594005 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -9,7 +9,7 @@ true ..\artifacts ElectronNET.CLI - 1.0.4.1 + 1.0.4.2 Gregor Biswanger, Robert Muehsig Electron.NET diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index 31eb482..cf63b5d 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -1,18 +1,19 @@ -const { app } = require('electron'); +const { app } = require('electron'); // yf add -const { BrowserWindow } = require('electron') +const { BrowserWindow, dialog, shell } = require('electron') const fs = require('fs'); const path = require('path'); const process = require('child_process').spawn; const portfinder = require('detect-port'); let io, browserWindows, ipc, apiProcess, loadURL; -let appApi, menu, dialog, notification, tray, webContents; -let globalShortcut, shell, screen, clipboard; +let appApi, menu, dialogApi, notification, tray, webContents; +let globalShortcut, shellApi, screen, clipboard; // yf add let loadingWindow; let mainWindowId; +let countDownInterval; // yf add const manifestJsonFile = require("./bin/electron.manifest.json"); @@ -52,12 +53,12 @@ function startSocketApiBridge(port) { browserWindows = require('./api/browserWindows')(socket); ipc = require('./api/ipc')(socket); menu = require('./api/menu')(socket); - dialog = require('./api/dialog')(socket); + dialogApi = require('./api/dialog')(socket); notification = require('./api/notification')(socket); tray = require('./api/tray')(socket); webContents = require('./api/webContents')(socket); globalShortcut = require('./api/globalShortcut')(socket); - shell = require('./api/shell')(socket); + shellApi = require('./api/shell')(socket); screen = require('./api/screen')(socket); clipboard = require('./api/clipboard')(socket); }); @@ -114,13 +115,45 @@ function startLoadingWindow() { loadingWindow.loadURL(loadingUrl); loadingWindow.once('ready-to-show', () => { loadingWindow.show() + + // 激活倒计时 + activeCountDowInterval(manifestJsonFile) }) loadingWindow.on('closed', () => { loadingWindow = null + + clearInterval(countDownInterval) }) } } +function activeCountDowInterval(manifestJsonFile) { + if (!manifestJsonFile.timeout || !manifestJsonFile.timeout.limit) + return + + let limitSecond = manifestJsonFile.timeout.limit + let currentSecond = 0; + countDownInterval = setInterval(() => { + currentSecond++; + if (currentSecond < limitSecond) + return; + + clearInterval(countDownInterval); + + dialog.showMessageBox(loadingWindow, { + type: 'error', + buttons: ["前往安装"], + title: '文件缺失提示', + message: '计算机缺少组件无法启动该程序,点击前往安装组件后重试', + }, (res, isChecked) => { + if (manifestJsonFile.timeout.help) + shell.openExternal(manifestJsonFile.timeout.help) + app.quit(); + }); + + }, 1000) +} + //app.on('activate', () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. From 85127be49e39c95233f4d77e3be950703ca9879d Mon Sep 17 00:00:00 2001 From: yaofeng Date: Mon, 16 Jul 2018 14:07:51 +0800 Subject: [PATCH 14/14] config --- ElectronNET.Host/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ElectronNET.Host/main.js b/ElectronNET.Host/main.js index cf63b5d..b3d8550 100644 --- a/ElectronNET.Host/main.js +++ b/ElectronNET.Host/main.js @@ -141,10 +141,10 @@ function activeCountDowInterval(manifestJsonFile) { clearInterval(countDownInterval); dialog.showMessageBox(loadingWindow, { - type: 'error', - buttons: ["前往安装"], - title: '文件缺失提示', - message: '计算机缺少组件无法启动该程序,点击前往安装组件后重试', + type: manifestJsonFile.timeout.messageBox.type || 'error', + buttons: manifestJsonFile.timeout.messageBox.buttons || ["前往安装"], + title: manifestJsonFile.timeout.messageBox.title || '文件缺失提示', + message: manifestJsonFile.timeout.messageBox.message || '计算机缺少组件无法启动该程序,点击前往安装组件后重试', }, (res, isChecked) => { if (manifestJsonFile.timeout.help) shell.openExternal(manifestJsonFile.timeout.help)