feat: automatically jump to the next photo when deleting while previewing (#1143)
This commit is contained in:
parent
e8b4e9af46
commit
9515ceeb42
|
@ -133,16 +133,29 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted () {
|
async mounted () {
|
||||||
window.addEventListener('keyup', this.key)
|
window.addEventListener('keydown', this.key)
|
||||||
this.$store.commit('setPreviewMode', true)
|
this.$store.commit('setPreviewMode', true)
|
||||||
this.listing = this.oldReq.items
|
this.listing = this.oldReq.items
|
||||||
|
this.$root.$on('preview-deleted', this.deleted)
|
||||||
this.updatePreview()
|
this.updatePreview()
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
window.removeEventListener('keyup', this.key)
|
window.removeEventListener('keydown', this.key)
|
||||||
this.$store.commit('setPreviewMode', false)
|
this.$store.commit('setPreviewMode', false)
|
||||||
|
this.$root.$off('preview-deleted', this.deleted)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
deleted () {
|
||||||
|
this.listing = this.listing.filter(item => item.name !== this.name)
|
||||||
|
|
||||||
|
if (this.hasNext) {
|
||||||
|
this.next()
|
||||||
|
} else if (!this.hasPrevious && !this.hasNext) {
|
||||||
|
this.back()
|
||||||
|
} else {
|
||||||
|
this.prev()
|
||||||
|
}
|
||||||
|
},
|
||||||
back () {
|
back () {
|
||||||
this.$store.commit('setPreviewMode', false)
|
this.$store.commit('setPreviewMode', false)
|
||||||
let uri = url.removeLastDir(this.$route.path) + '/'
|
let uri = url.removeLastDir(this.$route.path) + '/'
|
||||||
|
@ -155,7 +168,6 @@ export default {
|
||||||
this.$router.push({ path: this.nextLink })
|
this.$router.push({ path: this.nextLink })
|
||||||
},
|
},
|
||||||
key (event) {
|
key (event) {
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
if (this.show !== null) {
|
if (this.show !== null) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
<script>
|
<script>
|
||||||
import {mapGetters, mapMutations, mapState} from 'vuex'
|
import {mapGetters, mapMutations, mapState} from 'vuex'
|
||||||
import { files as api } from '@/api'
|
import { files as api } from '@/api'
|
||||||
import url from '@/utils/url'
|
|
||||||
import buttons from '@/utils/buttons'
|
import buttons from '@/utils/buttons'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -32,17 +31,20 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(['closeHovers']),
|
...mapMutations(['closeHovers']),
|
||||||
submit: async function () {
|
submit: async function () {
|
||||||
this.closeHovers()
|
|
||||||
buttons.loading('delete')
|
buttons.loading('delete')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.isListing) {
|
if (!this.isListing) {
|
||||||
await api.remove(this.$route.path)
|
await api.remove(this.$route.path)
|
||||||
buttons.success('delete')
|
buttons.success('delete')
|
||||||
this.$router.push({ path: url.removeLastDir(this.$route.path) + '/' })
|
|
||||||
|
this.$root.$emit('preview-deleted')
|
||||||
|
this.closeHovers()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.closeHovers()
|
||||||
|
|
||||||
if (this.selectedCount === 0) {
|
if (this.selectedCount === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue