From 0309d2924276e9182f2a95053d7055f8d4635124 Mon Sep 17 00:00:00 2001 From: Sin Date: Tue, 17 Sep 2019 23:08:37 +0800 Subject: [PATCH 1/2] fix(windows): fix isMaximized and isFullScreen --- .electron-vue/webpack.main.config.js | 21 -------------------- src/main/helpers/electronPrototypes.js | 27 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.electron-vue/webpack.main.config.js b/.electron-vue/webpack.main.config.js index a8b4a3d7ea..23fef763c6 100644 --- a/.electron-vue/webpack.main.config.js +++ b/.electron-vue/webpack.main.config.js @@ -5,7 +5,6 @@ process.env.BABEL_ENV = 'main'; const path = require('path'); const childProcess = require('child_process'); const webpack = require('webpack'); -const SentryWebpackPlugin = require('@sentry/webpack-plugin'); const { dependencies, optionalDependencies, _moduleAliases } = require('../package.json'); const TerserPlugin = require('terser-webpack-plugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); @@ -103,7 +102,6 @@ const sharedDefinedVariables = {}; */ if (process.env.NODE_ENV !== 'production') { mainConfig.plugins.push( - new ForkTsCheckerWebpackPlugin({ eslint: true }), new webpack.DefinePlugin(Object.assign(sharedDefinedVariables, { 'process.env.SAGI_API': `"${process.env.SAGI_API || 'apis.stage.sagittarius.ai:8443'}"`, __static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`, @@ -137,25 +135,6 @@ if (process.env.NODE_ENV === 'production') { // only check on mac, to speed up Windows build mainConfig.plugins.push(new ForkTsCheckerWebpackPlugin({ eslint: true })); } - - if (release && process.env.SENTRY_AUTH_TOKEN) { - mainConfig.plugins.push( - new SentryWebpackPlugin({ - release, - include: './dist', - urlPrefix: 'app:///dist/', - ext: ['js', 'map'], - ignore: ['node_modules'], - }), - new SentryWebpackPlugin({ - release, - include: './src', - urlPrefix: 'webpack:///./src/', - ext: ['js', 'ts', 'vue'], - ignore: ['node_modules'], - }), - ); - } } module.exports = mainConfig; diff --git a/src/main/helpers/electronPrototypes.js b/src/main/helpers/electronPrototypes.js index 27bb1dfdd4..1e6f1b0e1b 100644 --- a/src/main/helpers/electronPrototypes.js +++ b/src/main/helpers/electronPrototypes.js @@ -116,4 +116,31 @@ if (process.platform !== 'darwin') { }; } }; + + // fix isMaximized always returns false + const originMaximize = BrowserWindow.prototype.maximize; + BrowserWindow.prototype.maximize = function maximize(...args) { + this._isMaximized = true; + originMaximize.apply(this, args); + }; + const originUnmaximize = BrowserWindow.prototype.unmaximize; + BrowserWindow.prototype.unmaximize = function unmaximize(...args) { + this._isMaximized = false; + originUnmaximize.apply(this, args); + }; + const originIsMaximize = BrowserWindow.prototype.isMaximized; + BrowserWindow.prototype.isMaximized = function isMaximized(...args) { + return originIsMaximize.apply(this, args) || this._isMaximized; + }; + + // fix isFullScreen always returns false + const originSetFullScreen = BrowserWindow.prototype.setFullScreen; + BrowserWindow.prototype.setFullScreen = function setFullScreen(isFullScreen, ...args) { + this._isFullScreen = isFullScreen; + originSetFullScreen.call(this, isFullScreen, ...args); + }; + const originIsFullScreen = BrowserWindow.prototype.isFullScreen; + BrowserWindow.prototype.isFullScreen = function isFullScreen(...args) { + return originIsFullScreen.apply(this, args) || this._isFullScreen; + }; } From 33c9f45c609469d189c7ff49c1b51d717f09f59b Mon Sep 17 00:00:00 2001 From: Sin Date: Tue, 17 Sep 2019 23:45:11 +0800 Subject: [PATCH 2/2] fix(windows): try fix html fullscreen but failed --- src/main/helpers/BrowserViewManager.ts | 1 + src/main/helpers/electronPrototypes.js | 42 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/helpers/BrowserViewManager.ts b/src/main/helpers/BrowserViewManager.ts index f5d1b0be0b..a8367fabd2 100644 --- a/src/main/helpers/BrowserViewManager.ts +++ b/src/main/helpers/BrowserViewManager.ts @@ -67,6 +67,7 @@ export class BrowserViewManager implements IBrowserViewManager { webPreferences: { preload: `${require('path').resolve(__static, 'pip/preload.js')}`, nativeWindowOpen: true, + // disableHtmlFullscreenWindowResize: true, // Electron 6 required }, }), }; diff --git a/src/main/helpers/electronPrototypes.js b/src/main/helpers/electronPrototypes.js index 1e6f1b0e1b..acdbb72090 100644 --- a/src/main/helpers/electronPrototypes.js +++ b/src/main/helpers/electronPrototypes.js @@ -117,28 +117,38 @@ if (process.platform !== 'darwin') { } }; - // fix isMaximized always returns false - const originMaximize = BrowserWindow.prototype.maximize; - BrowserWindow.prototype.maximize = function maximize(...args) { - this._isMaximized = true; - originMaximize.apply(this, args); - }; - const originUnmaximize = BrowserWindow.prototype.unmaximize; - BrowserWindow.prototype.unmaximize = function unmaximize(...args) { - this._isMaximized = false; - originUnmaximize.apply(this, args); + // fix isMaximized and isFullScreen always returns false + const originLoadURL = BrowserWindow.prototype.loadURL; + BrowserWindow.prototype.loadURL = function loadURl(...args) { + if (!this._customPrototypeInited) { + this._customPrototypeInited = true; + this.on('maximize', function onMaximize() { + this._isMaximized = true; + }); + this.on('unmaximize', function onUnmaximize() { + this._isMaximized = false; + }); + this.on('enter-full-screen', function onEnterFullScreen() { + this._isFullScreen = true; + }); + this.on('leave-full-screen', function onLeaveFullScreen() { + this._isFullScreen = false; + }); + this.on('enter-html-full-screen', function onEnterFullScreen() { + this._isFullScreen = true; + }); + this.on('leave-html-full-screen', function onLeaveFullScreen() { + this._isFullScreen = false; + }); + } + originLoadURL.apply(this, args); }; + const originIsMaximize = BrowserWindow.prototype.isMaximized; BrowserWindow.prototype.isMaximized = function isMaximized(...args) { return originIsMaximize.apply(this, args) || this._isMaximized; }; - // fix isFullScreen always returns false - const originSetFullScreen = BrowserWindow.prototype.setFullScreen; - BrowserWindow.prototype.setFullScreen = function setFullScreen(isFullScreen, ...args) { - this._isFullScreen = isFullScreen; - originSetFullScreen.call(this, isFullScreen, ...args); - }; const originIsFullScreen = BrowserWindow.prototype.isFullScreen; BrowserWindow.prototype.isFullScreen = function isFullScreen(...args) { return originIsFullScreen.apply(this, args) || this._isFullScreen;