mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-01-27 07:46:15 +01:00
Merge pull request #56 from h3poteto/iss-49
closes #49 Open link with default browser in toot
This commit is contained in:
commit
58c2c3295c
@ -12,7 +12,7 @@
|
||||
{{ parseDatetime(message.created_at) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="content" v-html="message.content"></div>
|
||||
<div class="content" v-html="message.content" @click.capture.prevent="tootClick"></div>
|
||||
<div class="tool-box">
|
||||
<el-button type="text"><icon name="reply" scale="0.9"></icon></el-button>
|
||||
<el-button type="text"><icon name="retweet" scale="0.9"></icon></el-button>
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
<script>
|
||||
import moment from 'moment'
|
||||
import { shell } from 'electron'
|
||||
|
||||
export default {
|
||||
name: 'toot',
|
||||
@ -33,9 +34,25 @@ export default {
|
||||
methods: {
|
||||
parseDatetime (datetime) {
|
||||
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
|
||||
},
|
||||
tootClick (e) {
|
||||
const link = findLink(e.target)
|
||||
if (link !== null) {
|
||||
shell.openExternal(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findLink (target) {
|
||||
if (target.localName === 'a') {
|
||||
return target.href
|
||||
}
|
||||
if (target.parentNode === undefined || target.parentNode === null) {
|
||||
return null
|
||||
}
|
||||
return findLink(target.parentNode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
Loading…
x
Reference in New Issue
Block a user