From d2f89513630c183a115b921d499f4410e9a9ba85 Mon Sep 17 00:00:00 2001 From: Quentin Guillemin Date: Thu, 7 Mar 2024 10:51:35 +0100 Subject: [PATCH] feat: change document title on app context --- src/main/webapp/src/views/AppView.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/webapp/src/views/AppView.vue b/src/main/webapp/src/views/AppView.vue index 737e84d5..17f0fee5 100644 --- a/src/main/webapp/src/views/AppView.vue +++ b/src/main/webapp/src/views/AppView.vue @@ -115,11 +115,21 @@ const preventExit = (e: Event): void => { e.preventDefault(); }; +watch( + title, + (newValue) => { + if (newValue.trim() != '') document.title = `${newValue} - ${__APP_NAME__}`; + else if (document.title != __APP_NAME__) document.title = __APP_NAME__; + }, + { immediate: true }, +); + onMounted(() => { window.addEventListener('beforeunload', preventExit); }); onUnmounted(() => { + if (document.title != __APP_NAME__) document.title = __APP_NAME__; window.removeEventListener('beforeunload', preventExit); exitAppContext(); });