feat: share management delete confirm (#1212)

This commit is contained in:
WeidiDeng
2021-01-12 06:54:16 +08:00
committed by GitHub
parent 019ce80fc5
commit b600b11415
5 changed files with 64 additions and 8 deletions

View File

@@ -73,19 +73,23 @@ export default {
this.clip.on('success', () => {
this.$showSuccess(this.$t('success.linkCopied'))
})
this.$root.$on('share-deleted', this.deleted)
},
beforeDestroy () {
this.clip.destroy()
this.$root.$off('share-deleted', this.deleted)
},
methods: {
deleteLink: async function (event, link) {
event.preventDefault()
try {
await api.remove(link.hash)
this.links = this.links.filter(item => item.hash !== link.hash)
} catch (e) {
this.$showError(e)
}
this.$store.commit('setHash', {
hash: link.hash,
path: link.path
})
this.$store.commit('showHover', 'share-delete')
},
deleted (hash) {
this.links = this.links.filter(item => item.hash !== hash)
},
humanTime (time) {
return moment(time * 1000).fromNow()