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:50:20 +08:00 committed by GitHub
parent 7797a4ef18
commit ecfb5fb913
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,7 @@ export default {
return {
error: null,
width: window.innerWidth,
parentDir: false,
};
},
computed: {
@ -69,6 +70,12 @@ export default {
},
watch: {
$route: function (to, from) {
if (to.path.endsWith("/") && from.path.startsWith(to.path) && from.path.length > to.path.length ){
this.parentDir = "true";
} else {
this.parentDir = "false";
window.sessionStorage.removeItem(to.path);
}
if (from.path.endsWith("/")) {
if (to.path.endsWith("/")) {
window.sessionStorage.setItem("listFrozen", "false");
@ -116,7 +123,9 @@ export default {
this.$store.commit("closeHovers");
// Set loading to true and reset the error.
if (window.sessionStorage.getItem("listFrozen") !=="true" && window.sessionStorage.getItem("modified") !=="true"){
if (window.sessionStorage.getItem("listFrozen") !=="true"
&& window.sessionStorage.getItem("modified") !=="true"
&& this.parentDir !== "true"){
this.setLoading(true);
}
this.error = null;