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

This commit is contained in:
niubility000 2024-03-16 03:37:03 +08:00 committed by GitHub
parent 87e3b73a8f
commit 93e5fd321f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 9 deletions

View File

@ -28,7 +28,6 @@ import { mapState } from "vuex";
import { files as api } from "@/api"; import { files as api } from "@/api";
import { theme } from "@/utils/constants"; import { theme } from "@/utils/constants";
import buttons from "@/utils/buttons"; import buttons from "@/utils/buttons";
import url from "@/utils/url";
import { version as ace_version } from "ace-builds"; import { version as ace_version } from "ace-builds";
import ace from "ace-builds/src-min-noconflict/ace.js"; import ace from "ace-builds/src-min-noconflict/ace.js";
@ -148,8 +147,7 @@ export default {
this.$store.commit("updateRequest", {}); this.$store.commit("updateRequest", {});
let uri = url.removeLastDir(this.$route.path) + "/"; history.back();
this.$router.push({ path: uri });
}, },
}, },
}; };

View File

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

View File

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