chore: Allow disabling electron frame on all desktop OSs
This commit is contained in:
7 files changed
+31
-14
No files matched your search
@@ -127,10 +127,10 @@ export default function initializeMockIPC(server) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for browsers running on windows OS
|
||||
* Check for OS frame
|
||||
*/
|
||||
isWindowsOS() {
|
||||
return Boolean(window.navigator.userAgent.match(/(windows)/i));
|
||||
isFrameless() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,6 +78,7 @@ These environment variables may be used to customized the build.
|
||||
| `APP_UPDATER_LATEST_VERSION_TAG` | Next version for comparison with current version. |
|
||||
| `APP_UPDATER_LATEST_VERSION_LOCATION` | Location of app release to use for updating client. Can be a filepath or url. |
|
||||
| `BYPASS_CLI_SETUP` | Disable download and extraction of cli. For development use only. |
|
||||
| `BYPASS_OS_SHELL` | Disable OS shell with window actions. For internal use only. |
|
||||
|
||||
### Building for Production
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@ export default class ApplicationController extends Controller {
|
||||
// =attributes
|
||||
|
||||
/**
|
||||
* Display OS window actions (minimize, fullscreen, close) for
|
||||
* Windows and Linux as OS frame/shell is disable.
|
||||
* Does not apply to MacOS.
|
||||
* Check for MacOS frame
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('isMacOS')
|
||||
get isFrameless() {
|
||||
return !this.isMacOS;
|
||||
@computed('isMacOS', 'isFrameless')
|
||||
get hasMacOSFrame() {
|
||||
console.log('hasMacOSFrame ', this.isMacOS && !this.isFrameless);
|
||||
return this.isMacOS && !this.isFrameless;
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,11 @@ export default class ApplicationRoute extends Route {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add OS config on controller.
|
||||
* Add window frame config on controller.
|
||||
*/
|
||||
async setupController(controller) {
|
||||
controller.set('isMacOS', await this.ipc.invoke('isMacOS'));
|
||||
controller.set('isFrameless', await this.ipc.invoke('isFrameless'));
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
{{page-title (app-name)}}
|
||||
|
||||
<Rose::Layout::Global
|
||||
@@ -8,7 +10,7 @@
|
||||
<layout.header>
|
||||
<Rose::Header
|
||||
class='{{if (is-loading) ' loading'}}
|
||||
{{if this.isMacOS ' header-cushion'}}'
|
||||
{{if this.hasMacOSFrame ' header-cushion'}}'
|
||||
as |header|
|
||||
>
|
||||
<header.brand @logo='logo-app' @text={{app-name}} />
|
||||
|
||||
@@ -113,11 +113,18 @@ app.on('ready', async () => {
|
||||
}
|
||||
Menu.setApplicationMenu(menuTemplate);
|
||||
|
||||
/**
|
||||
* Enable electron OS frame for MacOS only.
|
||||
* Disable frame regardless of OS using `BYPASS_OS_SHELL`
|
||||
*/
|
||||
let showFrame = isMac();
|
||||
if (process.env.BYPASS_OS_SHELL) showFrame = false;
|
||||
|
||||
const browserWindowOptions = {
|
||||
width: 1280,
|
||||
height: 760,
|
||||
titleBarStyle: 'hiddenInset',
|
||||
frame: isMac(),
|
||||
frame: showFrame,
|
||||
titleBarStyle: showFrame ? 'hiddenInset' : 'none',
|
||||
webPreferences: {
|
||||
partition,
|
||||
sandbox: true,
|
||||
|
||||
@@ -69,7 +69,14 @@ handle('connect', ({ target_id, token, host_id }) =>
|
||||
handle('stop', ({ session_id }) => sessionManager.stopById(session_id));
|
||||
|
||||
/**
|
||||
* Check for MacOS OS
|
||||
* Check for frameless window state. Only MacOS uses default OS frame.
|
||||
* Frameless window disables OS window actions (minimize, fullscreen, close).
|
||||
* Enable `BYPASS_OS_SHELL` to bypass OS verification for frame.
|
||||
*/
|
||||
handle('isFrameless', () => !isMac() || process.env.BYPASS_OS_SHELL);
|
||||
|
||||
/**
|
||||
* Check for MacOS
|
||||
*/
|
||||
handle('isMacOS', () => isMac());
|
||||
|
||||
|
||||
Reference in new issue
Block a user