mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
multi windows
This commit is contained in:
parent
6bf9b9423a
commit
98b18ea2b5
3 changed files with 22 additions and 22 deletions
41
electron.js
41
electron.js
|
@ -123,7 +123,8 @@ function createMainWindow () {
|
|||
);
|
||||
};
|
||||
|
||||
registerIpcEvents(mainWindow);
|
||||
registerIpcEventsMain();
|
||||
registerIpcEventsWindow();
|
||||
|
||||
UpdateManager.init(mainWindow);
|
||||
UpdateManager.exit = exit;
|
||||
|
@ -152,25 +153,14 @@ function createChildWindow (route) {
|
|||
};
|
||||
});
|
||||
|
||||
registerIpcEvents(win);
|
||||
registerIpcEventsWindow();
|
||||
};
|
||||
|
||||
function registerIpcEvents (win) {
|
||||
ipcMain.on('appLoaded', () => { Util.send(win, 'init', dataPath.join('/'), ConfigManager.config, Util.isDarkTheme()); });
|
||||
function registerIpcEventsMain () {
|
||||
ipcMain.on('exit', (e, relaunch) => { exit(relaunch); });
|
||||
ipcMain.on('shutdown', (e, relaunch) => { shutdown(relaunch); });
|
||||
ipcMain.on('configSet', (e, config) => { setConfig(config); });
|
||||
|
||||
ipcMain.on('keytarSet', (e, key, value) => {
|
||||
if (key && value) {
|
||||
keytar.setPassword(KEYTAR_SERVICE, key, value);
|
||||
};
|
||||
});
|
||||
ipcMain.on('keytarGet', (e, key) => {
|
||||
keytar.getPassword(KEYTAR_SERVICE, key).then((value) => { Util.send(win, 'keytarGet', key, value); });
|
||||
});
|
||||
ipcMain.on('keytarDelete', (e, key) => { keytar.deletePassword(KEYTAR_SERVICE, key); });
|
||||
|
||||
ipcMain.on('updateDownload', (e) => { UpdateManager.download(); });
|
||||
ipcMain.on('updateConfirm', (e) => { exit(true); });
|
||||
ipcMain.on('updateCancel', (e) => { UpdateManager.cancel(); });
|
||||
|
@ -179,21 +169,28 @@ function registerIpcEvents (win) {
|
|||
ipcMain.on('pathOpen', async (e, v) => { shell.openPath(v); });
|
||||
ipcMain.on('windowOpen', (e, v) => { createChildWindow(v); });
|
||||
|
||||
ipcMain.on('download', async (e, url) => { await download(win, url, { saveAs: true }); });
|
||||
ipcMain.on('keytarSet', (e, key, value) => {
|
||||
if (key && value) {
|
||||
keytar.setPassword(KEYTAR_SERVICE, key, value);
|
||||
};
|
||||
});
|
||||
ipcMain.on('keytarDelete', (e, key) => { keytar.deletePassword(KEYTAR_SERVICE, key); });
|
||||
};
|
||||
|
||||
ipcMain.on('proxyEvent', function () {
|
||||
let args = Object.values(arguments);
|
||||
function registerIpcEventsWindow () {
|
||||
ipcMain.on('appLoaded', () => { Util.send(BrowserWindow.getFocusedWindow(), 'init', dataPath.join('/'), ConfigManager.config, Util.isDarkTheme()); });
|
||||
|
||||
args.shift();
|
||||
send.apply(this, args);
|
||||
ipcMain.on('keytarGet', (e, key) => {
|
||||
keytar.getPassword(KEYTAR_SERVICE, key).then((value) => { Util.send(BrowserWindow.getFocusedWindow(), 'keytarGet', key, value); });
|
||||
});
|
||||
|
||||
ipcMain.on('winCommand', (e, cmd, param) => { WindowManager.command(win, cmd, param); });
|
||||
ipcMain.on('download', async (e, url) => { await download(BrowserWindow.getFocusedWindow(), url, { saveAs: true }); });
|
||||
ipcMain.on('winCommand', (e, cmd, param) => { WindowManager.command(BrowserWindow.getFocusedWindow(), cmd, param); });
|
||||
};
|
||||
|
||||
function setConfig (obj, callBack) {
|
||||
ConfigManager.set(obj, (err) => {
|
||||
Util.send(mainWindow, 'config', ConfigManager.config);
|
||||
Util.send(BrowserWindow.getFocusedWindow(), 'config', ConfigManager.config);
|
||||
|
||||
if (callBack) {
|
||||
callBack(err);
|
||||
|
@ -220,7 +217,7 @@ app.on('second-instance', (event, argv, cwd) => {
|
|||
if (!is.macos) {
|
||||
deeplinkingUrl = argv.find((arg) => arg.startsWith(`${protocol}://`));
|
||||
if (deeplinkingUrl) {
|
||||
Util.send(mainWindow, 'route', Util.getRouteFromUrl(deeplinkingUrl));
|
||||
Util.send(BrowserWindow.getFocusedWindow(), 'route', Util.getRouteFromUrl(deeplinkingUrl));
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -86,6 +86,8 @@ class Util {
|
|||
args.shift();
|
||||
win.webContents.send.apply(win.webContents, args);
|
||||
};
|
||||
|
||||
console.log('[Send]', win, args);
|
||||
};
|
||||
|
||||
savePage (win, exportPath, name) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
.path {
|
||||
width: 66%; display: inline-block; border-radius: 6px; height: 28px; line-height: 26px; cursor: pointer; transition: $transitionFast;
|
||||
@include text-overflow-nw; padding: 0px 6px;
|
||||
}
|
||||
|
||||
.tabs { white-space: nowrap; background: $colorLightGrey; display: inline-block; height: 28px; padding: 2px; border-radius: 6px; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue