1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2025-01-11 08:24:58 +01:00

refs #136 Open link on the default browser in notifications

This commit is contained in:
AkiraFukushima 2018-03-26 22:18:15 +09:00
parent 93e50f3143
commit 81fc81bf76
2 changed files with 36 additions and 2 deletions

View File

@ -25,7 +25,7 @@
{{ parseDatetime(message.status.created_at) }}
</div>
</div>
<div class="content" v-html="message.status.content"></div>
<div class="content" v-html="message.status.content" @click.capture.prevent="tootClick"></div>
</div>
</div>
<div class="clearfix"></div>
@ -35,6 +35,7 @@
<script>
import moment from 'moment'
import { shell } from 'electron'
export default {
name: 'favourite',
@ -49,9 +50,25 @@ export default {
},
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>

View File

@ -25,7 +25,7 @@
{{ parseDatetime(message.status.created_at) }}
</div>
</div>
<div class="content" v-html="message.status.content"></div>
<div class="content" v-html="message.status.content" @click.capture.prevent="tootClick"></div>
</div>
</div>
<div class="clearfix"></div>
@ -35,6 +35,7 @@
<script>
import moment from 'moment'
import { shell } from 'electron'
export default {
name: 'reblog',
@ -49,9 +50,25 @@ export default {
},
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>