feat: remain in the same position of the list when back from a sub folder

This commit is contained in:
niubility000 2024-03-15 10:51:16 +08:00 committed by GitHub
parent ecfb5fb913
commit 2db8a77c7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 8 deletions

View File

@ -148,8 +148,7 @@ export default {
this.$store.commit("updateRequest", {});
let uri = url.removeLastDir(this.$route.path) + "/";
this.$router.push({ path: uri });
history.back();
},
},
};

View File

@ -385,7 +385,7 @@ export default {
req: function () {
if (window.sessionStorage.getItem("listFrozen") !=="true" && window.sessionStorage.getItem("modified") !=="true"){
// Reset the show value
this.showLimit = 50;
this.showLimit = this.req.numDirs + this.req.numFiles;
// Ensures that the listing is displayed
Vue.nextTick(() => {
@ -394,6 +394,11 @@ export default {
// Fill and fit the window with listing items
this.fillWindow(true);
if (window.sessionStorage.getItem(this.$route.path)) {
this.addSelected(JSON.parse(window.sessionStorage.getItem(this.$route.path))[1]);
document.documentElement.scrollTop = JSON.parse(window.sessionStorage.getItem(this.$route.path))[0];
window.sessionStorage.removeItem(this.$route.path);
}
});
}
if (this.req.isDir) {
@ -882,9 +887,9 @@ export default {
const windowHeight = window.innerHeight;
// Quantity of items needed to fill 2x of the window height
const showQuantity = Math.ceil(
(windowHeight + windowHeight * 2) / this.itemWeight
);
const showQuantity = window.sessionStorage.getItem(this.$route.path) ?
Math.ceil((JSON.parse(window.sessionStorage.getItem(this.$route.path))[0] + windowHeight * 2) / this.itemWeight) :
Math.ceil((windowHeight + windowHeight * 2) / this.itemWeight);
// Less items to display than current
if (this.showLimit > showQuantity && !fit) return;

View File

@ -346,8 +346,7 @@ export default {
close() {
this.$store.commit("updateRequest", {});
let uri = url.removeLastDir(this.$route.path) + "/";
this.$router.push({ path: uri });
history.back();
},
download() {
window.open(this.downloadUrl);