Оптимизация ядра, исправление гонки потоков при получении версии
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BrowserWindow, shell, app, ipcMain, nativeTheme, screen, powerMonitor } from 'electron'
|
||||
import { BrowserWindow, shell, ipcMain, nativeTheme, screen, powerMonitor } from 'electron'
|
||||
import { join } from 'path'
|
||||
import fs from 'fs'
|
||||
import { WORKING_DIR } from './constants';
|
||||
@@ -79,11 +79,6 @@ export function foundationIpcRegistration(mainWindow: BrowserWindow) {
|
||||
ipcMain.removeAllListeners("write-file");
|
||||
ipcMain.removeAllListeners("read-file");
|
||||
ipcMain.removeAllListeners("mkdir");
|
||||
ipcMain.removeHandler("get-core-version");
|
||||
ipcMain.removeHandler("get-arch");
|
||||
ipcMain.removeAllListeners("get-user-dir");
|
||||
ipcMain.removeHandler("get-downloads-path")
|
||||
ipcMain.removeHandler("get-app-path");
|
||||
ipcMain.removeHandler('open-dev-tools');
|
||||
ipcMain.removeHandler('window-state');
|
||||
ipcMain.removeHandler('window-toggle');
|
||||
@@ -92,14 +87,6 @@ export function foundationIpcRegistration(mainWindow: BrowserWindow) {
|
||||
ipcMain.removeHandler('showItemInFolder');
|
||||
ipcMain.removeHandler('openExternal');
|
||||
|
||||
ipcMain.handle('showItemInFolder', (_, fullPath: string) => {
|
||||
shell.showItemInFolder(fullPath);
|
||||
});
|
||||
|
||||
ipcMain.handle('openExternal', (_, url: string) => {
|
||||
shell.openExternal(url);
|
||||
});
|
||||
|
||||
ipcMain.handle('open-dev-tools', () => {
|
||||
if (mainWindow.webContents.isDevToolsOpened()) {
|
||||
return;
|
||||
@@ -208,27 +195,4 @@ export function foundationIpcRegistration(mainWindow: BrowserWindow) {
|
||||
mainWindow.webContents.send("mkdir-reply");
|
||||
});
|
||||
});
|
||||
/**
|
||||
* Change to get-core-version
|
||||
*/
|
||||
ipcMain.handle("get-core-version", () => {
|
||||
return app.getVersion();
|
||||
});
|
||||
|
||||
ipcMain.handle("get-arch", () => {
|
||||
return process.arch;
|
||||
})
|
||||
|
||||
ipcMain.on("get-user-dir", () => {
|
||||
const userDir = app.getPath("userData");
|
||||
mainWindow.webContents.send("get-user-dir-reply", userDir);
|
||||
});
|
||||
|
||||
ipcMain.handle("get-app-path", () => {
|
||||
return app.getAppPath();
|
||||
});
|
||||
|
||||
ipcMain.handle("get-downloads-path", () => {
|
||||
return app.getPath("downloads");
|
||||
});
|
||||
}
|
||||
|
||||
34
lib/main/ipcs/ipcCore.ts
Normal file
34
lib/main/ipcs/ipcCore.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { app, ipcMain, shell } from "electron";
|
||||
|
||||
ipcMain.handle("ipcCore:getCoreVersion", () => {
|
||||
return app.getVersion();
|
||||
});
|
||||
|
||||
ipcMain.handle("ipcCore:getArch", () => {
|
||||
return process.arch;
|
||||
})
|
||||
|
||||
ipcMain.handle("ipcCore:getUserDir", () => {
|
||||
const userDir = app.getPath("userData");
|
||||
return userDir;
|
||||
});
|
||||
|
||||
ipcMain.handle("ipcCore:getAppPath", () => {
|
||||
return app.getAppPath();
|
||||
});
|
||||
|
||||
ipcMain.handle("ipcCore:getDownloadsPath", () => {
|
||||
return app.getPath("downloads");
|
||||
});
|
||||
|
||||
ipcMain.handle('ipcCore:showItemInFolder', (_, fullPath: string) => {
|
||||
shell.showItemInFolder(fullPath);
|
||||
});
|
||||
|
||||
ipcMain.handle('ipcCore:openExternal', (_, url: string) => {
|
||||
shell.openExternal(url);
|
||||
});
|
||||
|
||||
ipcMain.handle('ipcCore:getPlatform', () => {
|
||||
return process.platform;
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import './ipcs/ipcFilestorage'
|
||||
import './ipcs/ipcUpdate'
|
||||
import './ipcs/ipcNotification'
|
||||
import './ipcs/ipcDevice'
|
||||
import './ipcs/ipcCore'
|
||||
import { Tray } from 'electron/main'
|
||||
import { join } from 'path'
|
||||
import { Logger } from './logger'
|
||||
|
||||
Reference in New Issue
Block a user