mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
incr: remove 600x600 windows
This commit is contained in:
parent
27aed52044
commit
b6163b4cac
9
main.ts
9
main.ts
@ -10,7 +10,6 @@ import Store from 'electron-store';
|
|||||||
import { autoUpdater } from 'electron-updater';
|
import { autoUpdater } from 'electron-updater';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
|
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
|
||||||
import { getMainWindowSize } from './main/helpers';
|
|
||||||
import registerAppLifecycleListeners from './main/registerAppLifecycleListeners';
|
import registerAppLifecycleListeners from './main/registerAppLifecycleListeners';
|
||||||
import registerAutoUpdaterListeners from './main/registerAutoUpdaterListeners';
|
import registerAutoUpdaterListeners from './main/registerAutoUpdaterListeners';
|
||||||
import registerIpcMainActionListeners from './main/registerIpcMainActionListeners';
|
import registerIpcMainActionListeners from './main/registerIpcMainActionListeners';
|
||||||
@ -18,6 +17,9 @@ import registerIpcMainMessageListeners from './main/registerIpcMainMessageListen
|
|||||||
import registerProcessListeners from './main/registerProcessListeners';
|
import registerProcessListeners from './main/registerProcessListeners';
|
||||||
import { IPC_CHANNELS } from './utils/messages';
|
import { IPC_CHANNELS } from './utils/messages';
|
||||||
|
|
||||||
|
const WIDTH = 1200;
|
||||||
|
const HEIGHT = 907;
|
||||||
|
|
||||||
export class Main {
|
export class Main {
|
||||||
title: string = 'Frappe Books';
|
title: string = 'Frappe Books';
|
||||||
icon: string;
|
icon: string;
|
||||||
@ -69,13 +71,12 @@ export class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getOptions(): BrowserWindowConstructorOptions {
|
getOptions(): BrowserWindowConstructorOptions {
|
||||||
const { width, height } = getMainWindowSize();
|
|
||||||
const options: BrowserWindowConstructorOptions = {
|
const options: BrowserWindowConstructorOptions = {
|
||||||
vibrancy: 'sidebar',
|
vibrancy: 'sidebar',
|
||||||
transparent: this.isMac,
|
transparent: this.isMac,
|
||||||
backgroundColor: '#80FFFFFF',
|
backgroundColor: '#80FFFFFF',
|
||||||
width,
|
width: WIDTH,
|
||||||
height,
|
height: HEIGHT,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
contextIsolation: false, // TODO: Switch this off
|
contextIsolation: false, // TODO: Switch this off
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
import electron, { app } from 'electron';
|
|
||||||
|
|
||||||
export function getMainWindowSize() {
|
|
||||||
let height;
|
|
||||||
if (app.isReady()) {
|
|
||||||
const screen = electron.screen;
|
|
||||||
height = screen.getPrimaryDisplay().workAreaSize.height;
|
|
||||||
height = height > 907 ? 907 : height;
|
|
||||||
} else {
|
|
||||||
height = 907;
|
|
||||||
}
|
|
||||||
const width = Math.ceil(1.323 * height);
|
|
||||||
return { height, width };
|
|
||||||
}
|
|
@ -10,7 +10,6 @@ import saveHtmlAsPdf from '../src/saveHtmlAsPdf';
|
|||||||
import { DatabaseMethod } from '../utils/db/types';
|
import { DatabaseMethod } from '../utils/db/types';
|
||||||
import { DatabaseResponse } from '../utils/ipc/types';
|
import { DatabaseResponse } from '../utils/ipc/types';
|
||||||
import { IPC_ACTIONS } from '../utils/messages';
|
import { IPC_ACTIONS } from '../utils/messages';
|
||||||
import { getMainWindowSize } from './helpers';
|
|
||||||
|
|
||||||
export default function registerIpcMainActionListeners(main: Main) {
|
export default function registerIpcMainActionListeners(main: Main) {
|
||||||
ipcMain.handle(IPC_ACTIONS.TOGGLE_MAXIMIZE_CURRENT_WINDOW, (event) => {
|
ipcMain.handle(IPC_ACTIONS.TOGGLE_MAXIMIZE_CURRENT_WINDOW, (event) => {
|
||||||
@ -31,10 +30,6 @@ export default function registerIpcMainActionListeners(main: Main) {
|
|||||||
return await dialog.showSaveDialog(main.mainWindow!, options);
|
return await dialog.showSaveDialog(main.mainWindow!, options);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle(IPC_ACTIONS.GET_PRIMARY_DISPLAY_SIZE, (event) => {
|
|
||||||
return getMainWindowSize();
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle(IPC_ACTIONS.GET_DIALOG_RESPONSE, async (event, options) => {
|
ipcMain.handle(IPC_ACTIONS.GET_DIALOG_RESPONSE, async (event, options) => {
|
||||||
if (main.isDevelopment || main.isLinux) {
|
if (main.isDevelopment || main.isLinux) {
|
||||||
Object.assign(options, { icon: main.icon });
|
Object.assign(options, { icon: main.icon });
|
||||||
|
@ -21,13 +21,6 @@ export default function registerIpcMainMessageListeners(main: Main) {
|
|||||||
main.mainWindow!.reload();
|
main.mainWindow!.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(IPC_MESSAGES.RESIZE_MAIN_WINDOW, (event, size, resizable) => {
|
|
||||||
const [width, height] = size;
|
|
||||||
if (!width || !height) return;
|
|
||||||
main.mainWindow!.setSize(width, height);
|
|
||||||
main.mainWindow!.setResizable(resizable);
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.on(IPC_MESSAGES.CLOSE_CURRENT_WINDOW, (event) => {
|
ipcMain.on(IPC_MESSAGES.CLOSE_CURRENT_WINDOW, (event) => {
|
||||||
main.mainWindow!.close();
|
main.mainWindow!.close();
|
||||||
});
|
});
|
||||||
|
21
src/App.vue
21
src/App.vue
@ -30,9 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ipcRenderer } from 'electron';
|
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { IPC_MESSAGES } from 'utils/messages';
|
|
||||||
import { fyo } from './initFyo';
|
import { fyo } from './initFyo';
|
||||||
import DatabaseSelector from './pages/DatabaseSelector';
|
import DatabaseSelector from './pages/DatabaseSelector';
|
||||||
// import Desk from './pages/Desk';
|
// import Desk from './pages/Desk';
|
||||||
@ -47,25 +45,6 @@ export default {
|
|||||||
activeScreen: null,
|
activeScreen: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
async activeScreen(value) {
|
|
||||||
if (!value) return;
|
|
||||||
const { width, height } = await ipcRenderer.invoke(
|
|
||||||
IPC_ACTIONS.GET_PRIMARY_DISPLAY_SIZE
|
|
||||||
);
|
|
||||||
|
|
||||||
let size = {
|
|
||||||
Desk: [width, height],
|
|
||||||
DatabaseSelector: [600, 600],
|
|
||||||
SetupWizard: [600, 600],
|
|
||||||
}[value];
|
|
||||||
let resizable = value === 'Desk';
|
|
||||||
|
|
||||||
if (size.length) {
|
|
||||||
ipcRenderer.send(IPC_MESSAGES.RESIZE_MAIN_WINDOW, size, resizable);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
// Desk,
|
// Desk,
|
||||||
// SetupWizard,
|
// SetupWizard,
|
||||||
|
@ -27,7 +27,7 @@ import { setLanguageMap } from './utils/language';
|
|||||||
registerIpcRendererListeners();
|
registerIpcRendererListeners();
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
template: '<h1>Hellow, World</h1>',
|
template: '<App/>',
|
||||||
});
|
});
|
||||||
setErrorHandlers(app);
|
setErrorHandlers(app);
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ export enum IPC_MESSAGES {
|
|||||||
OPEN_EXTERNAL = 'open-external',
|
OPEN_EXTERNAL = 'open-external',
|
||||||
SHOW_ITEM_IN_FOLDER = 'show-item-in-folder',
|
SHOW_ITEM_IN_FOLDER = 'show-item-in-folder',
|
||||||
RELOAD_MAIN_WINDOW = 'reload-main-window',
|
RELOAD_MAIN_WINDOW = 'reload-main-window',
|
||||||
RESIZE_MAIN_WINDOW = 'resize-main-window',
|
|
||||||
CLOSE_CURRENT_WINDOW = 'close-current-window',
|
CLOSE_CURRENT_WINDOW = 'close-current-window',
|
||||||
MINIMIZE_CURRENT_WINDOW = 'minimize-current-window',
|
MINIMIZE_CURRENT_WINDOW = 'minimize-current-window',
|
||||||
DOWNLOAD_UPDATE = 'download-update',
|
DOWNLOAD_UPDATE = 'download-update',
|
||||||
@ -18,7 +17,6 @@ export enum IPC_ACTIONS {
|
|||||||
GET_OPEN_FILEPATH = 'open-dialog',
|
GET_OPEN_FILEPATH = 'open-dialog',
|
||||||
GET_SAVE_FILEPATH = 'save-dialog',
|
GET_SAVE_FILEPATH = 'save-dialog',
|
||||||
GET_DIALOG_RESPONSE = 'show-message-box',
|
GET_DIALOG_RESPONSE = 'show-message-box',
|
||||||
GET_PRIMARY_DISPLAY_SIZE = 'get-primary-display-size',
|
|
||||||
SAVE_HTML_AS_PDF = 'save-html-as-pdf',
|
SAVE_HTML_AS_PDF = 'save-html-as-pdf',
|
||||||
SAVE_DATA = 'save-data',
|
SAVE_DATA = 'save-data',
|
||||||
SHOW_ERROR = 'show-error',
|
SHOW_ERROR = 'show-error',
|
||||||
|
Loading…
Reference in New Issue
Block a user