fix: remain in the same position of list when back

This commit is contained in:
niubility000 2024-03-16 02:55:06 +08:00 committed by GitHub
parent 1c079a2719
commit b27d5b2dcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,18 +4,20 @@
<breadcrumbs base="/files" /> <breadcrumbs base="/files" />
<listing /> <listing />
<errors v-if="error" :errorCode="error.status" /> <transition name="closing">
<component v-else-if="currentView" :is="currentView"></component> <errors v-if="error" :errorCode="error.status" />
<div v-else-if="currentView !== null"> <component v-else-if="currentView" :is="currentView"></component>
<h2 class="message delayed"> <div v-else-if="currentView !== null">
<div class="spinner"> <h2 class="message delayed">
<div class="bounce1"></div> <div class="spinner">
<div class="bounce2"></div> <div class="bounce1"></div>
<div class="bounce3"></div> <div class="bounce2"></div>
</div> <div class="bounce3"></div>
<span>{{ $t("files.loading") }}</span> </div>
</h2> <span>{{ $t("files.loading") }}</span>
</div> </h2>
</div>
</transition>
</div> </div>
</template> </template>
@ -74,26 +76,18 @@ export default {
this.parentDir = "true"; this.parentDir = "true";
} else { } else {
this.parentDir = "false"; this.parentDir = "false";
window.sessionStorage.removeItem(to.path); window.sessionStorage.removeItem(to.path);
} }
if (from.path.endsWith("/")) { if (from.path.endsWith("/")) {
if (to.path.endsWith("/")) { if (to.path.endsWith("/")) {
window.sessionStorage.setItem("listFrozen", "false"); window.sessionStorage.setItem("listFrozen", "false");
this.fetchData();
return;
} else { } else {
window.sessionStorage.setItem("listFrozen", "true"); window.sessionStorage.setItem("listFrozen", "true");
this.fetchData();
return;
} }
} else if (to.path.endsWith("/")) { } else if (to.path.endsWith("/")) {
this.$store.commit("updateRequest", {}); this.$store.commit("updateRequest", {});
this.fetchData();
return;
} else {
this.fetchData();
return;
} }
this.fetchData();
}, },
reload: function (value) { reload: function (value) {
if (value === true) { if (value === true) {
@ -125,7 +119,7 @@ export default {
// Set loading to true and reset the error. // Set loading to true and reset the error.
if (window.sessionStorage.getItem("listFrozen") !=="true" if (window.sessionStorage.getItem("listFrozen") !=="true"
&& window.sessionStorage.getItem("modified") !=="true" && window.sessionStorage.getItem("modified") !=="true"
&& this.parentDir !== "true"){ && this.parentDir !== "true"){
this.setLoading(true); this.setLoading(true);
} }
this.error = null; this.error = null;
@ -159,3 +153,13 @@ export default {
}, },
}; };
</script> </script>
<style>
.closing-leave-active {
animation: closing 0.5s
}
@keyframes closing {
to {
transform: scale(0);
}
}
</style>