perf: 文件浏览支持滑动返回上一个文件夹

This commit is contained in:
kuaifan 2022-06-19 10:42:39 +08:00
parent 073b1937f0
commit ba65c21a0b

View File

@ -6,6 +6,8 @@
</template> </template>
<script> <script>
import {mapState} from "vuex";
export default { export default {
name: "MobileBack", name: "MobileBack",
props: { props: {
@ -42,6 +44,8 @@ export default {
}, },
computed: { computed: {
...mapState(['files']),
style() { style() {
const offset = 135; const offset = 135;
const top = Math.max(offset, this.y) + this.windowScrollY, const top = Math.max(offset, this.y) + this.windowScrollY,
@ -51,6 +55,15 @@ export default {
left: this.x > 20 ? 0 : '-50px', left: this.x > 20 ? 0 : '-50px',
} }
}, },
routeName() {
return this.$route.name
},
fileFolderId() {
const {folderId} = this.$route.params;
return parseInt(/^\d+$/.test(folderId) ? folderId : 0);
},
}, },
watch: { watch: {
@ -100,13 +113,31 @@ export default {
if (!this.showTabbar) { if (!this.showTabbar) {
return true; return true;
} }
return this.$Modal.visibles().length > 0; if (this.$Modal.visibles().length > 0) {
return true;
}
if (this.fileFolderId > 0) {
return true;
}
return false;
}, },
onBack() { onBack() {
if (this.$Modal.removeLast()) { if (this.$Modal.removeLast()) {
return; return;
} }
if (this.fileFolderId > 0) {
const file = this.files.find(({id, permission}) => id == this.fileFolderId && permission > -1)
if (file) {
const prevFile = this.files.find(({id, permission}) => id == file.pid && permission > -1)
if (prevFile) {
this.goForward({name: 'manage-file', params: {folderId: prevFile.id, fileId: null}});
return;
}
}
this.goForward({name: 'manage-file'});
return;
}
this.goBack(); this.goBack();
}, },