From e167c3e1efed8b16be45d994a8d443fda1d8cf49 Mon Sep 17 00:00:00 2001 From: niubility000 <76441520+niubility000@users.noreply.github.com> Date: Fri, 23 Feb 2024 02:42:36 +0800 Subject: [PATCH] feat: freezing the list in the backgroud while previewing a file (#3004) --- frontend/src/css/styles.css | 2 +- frontend/src/views/Files.vue | 36 +++++++++++++++++++++------- frontend/src/views/files/Listing.vue | 23 +++++++++++------- frontend/src/views/files/Preview.vue | 2 ++ 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/frontend/src/css/styles.css b/frontend/src/css/styles.css index 00442507..f38f6b63 100644 --- a/frontend/src/css/styles.css +++ b/frontend/src/css/styles.css @@ -152,7 +152,7 @@ main .spinner .bounce2 { /* PREVIEWER */ #previewer { - background-color: rgba(0, 0, 0, 0.9); + background-color: rgba(0, 0, 0, 0.99); padding-top: 4em; position: fixed; top: 0; diff --git a/frontend/src/views/Files.vue b/frontend/src/views/Files.vue index ff7b84a6..2d67fdd7 100644 --- a/frontend/src/views/Files.vue +++ b/frontend/src/views/Files.vue @@ -3,10 +3,10 @@ - + -
+

@@ -52,13 +52,10 @@ export default { computed: { ...mapState(["req", "reload", "loading"]), currentView() { - if (this.req.type == undefined) { + if (this.req.type == undefined || this.req.isDir) { return null; } - - if (this.req.isDir) { - return "listing"; - } else if ( + else if ( this.req.type === "text" || this.req.type === "textImmutable" ) { @@ -72,7 +69,26 @@ export default { this.fetchData(); }, watch: { - $route: "fetchData", + $route: function (to, from) { + if (from.path.endsWith("/")) { + if (to.path.endsWith("/")) { + window.sessionStorage.setItem('listFrozen', "false"); + this.fetchData(); + return; + } else { + window.sessionStorage.setItem('listFrozen', "true"); + this.fetchData(); + return; + } + } else if (to.path.endsWith("/")) { + this.$store.commit("updateRequest", {}); + this.fetchData(); + return; + } else { + this.fetchData(); + return; + } + }, reload: function (value) { if (value === true) { this.fetchData(); @@ -101,7 +117,9 @@ export default { this.$store.commit("closeHovers"); // Set loading to true and reset the error. - this.setLoading(true); + if (window.sessionStorage.getItem('listFrozen') !=="true"){ + this.setLoading(true); + } this.error = null; let url = this.$route.path; diff --git a/frontend/src/views/files/Listing.vue b/frontend/src/views/files/Listing.vue index c204de45..692593b6 100644 --- a/frontend/src/views/files/Listing.vue +++ b/frontend/src/views/files/Listing.vue @@ -383,17 +383,22 @@ export default { }, watch: { req: function () { - // Reset the show value - this.showLimit = 50; + if (window.sessionStorage.getItem('listFrozen') !=="true"){ + // Reset the show value + this.showLimit = 50; - // Ensures that the listing is displayed - Vue.nextTick(() => { - // How much every listing item affects the window height - this.setItemWeight(); + // Ensures that the listing is displayed + Vue.nextTick(() => { + // How much every listing item affects the window height + this.setItemWeight(); - // Fill and fit the window with listing items - this.fillWindow(true); - }); + // Fill and fit the window with listing items + this.fillWindow(true); + }); + } + if (this.req.isDir) { + window.sessionStorage.setItem('listFrozen', "false"); + } }, }, mounted: function () { diff --git a/frontend/src/views/files/Preview.vue b/frontend/src/views/files/Preview.vue index 6422ac5a..aa85e2eb 100644 --- a/frontend/src/views/files/Preview.vue +++ b/frontend/src/views/files/Preview.vue @@ -1,6 +1,8 @@