2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 20:00:29 +00:00
books/src-electron/main.js

93 lines
1.9 KiB
JavaScript
Raw Normal View History

const { app, BrowserWindow, ipcMain } = require('electron');
2018-07-29 11:50:44 +00:00
const setupMenu = require('./menu');
const theme = require('../src/theme');
2018-07-29 11:50:44 +00:00
let mainWindow;
let winURL;
2018-07-29 11:50:44 +00:00
if (process.env.NODE_ENV !== 'development') {
global.__static = require('path')
2019-09-03 09:43:16 +00:00
.join(__dirname, '/static')
.replace(/\\/g, '\\\\');
2019-09-03 09:43:16 +00:00
global.documentsPath = app.getPath('documents');
2018-07-29 11:50:44 +00:00
}
if (process.env.NODE_ENV === 'development') {
const { getAppConfig } = require('frappejs/webpack/utils');
const appConfig = getAppConfig();
winURL = `http://localhost:${appConfig.dev.devServerPort}`;
} else {
winURL = `file://${__dirname}/index.html`;
}
2018-07-29 11:50:44 +00:00
function createWindow() {
/**
* Initial window options
*/
Winter Sprint: Work (#79) * init() * Country-wise Chart of accounts on setup * Add a sample invoice template * Some error fixes * [fix] missing COA - move importCOA.js from models/doctype/account to models/doctype/Account * All Account initial balance zero * setup Bank Reconciliation * New chart of accounts tree component * GST taxes added. initialized gst reports. * [chore] add *.db to .gitignore * [fix] importCOA path error * fix error + bank reconciliation fields * [feat] add gst taxes * GST report initialized * GST report finalized * GST report finalized * Complete min. reconciliation * [feat] auto select tax in invoice based on states * [chore] fix merge changes * Fix date issue - Make Payment * Add invoice templates and invoice customizer panel * Restructure invoice vue components * update file with fiscal year * Fix issues in invoice designs * Add company settings. Dynamic addresses in invoice * Move invoice styles to different file and add separate components for addresses * [feat] add export-filtered-data-to-csv to reports * [feat] add Export Wizard component for customizing export * Fix invoice customizer position while scrolling. Fix address displayed as undefined in invoice if not found in db * [chore] change markup for select all chkbox * Setup config as doctype * GSTIN bug fix * Add custom google fonts * Add Send email footer * Fix DateTime * Complete Merge + Resolve * Complete Merge + Resolve * [chore] change layout of Export Wizard * [enh] optimize checkNoneSelected, style export modal footer divider * Add Tax to SideBar * Remove extra logs * [fix] db name section in sidebar showing absolute path instead of dbname in windows i.e. platform=win32 * Country-wise Chart of accounts on setup (#78) * Country-wise Chart of accounts on setup * Some error fixes * All Account initial balance zero * Update README.md - updated installation instructions with more detail * Merge #79 Winter Sprint: Work https://github.com/frappe/accounting/pull/79 * Revert "Merge #79 Winter Sprint: Work" This reverts commit 171511666817caa430af672791c8d452e3b4b680.
2019-02-18 05:42:04 +00:00
2018-07-29 11:50:44 +00:00
mainWindow = new BrowserWindow({
vibrancy: 'sidebar',
transparent: true,
backgroundColor: '#80FFFFFF',
2019-10-04 17:59:05 +00:00
width: 1200,
height: 907,
frame: false,
resizable: false,
useContentSize: true,
webPreferences: {
webSecurity: false,
nodeIntegration: true
}
});
2018-07-29 11:50:44 +00:00
mainWindow.loadURL(winURL);
2018-07-29 11:50:44 +00:00
mainWindow.on('closed', () => {
mainWindow = null;
});
2018-07-29 11:50:44 +00:00
setupMenu();
}
function createSettingsWindow(tab = 'General') {
let settingsWindow = new BrowserWindow({
parent: mainWindow,
frame: false,
width: 460,
height: 577,
backgroundColor: theme.backgroundColor.gray['200'],
webPreferences: {
webSecurity: false,
nodeIntegration: true
}
});
settingsWindow.loadURL(`${winURL}/#/settings/${tab}`);
}
ipcMain.on('open-settings-window', (event, tab) => {
createSettingsWindow(tab);
});
ipcMain.on('reload-main-window', () => {
mainWindow.reload();
});
app.on('ready', createWindow);
2018-07-29 11:50:44 +00:00
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
2018-07-29 11:50:44 +00:00
}
});
2018-07-29 11:50:44 +00:00
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
2018-07-29 11:50:44 +00:00
}
});
2018-07-29 11:50:44 +00:00
// TODO:
// Enable Auto Update
// https://www.electron.build/auto-update/