mirror of
https://github.com/frappe/books.git
synced 2024-11-14 01:14:03 +00:00
fix: set window size dynamically
This commit is contained in:
parent
c1fa2d36ef
commit
045f38bb96
@ -29,6 +29,7 @@ import Settings from '@/pages/Settings/Settings.vue';
|
||||
import WindowsTitleBar from '@/components/WindowsTitleBar';
|
||||
import { remote } from 'electron';
|
||||
import { connectToLocalDatabase } from '@/utils';
|
||||
import { getMainWindowSize } from '@/screenSize';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
@ -40,8 +41,9 @@ export default {
|
||||
watch: {
|
||||
activeScreen(value) {
|
||||
if (!value) return;
|
||||
let { width, height } = getMainWindowSize();
|
||||
let size = {
|
||||
Desk: [1200, 907],
|
||||
Desk: [width, height],
|
||||
DatabaseSelector: [600, 600],
|
||||
SetupWizard: [600, 600],
|
||||
Settings: [460, 577]
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
installVueDevtools
|
||||
} from 'vue-cli-plugin-electron-builder/lib';
|
||||
import theme from '@/theme';
|
||||
import { getMainWindowSize } from './screenSize';
|
||||
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production';
|
||||
const isMac = process.platform === 'darwin';
|
||||
@ -24,12 +25,13 @@ protocol.registerSchemesAsPrivileged([
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
let { width, height } = getMainWindowSize();
|
||||
mainWindow = new BrowserWindow({
|
||||
vibrancy: 'sidebar',
|
||||
transparent: isMac,
|
||||
backgroundColor: '#80FFFFFF',
|
||||
width: 1200,
|
||||
height: 907,
|
||||
width,
|
||||
height,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
},
|
||||
|
14
src/screenSize.js
Normal file
14
src/screenSize.js
Normal file
@ -0,0 +1,14 @@
|
||||
import electron from 'electron';
|
||||
|
||||
export function getMainWindowSize() {
|
||||
let screen = electron.screen || electron.remote.screen;
|
||||
let { height } = screen.getPrimaryDisplay().workAreaSize;
|
||||
let width;
|
||||
|
||||
if (height > 907) {
|
||||
height = 907;
|
||||
}
|
||||
width = Math.ceil(1.323 * height);
|
||||
|
||||
return { width, height };
|
||||
}
|
Loading…
Reference in New Issue
Block a user