diff --git a/package.json b/package.json index 8b99c38..b69061a 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "license": "MIT", "main": ".webpack/main", "scripts": { - "start": "NODE_ENV=development electron-forge start", + "start": "DRAWPEN_DEV=1 electron-forge start", "package_no_sign": "electron-forge package -- --no-sign", "package": "electron-forge package", "make": "electron-forge make", diff --git a/src/main/index.js b/src/main/index.js index d0e232d..0223740 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -9,7 +9,7 @@ if (electronSquirrelStartup) { app.quit(); } -const isDevelopment = process.env.NODE_ENV === 'development' +const isDevelopment = process.env.DRAWPEN_DEV === '1' const isMac = process.platform === 'darwin' const isLinux = process.platform === 'linux' const isWin = process.platform === 'win32' @@ -252,11 +252,11 @@ function createMainWindow() { let hasDevTools = false if (isDevelopment) { - isResizable = true - hasDevTools = true + isResizable = true; + hasDevTools = true; } - mainWindow = new BrowserWindow({ + const mainWindowOptions = { show: false, transparent: true, backgroundColor: '#00000000', // 8-symbol ARGB @@ -271,8 +271,17 @@ function createMainWindow() { devTools: hasDevTools, nodeIntegration: false, preload: APP_WINDOW_PRELOAD_WEBPACK_ENTRY, - } - }) + }, + }; + + if (isDevelopment) { + mainWindowOptions.x = 0; + mainWindowOptions.y = 0; + mainWindowOptions.width = 500; + mainWindowOptions.height = 500; + } + + mainWindow = new BrowserWindow(mainWindowOptions) mainWindow.loadURL(APP_WINDOW_WEBPACK_ENTRY); @@ -505,6 +514,8 @@ ipcMain.handle('get_settings', () => { key_binding_clear_desk: normalizeAcceleratorForUI(store.get('key_binding_clear_desk')), key_binding_open_settings: normalizeAcceleratorForUI(KEY_SETTINGS), key_binding_make_screenshot: normalizeAcceleratorForUI(KEY_MAKE_SCREENSHOT), + + is_development: isDevelopment, }; }); @@ -965,13 +976,8 @@ function sendNotification(data) { function showWindowOnScreen() { const currentDisplay = getDrawingDisplay() - mainWindow.setBounds(currentDisplay.workArea) - - if (isDevelopment) { - mainWindow.setBounds({ - width: 500, - height: 500 - }) + if (!isDevelopment) { + mainWindow.setBounds(currentDisplay.workArea) } if (store.get('active_monitor_id') === currentDisplay.id) { diff --git a/src/renderer/app_page/components/Application.js b/src/renderer/app_page/components/Application.js index 2bf6f28..4b441f7 100644 --- a/src/renderer/app_page/components/Application.js +++ b/src/renderer/app_page/components/Application.js @@ -79,7 +79,7 @@ const Application = (settings) => { let initialFigures = [] - if (process.env.NODE_ENV === 'development') { + if (settings.is_development) { initialFigures = [ { id: 0, type: 'arrow', colorIndex: 0, widthIndex: 2, points: [[100, 100], [400, 100]], rainbowColorDeg: (Math.random() * 360) }, { id: 1, type: 'line', colorIndex: 0, widthIndex: 2, points: [[100, 200], [400, 200]], rainbowColorDeg: 250 }, diff --git a/tools/webpack/renderer.js b/tools/webpack/renderer.js index b957260..cb2580c 100644 --- a/tools/webpack/renderer.js +++ b/tools/webpack/renderer.js @@ -24,7 +24,7 @@ const rules = [ ] function inDev() { - return process.env.NODE_ENV == 'development'; + return process.env.DRAWPEN_DEV === '1'; } const copyPlugins = [