From 20bb0372ca9da5f1348ca8f1a0258e647f048f5f Mon Sep 17 00:00:00 2001 From: tappi287 Date: Mon, 3 Jul 2023 21:33:04 +0200 Subject: [PATCH] implemented preference setting to launch app in Edge browser --- app.py | 13 +++++++++---- vue/src/components/pages/PreferencesPage.vue | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 75278e2..ae8bc63 100644 --- a/app.py +++ b/app.py @@ -79,12 +79,17 @@ def start_eel(npm_serve=True): eel.init('web') # TODO: fetch OSError port in use + edge_cmd = f"{os.path.expandvars('%PROGRAMFILES(x86)%')}\\Microsoft\\Edge\\Application\\msedge.exe" + start_url = f'http://{host}:{url_port}' + try: - eel.start(page, host=host, port=port, block=False, close_callback=close_callback) + app_module_prefs = getattr(AppSettings, 'app_preferences', dict()).get('appModules', list()) + if Path(edge_cmd).exists() and 'edge_preferred' in app_module_prefs: + eel.start(page, mode='custom', host=host, port=port, block=False, + cmdline_args=[edge_cmd, '--profile-directory=Default', f'--app={start_url}']) + else: + eel.start(page, host=host, port=port, block=False, close_callback=close_callback) except EnvironmentError: - start_url = f'http://{host}:{url_port}' - edge_cmd = f"{os.path.expandvars('%PROGRAMFILES(x86)%')}\\Microsoft\\Edge\\Application\\msedge.exe" - # If Chrome isn't found, fallback to Microsoft Chromium Edge if Path(edge_cmd).exists(): logging.info('Falling back to Edge Browser') diff --git a/vue/src/components/pages/PreferencesPage.vue b/vue/src/components/pages/PreferencesPage.vue index feb7370..27f3037 100644 --- a/vue/src/components/pages/PreferencesPage.vue +++ b/vue/src/components/pages/PreferencesPage.vue @@ -23,7 +23,9 @@ - Weather to play audio feedback when using rf2-headlights or certain actions within the app. + Weather to play audio feedback when using rf2-headlights or certain actions within the app.
+ You can prefer the Windows builtin Chromium Edge browser over Google Chrome to render this app. + Changes apply after an app restart.
@@ -61,7 +63,8 @@ export default { ], appModules: ['audio'], appOptions: [ - {text: 'Enable Audio', value: 'audio'} + {text: 'Enable Audio', value: 'audio'}, + {text: 'Prefer Edge Browser', value: 'edge_preferred'} ] } },