From 87a991eaea4c13ffa9b68af7b3050c34997c8fbc Mon Sep 17 00:00:00 2001 From: Franzz Date: Tue, 2 Jun 2026 11:22:28 +0200 Subject: [PATCH] Fix back button --- src/App.vue | 22 +++++++++++++++----- src/components/admin.vue | 18 ++++++++-------- src/components/projectPost.vue | 4 ++-- src/components/upload.vue | 4 ++-- src/styles/_page.project.panel.settings.scss | 4 ++++ 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/App.vue b/src/App.vue index adc4a5c..8708e79 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,7 +11,7 @@ const aoRoutes = { export default { data() { return { - hash: {page: '', items: []}, + hash: {page: '', items: [], prev: {}}, consts: this.appConfig.consts, mobile: false }; @@ -20,7 +20,9 @@ export default { return { hash: this.hash, consts: this.consts, - isMobile: () => this.isMobile() + isMobile: () => this.isMobile(), + getAnchor: this.getAnchor, + getPrevAnchor: () => this.getPrevAnchor(), }; }, computed: { @@ -28,7 +30,8 @@ export default { return aoRoutes[this.hash.page]; }, hashSnapshot() { - return JSON.stringify(this.hash); + const { prev, ...asHash } = this.hash; + return JSON.stringify(asHash); } }, inject: ['appConfig'], @@ -49,11 +52,15 @@ export default { watch: { hashSnapshot(jNewHash, jOldHash) { const asNewHash = JSON.parse(jNewHash); + //Sync variable -> #hash if(asNewHash != this.getBrowserHash()) { this.setBrowserHash(asNewHash.page, asNewHash.items); } + //Store previous value + this.hash.prev = JSON.parse(jOldHash); + this.setPageTitle(asNewHash.page); } }, @@ -83,8 +90,13 @@ export default { }, setBrowserHash(sPage = '', asItems = []) { if(typeof asItems == 'string' && asItems != '') asItems = [asItems]; - const sItems = (asItems.length > 0)?(this.consts.hash_sep + asItems.join(this.consts.hash_sep)):''; - window.location.hash = '#' + sPage + sItems; + window.location.hash = this.getAnchor([sPage, ...asItems]); + }, + getAnchor(asBreadCrumbs) { + return '#' + asBreadCrumbs.filter(Boolean).join(this.consts.hash_sep); + }, + getPrevAnchor() { + return this.getAnchor([this.hash.prev.page, ...this.hash.prev.items]); } }, beforeUnmount() { diff --git a/src/components/admin.vue b/src/components/admin.vue index 48105cf..69a6958 100644 --- a/src/components/admin.vue +++ b/src/components/admin.vue @@ -1,7 +1,7 @@