mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
multiple windows
This commit is contained in:
parent
98b18ea2b5
commit
a6480206cd
3 changed files with 43 additions and 36 deletions
34
electron.js
34
electron.js
|
@ -107,7 +107,7 @@ nativeTheme.on('updated', () => {
|
|||
});
|
||||
|
||||
function createMainWindow () {
|
||||
mainWindow = WindowManager.createMain({ withState: true });
|
||||
mainWindow = WindowManager.createMain({ withState: true, route: Util.getRouteFromUrl(deeplinkingUrl) });
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
|
@ -123,6 +123,27 @@ function createMainWindow () {
|
|||
);
|
||||
};
|
||||
|
||||
mainWindow.on('close', (e) => {
|
||||
Util.log('info', 'closeMain: ' + app.isQuiting);
|
||||
|
||||
if (app.isQuiting) {
|
||||
return;
|
||||
};
|
||||
|
||||
e.preventDefault();
|
||||
if (!is.linux) {
|
||||
if (win.isFullScreen()) {
|
||||
win.setFullScreen(false);
|
||||
win.once('leave-full-screen', () => { win.hide(); });
|
||||
} else {
|
||||
win.hide();
|
||||
};
|
||||
} else {
|
||||
this.exit(false);
|
||||
};
|
||||
return false;
|
||||
});
|
||||
|
||||
registerIpcEventsMain();
|
||||
registerIpcEventsWindow();
|
||||
|
||||
|
@ -143,16 +164,7 @@ function createMainWindow () {
|
|||
};
|
||||
|
||||
function createChildWindow (route) {
|
||||
const win = WindowManager.createMain({ withState: false });
|
||||
|
||||
win.once('ready-to-show', () => {
|
||||
win.show();
|
||||
|
||||
if (route) {
|
||||
Util.send(win, 'route', route);
|
||||
};
|
||||
});
|
||||
|
||||
WindowManager.createMain({ withState: false, route: route });
|
||||
registerIpcEventsWindow();
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ const port = process.env.SERVER_PORT;
|
|||
const MenuManager = require('./menu.js');
|
||||
const Util = require('./util.js');
|
||||
|
||||
const DEFAULT_WIDTH = 800;
|
||||
const DEFAULT_HEIGHT = 600;
|
||||
const MIN_WIDTH = 752;
|
||||
const MIN_HEIGHT = 480;
|
||||
|
||||
|
@ -43,14 +45,17 @@ class WindowManager {
|
|||
};
|
||||
|
||||
createMain (options) {
|
||||
const { withState } = options;
|
||||
const { withState, route } = options;
|
||||
|
||||
const image = nativeImage.createFromPath(path.join(Util.imagePath(), 'icon512x512.png'));
|
||||
const state = windowStateKeeper({ defaultWidth: 800, defaultHeight: 600 });
|
||||
const state = windowStateKeeper({ defaultWidth: DEFAULT_WIDTH, defaultHeight: DEFAULT_HEIGHT });
|
||||
|
||||
let param = {
|
||||
minWidth: MIN_WIDTH,
|
||||
minHeight: MIN_HEIGHT,
|
||||
width: DEFAULT_WIDTH,
|
||||
height: DEFAULT_HEIGHT,
|
||||
|
||||
webPreferences: {
|
||||
nativeWindowOpen: true,
|
||||
nodeIntegration: true,
|
||||
|
@ -101,30 +106,17 @@ class WindowManager {
|
|||
win.loadFile('./dist/index.html');
|
||||
};
|
||||
|
||||
win.once('ready-to-show', () => {
|
||||
win.show();
|
||||
|
||||
if (route) {
|
||||
Util.send(win, 'route', route);
|
||||
};
|
||||
});
|
||||
|
||||
win.on('enter-full-screen', () => { Util.send(win, 'enter-full-screen'); });
|
||||
win.on('leave-full-screen', () => { Util.send(win, 'leave-full-screen'); });
|
||||
|
||||
win.on('close', (e) => {
|
||||
Util.log('info', 'close: ' + app.isQuiting);
|
||||
|
||||
if (app.isQuiting) {
|
||||
return;
|
||||
};
|
||||
|
||||
e.preventDefault();
|
||||
if (!is.linux) {
|
||||
if (win.isFullScreen()) {
|
||||
win.setFullScreen(false);
|
||||
win.once('leave-full-screen', () => { win.hide(); });
|
||||
} else {
|
||||
win.hide();
|
||||
};
|
||||
} else {
|
||||
this.exit(false);
|
||||
};
|
||||
return false;
|
||||
});
|
||||
|
||||
return win;
|
||||
};
|
||||
|
||||
|
|
|
@ -332,7 +332,10 @@ class App extends React.Component<Props, State> {
|
|||
keyboard.init();
|
||||
analytics.init();
|
||||
|
||||
this.setIpcEvents();
|
||||
this.registerIpcEvents();
|
||||
|
||||
$(window).off('beforeunload').on('beforeunload', () => {
|
||||
});
|
||||
};
|
||||
|
||||
initStorage () {
|
||||
|
@ -400,7 +403,7 @@ class App extends React.Component<Props, State> {
|
|||
Util.addBodyClass('theme', theme);
|
||||
};
|
||||
|
||||
setIpcEvents () {
|
||||
registerIpcEvents () {
|
||||
const node = $(ReactDOM.findDOMNode(this));
|
||||
const logo = node.find('#logo');
|
||||
const logsDir = path.join(userPath, 'logs');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue