Merge pull request #364 from h3poteto/iss-358
closes #358 Open tag timeline page when click tag in toot
This commit is contained in:
commit
ca2deb4b7c
|
@ -36,6 +36,7 @@
|
|||
<script>
|
||||
import moment from 'moment'
|
||||
import { shell } from 'electron'
|
||||
import { findLink, isTag } from '../../../../utils/link'
|
||||
|
||||
export default {
|
||||
name: 'favourite',
|
||||
|
@ -52,9 +53,14 @@ export default {
|
|||
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
|
||||
},
|
||||
tootClick (e) {
|
||||
if (isTag(e.target)) {
|
||||
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
||||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
if (link !== null) {
|
||||
shell.openExternal(link)
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
},
|
||||
openUser (account) {
|
||||
|
@ -64,19 +70,6 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findLink (target) {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'favourite') {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
<script>
|
||||
import moment from 'moment'
|
||||
import { shell } from 'electron'
|
||||
import { findLink, isTag } from '../../../../utils/link'
|
||||
|
||||
export default {
|
||||
name: 'reblog',
|
||||
|
@ -52,9 +53,14 @@ export default {
|
|||
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
|
||||
},
|
||||
tootClick (e) {
|
||||
if (isTag(e.target)) {
|
||||
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
||||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
if (link !== null) {
|
||||
shell.openExternal(link)
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
},
|
||||
openUser (account) {
|
||||
|
@ -64,19 +70,6 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findLink (target) {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'reblog') {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
import moment from 'moment'
|
||||
import { shell, clipboard } from 'electron'
|
||||
import { mapState } from 'vuex'
|
||||
import { findLink, isTag } from '../../../utils/link'
|
||||
|
||||
export default {
|
||||
name: 'toot',
|
||||
|
@ -155,9 +156,14 @@ export default {
|
|||
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
|
||||
},
|
||||
tootClick (e) {
|
||||
if (isTag(e.target)) {
|
||||
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
||||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
if (link !== null) {
|
||||
shell.openExternal(link)
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
},
|
||||
openReply (message) {
|
||||
|
@ -293,19 +299,6 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findLink (target) {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'toot') {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -31,6 +31,11 @@ export default {
|
|||
tag: ''
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (this.$route.name === 'tag') {
|
||||
this.tag = this.$route.params.tag
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route': function (route) {
|
||||
if (route.name === 'tag') {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
export function findLink (target) {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'toot') {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
}
|
||||
|
||||
export function isTag (target) {
|
||||
if (target.getAttribute('class') && target.getAttribute('class').includes('hashtag')) {
|
||||
return true
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return false
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'toot') {
|
||||
return false
|
||||
}
|
||||
return isTag(target.parentNode)
|
||||
}
|
Loading…
Reference in New Issue