1
0
mirror of https://github.com/elk-zone/elk synced 2024-11-27 22:38:11 +09:00

feat: open in new page when ctrl pressed

This commit is contained in:
三咲智子 2022-11-28 19:03:56 +08:00
parent 9fca8eee30
commit 2ff4041489
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E

View File

@ -21,16 +21,22 @@ const rebloggedBy = $computed(() => props.status.reblog ? props.status.account :
const el = ref<HTMLElement>()
const router = useRouter()
function onclick(e: MouseEvent | KeyboardEvent) {
const path = e.composedPath() as HTMLElement[]
function onclick(evt: MouseEvent | KeyboardEvent) {
const path = evt.composedPath() as HTMLElement[]
const el = path.find(el => ['A', 'BUTTON', 'IMG', 'VIDEO'].includes(el.tagName?.toUpperCase()))
if (!el)
go()
go(evt)
}
function go() {
cacheStatus(status)
router.push(getStatusPath(status))
function go(evt: MouseEvent | KeyboardEvent) {
const path = getStatusPath(status)
if (evt.metaKey || evt.ctrlKey) {
window.open(path)
}
else {
cacheStatus(status)
router.push(path)
}
}
const createdAt = useFormattedDateTime(status.createdAt)
@ -62,7 +68,7 @@ const timeago = useTimeAgo(() => status.createdAt, timeAgoOptions)
<div flex-auto />
<div text-sm text-secondary flex="~ row nowrap" hover:underline>
<CommonTooltip :content="createdAt">
<a :title="status.createdAt" :href="getStatusPath(status)" @click.prevent="go">
<a :title="status.createdAt" :href="getStatusPath(status)" @click.prevent="go($event)">
<time text-sm hover:underline :datetime="status.createdAt">
{{ timeago }}
</time>