fix: stay in the same position after renaming or deleting (#3039)

This commit is contained in:
niubility000 2024-03-07 18:14:40 +08:00 committed by GitHub
parent e167c3e1ef
commit cdf8def330
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 8 deletions

View File

@ -45,6 +45,7 @@ export default {
submit: async function () { submit: async function () {
buttons.loading("delete"); buttons.loading("delete");
window.sessionStorage.setItem("modified", "true");
try { try {
if (!this.isListing) { if (!this.isListing) {
await api.remove(this.$route.path); await api.remove(this.$route.path);

View File

@ -88,6 +88,7 @@ export default {
newLink = newLink =
url.removeLastDir(oldLink) + "/" + encodeURIComponent(this.name); url.removeLastDir(oldLink) + "/" + encodeURIComponent(this.name);
window.sessionStorage.setItem("modified", "true");
try { try {
await api.move([{ from: oldLink, to: newLink }]); await api.move([{ from: oldLink, to: newLink }]);
if (!this.isListing) { if (!this.isListing) {

View File

@ -54,8 +54,7 @@ export default {
currentView() { currentView() {
if (this.req.type == undefined || this.req.isDir) { if (this.req.type == undefined || this.req.isDir) {
return null; return null;
} } else if (
else if (
this.req.type === "text" || this.req.type === "text" ||
this.req.type === "textImmutable" this.req.type === "textImmutable"
) { ) {
@ -72,11 +71,11 @@ export default {
$route: function (to, from) { $route: function (to, from) {
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(); this.fetchData();
return; return;
} else { } else {
window.sessionStorage.setItem('listFrozen', "true"); window.sessionStorage.setItem("listFrozen", "true");
this.fetchData(); this.fetchData();
return; return;
} }
@ -117,7 +116,7 @@ export default {
this.$store.commit("closeHovers"); this.$store.commit("closeHovers");
// 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"){
this.setLoading(true); this.setLoading(true);
} }
this.error = null; this.error = null;

View File

@ -1,5 +1,9 @@
<template> <template>
<div id="editor-container"> <div
id="editor-container"
@touchmove.prevent.stop
@wheel.prevent.stop
>
<header-bar> <header-bar>
<action icon="close" :label="$t('buttons.close')" @action="close()" /> <action icon="close" :label="$t('buttons.close')" @action="close()" />
<title>{{ req.name }}</title> <title>{{ req.name }}</title>

View File

@ -383,7 +383,7 @@ export default {
}, },
watch: { watch: {
req: function () { req: function () {
if (window.sessionStorage.getItem('listFrozen') !=="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 = 50;
@ -397,7 +397,8 @@ export default {
}); });
} }
if (this.req.isDir) { if (this.req.isDir) {
window.sessionStorage.setItem('listFrozen', "false"); window.sessionStorage.setItem("listFrozen", "false");
window.sessionStorage.setItem("modified", "false");
} }
}, },
}, },