From e38eb68f8f5385d89d16fd72108be9df89449efb Mon Sep 17 00:00:00 2001 From: Ryan Debouvries Date: Fri, 23 Feb 2024 10:11:43 +0100 Subject: [PATCH] fix(reload_experience): Improve reload experience with a 404 page and a choice when there is changes not saved --- .firebase/hosting.ZGlzdA.cache | 17 ++++--- public/404.html | 91 ++++++++++++++++++++++++++++++++++ src/views/PageView.vue | 10 ++++ 3 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 public/404.html diff --git a/.firebase/hosting.ZGlzdA.cache b/.firebase/hosting.ZGlzdA.cache index b8c6a3b6..5b6fa321 100644 --- a/.firebase/hosting.ZGlzdA.cache +++ b/.firebase/hosting.ZGlzdA.cache @@ -1,8 +1,9 @@ -favicon.ico,1708616553748,642f1aaa9a48d91d01009c5d59bf43b000ac928f2087032988c612cfc9a0ffcf -index.html,1708616553928,e865bf78a74377096c14b5e62dbff09d7b9845bf0708ac3d5cbcf0b5cd56742d -assets/fireman-helmet-Ukc3N7ug.png,1708616553928,f8c2804ac98abb8be17dab1f4c198cf379a3122e19b82a898bf919a55c6c12b3 -assets/index-YYuIn3io.css,1708616553928,2c403f6fe376a7397d3b8ec074586c571b558adef4296c8a70bb9ecb9c323255 -assets/google-logo-7SJOUJsJ.png,1708616553928,f56e9879d41f269f2bb757924c931fff5bd22ed1b6ec2563327125f872e34312 -assets/background-zxbUyEDC.png,1708616553928,21491117a988ab2a35192e617e1d1b3bc6e09907951cb82916512cfd170dbdd8 -assets/index-AggciY1l.js,1708616553928,fa7d64ca16392176cd65d846b0c814f908a82dc7b7ce1971efc8f89eb11a94c4 -assets/logo-FNuJ5V5l.png,1708616553928,c7e4655162bd792eb336d1d9c9ef1dc162a5be24ea5651694f354d2732d5262d +404.html,1708679304125,9caddd17c52fa475306d2f1788cda5c564a4f55e4bc4e7ccfb7f186a14fd88d4 +index.html,1708679304321,a4cabe4f7d24e5a48459b40c217b563391ab0924338ea5278f84d8226ea8eab1 +favicon.ico,1708679304125,642f1aaa9a48d91d01009c5d59bf43b000ac928f2087032988c612cfc9a0ffcf +assets/fireman-helmet-Ukc3N7ug.png,1708679304321,f8c2804ac98abb8be17dab1f4c198cf379a3122e19b82a898bf919a55c6c12b3 +assets/index-YYuIn3io.css,1708679304321,2c403f6fe376a7397d3b8ec074586c571b558adef4296c8a70bb9ecb9c323255 +assets/google-logo-7SJOUJsJ.png,1708679304321,f56e9879d41f269f2bb757924c931fff5bd22ed1b6ec2563327125f872e34312 +assets/background-zxbUyEDC.png,1708679304321,21491117a988ab2a35192e617e1d1b3bc6e09907951cb82916512cfd170dbdd8 +assets/index-jaG_QrW6.js,1708679304321,854524b696308d17614062438e3e2470bb4a70605eb5f7d9f9902df355529d01 +assets/logo-FNuJ5V5l.png,1708679304321,c7e4655162bd792eb336d1d9c9ef1dc162a5be24ea5651694f354d2732d5262d diff --git a/public/404.html b/public/404.html new file mode 100644 index 00000000..e3936e57 --- /dev/null +++ b/public/404.html @@ -0,0 +1,91 @@ + + + + + + Page Not Found + + + + +
+

404

+

Page non trouvée

+

Pour des raisons de sécurité nous vous demandons de vous reconnecter.

+ Se connecter +
+ + diff --git a/src/views/PageView.vue b/src/views/PageView.vue index 590e1d17..d6d95562 100644 --- a/src/views/PageView.vue +++ b/src/views/PageView.vue @@ -5,6 +5,7 @@ import { useDataStore } from "../stores/data"; import router from "@/router"; import AddPopup from "@/components/AddPopup.vue"; import SaveAlertPopup from "@/components/SaveAlertPopup.vue"; +import { onMounted } from "vue"; // Get the stores const userStore = useUserStore(); @@ -13,6 +14,15 @@ const dataStore = useDataStore(); // Get the route const route = useRoute(); +onMounted(() => { + // Prevent leaving the page without saving + window.addEventListener("beforeunload", (e) => { + if (dataStore.needToSave) { + e.preventDefault(); + } + }); +}); + // Save to firebase function saveToFirebase() { if (route.name == "Modules") dataStore.saveModulesToFirebase();