refs #680 Open the links in meta fields in the default browser
This commit is contained in:
parent
07234367ce
commit
5fca328af3
|
@ -153,12 +153,12 @@ export default {
|
|||
}
|
||||
},
|
||||
tootClick (e) {
|
||||
if (isTag(e.target)) {
|
||||
if (isTag(e.target, 'favourite')) {
|
||||
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
||||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const parsedAccount = findAccount(e.target)
|
||||
const parsedAccount = findAccount(e.target, 'favourite')
|
||||
if (parsedAccount !== null) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', parsedAccount)
|
||||
|
@ -175,7 +175,7 @@ export default {
|
|||
})
|
||||
return parsedAccount.acct
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
const link = findLink(e.target, 'favourite')
|
||||
if (link !== null) {
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
|
|
|
@ -152,12 +152,12 @@ export default {
|
|||
}
|
||||
},
|
||||
tootClick (e) {
|
||||
if (isTag(e.target)) {
|
||||
if (isTag(e.target, 'reblog')) {
|
||||
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
||||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const parsedAccount = findAccount(e.target)
|
||||
const parsedAccount = findAccount(e.target, 'reblog')
|
||||
if (parsedAccount !== null) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', parsedAccount)
|
||||
|
@ -174,7 +174,7 @@ export default {
|
|||
})
|
||||
return parsedAccount
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
const link = findLink(e.target, 'reblog')
|
||||
if (link !== null) {
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
|
|
|
@ -239,12 +239,12 @@ export default {
|
|||
}
|
||||
},
|
||||
tootClick (e) {
|
||||
if (isTag(e.target)) {
|
||||
if (isTag(e.target, 'toot')) {
|
||||
const tag = `/${this.$route.params.id}/hashtag/${e.target.innerText}`
|
||||
this.$router.push({ path: tag })
|
||||
return tag
|
||||
}
|
||||
const parsedAccount = findAccount(e.target)
|
||||
const parsedAccount = findAccount(e.target, 'toot')
|
||||
if (parsedAccount !== null) {
|
||||
this.$store.commit('TimelineSpace/Contents/SideBar/changeOpenSideBar', true)
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/searchAccount', parsedAccount)
|
||||
|
@ -261,7 +261,7 @@ export default {
|
|||
})
|
||||
return parsedAccount.acct
|
||||
}
|
||||
const link = findLink(e.target)
|
||||
const link = findLink(e.target, 'toot')
|
||||
if (link !== null) {
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<dt>
|
||||
{{ data.name }}
|
||||
</dt>
|
||||
<dd v-html="data.value">
|
||||
<dd v-html="data.value" @click.capture.prevent="metadataClick">
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
@ -109,6 +109,7 @@
|
|||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import { shell } from 'electron'
|
||||
import { findLink } from '~/src/renderer/utils/tootParser'
|
||||
import Timeline from './AccountProfile/Timeline'
|
||||
import Follows from './AccountProfile/Follows'
|
||||
import Followers from './AccountProfile/Followers'
|
||||
|
@ -161,7 +162,7 @@ export default {
|
|||
}
|
||||
},
|
||||
noteClick (e) {
|
||||
const link = findLink(e.target)
|
||||
const link = findLink(e.target, 'note')
|
||||
if (link !== null) {
|
||||
shell.openExternal(link)
|
||||
}
|
||||
|
@ -220,22 +221,15 @@ export default {
|
|||
unblock (account) {
|
||||
this.$store.dispatch('TimelineSpace/Contents/SideBar/AccountProfile/unblock', account)
|
||||
this.$refs.popper.doClose()
|
||||
},
|
||||
metadataClick (e) {
|
||||
const link = findLink(e.target, 'metadata')
|
||||
if (link !== null) {
|
||||
return shell.openExternal(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findLink (target) {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if (target.parentNode.getAttribute('class') === 'note') {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
export function findLink (target) {
|
||||
export function findLink (target, parentClass = 'toot') {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if ((target.parentNode.getAttribute('class') === 'toot') ||
|
||||
(target.parentNode.getAttribute('class') === 'favourite') ||
|
||||
(target.parentNode.getAttribute('class') === 'reblog')) {
|
||||
if (target.parentNode.getAttribute('class') === parentClass) {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
return findLink(target.parentNode, parentClass)
|
||||
}
|
||||
|
||||
export function isTag (target) {
|
||||
export function isTag (target, parentClass = 'toot') {
|
||||
if (target.getAttribute('class') && target.getAttribute('class').includes('hashtag')) {
|
||||
return true
|
||||
}
|
||||
|
@ -25,15 +23,13 @@ export function isTag (target) {
|
|||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return false
|
||||
}
|
||||
if ((target.parentNode.getAttribute('class') === 'toot') ||
|
||||
(target.parentNode.getAttribute('class') === 'favourite') ||
|
||||
(target.parentNode.getAttribute('class') === 'reblog')) {
|
||||
if (target.parentNode.getAttribute('class') === parentClass) {
|
||||
return false
|
||||
}
|
||||
return isTag(target.parentNode)
|
||||
return isTag(target.parentNode, parentClass)
|
||||
}
|
||||
|
||||
export function findAccount (target) {
|
||||
export function findAccount (target, parentClass = 'toot') {
|
||||
if (target.getAttribute('class') && target.getAttribute('class').includes('u-url')) {
|
||||
return parseAccount(target.href)
|
||||
}
|
||||
|
@ -45,12 +41,10 @@ export function findAccount (target) {
|
|||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
if ((target.parentNode.getAttribute('class') === 'toot') ||
|
||||
(target.parentNode.getAttribute('class') === 'favourite') ||
|
||||
(target.parentNode.getAttribute('class') === 'reblog')) {
|
||||
if (target.parentNode.getAttribute('class') === parentClass) {
|
||||
return null
|
||||
}
|
||||
return findAccount(target.parentNode)
|
||||
return findAccount(target.parentNode, parentClass)
|
||||
}
|
||||
|
||||
export function parseAccount (accountURL) {
|
||||
|
|
Loading…
Reference in New Issue