Skip to content

Commit

Permalink
feat: change document title on app context
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Mar 7, 2024
1 parent 58b44cc commit d2f8951
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/webapp/src/views/AppView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit d2f8951

Please sign in to comment.