ui: 修正 chat-file 為 超鏈接
This commit is contained in:
@@ -7,16 +7,24 @@ customElements.define('chat-file', class extends HTMLElement {
|
|||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
this.style.display = 'block'
|
this.style.display = 'block'
|
||||||
const e = new DOMParser().parseFromString(`
|
const e = new DOMParser().parseFromString(`
|
||||||
<div style="width: 100%;height: 100%;">
|
<a style="width: 100%;height: 100%;">
|
||||||
<mdui-card variant="outlined" clickable style="display: flex;align-items: center;">
|
<mdui-card variant="outlined" clickable style="display: flex;align-items: center;">
|
||||||
<mdui-icon name="insert_drive_file" style="margin: 13px;font-size: 34px;"></mdui-icon>
|
<mdui-icon name="insert_drive_file" style="margin: 13px;font-size: 34px;"></mdui-icon>
|
||||||
<span style="margin-right: 13px;"></span>
|
<span style="margin-right: 13px;"></span>
|
||||||
</mdui-card>
|
</mdui-card>
|
||||||
</div>`, 'text/html').body.firstChild as HTMLElement
|
</a>`, 'text/html').body.firstChild as HTMLElement
|
||||||
$(e).find('span').text($(this).attr("name"))
|
$(e).find('span').text($(this).attr("name"))
|
||||||
const href = $(this).attr('href')
|
const href = $(this).attr('href')
|
||||||
|
$(e).attr('href', href)
|
||||||
|
$(e).attr('target', '_blank')
|
||||||
|
$(e).attr('download', href)
|
||||||
|
e.style.textDecoration = 'none'
|
||||||
|
e.style.color = 'inherit'
|
||||||
// deno-lint-ignore no-window
|
// deno-lint-ignore no-window
|
||||||
e.onclick = () => window.open(href, '_blank')
|
e.onclick = (e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
window.open(href, '_blank')
|
||||||
|
}
|
||||||
this.appendChild(e)
|
this.appendChild(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user