mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
fix: fix open attachment
This commit is contained in:
@@ -24,7 +24,7 @@ async function uploadFile (file: any, asImage: boolean) {
|
||||
if (asImage) {
|
||||
insert(`})\n`)
|
||||
} else {
|
||||
insert(`[${dayjs().format('YYYY-MM-DD HH:mm')}] [${file.name} (${(file.size / 1024).toFixed(2)}KiB)](${encodeMarkdownLink(assetPath)}){class=open target=_blank}\n`)
|
||||
insert(`[${dayjs().format('YYYY-MM-DD HH:mm')}] [${file.name} (${(file.size / 1024).toFixed(2)}KiB)](${encodeMarkdownLink(assetPath)}){.open}\n`)
|
||||
}
|
||||
|
||||
refreshTree()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { sleep } from '@fe/utils'
|
||||
import { isElectron } from '@fe/support/env'
|
||||
import { basename, dirname, join, resolve } from '@fe/utils/path'
|
||||
import { switchDoc } from '@fe/services/document'
|
||||
import { openExternal, openPath } from '@fe/services/base'
|
||||
import { getRepo, openExternal, openPath } from '@fe/services/base'
|
||||
|
||||
const handleLink = (link: HTMLAnchorElement, view: HTMLElement) => {
|
||||
const { currentFile } = store.state
|
||||
@@ -17,11 +17,6 @@ const handleLink = (link: HTMLAnchorElement, view: HTMLElement) => {
|
||||
const { repo: fileRepo, path: filePath } = currentFile
|
||||
|
||||
// open attachment in os
|
||||
if (link.classList.contains('open')) {
|
||||
fetch(link.href.replace('api/attachment', 'api/open'))
|
||||
return true
|
||||
}
|
||||
|
||||
const href = link.getAttribute('href') || ''
|
||||
|
||||
if (/^(http:|https:|ftp:)\/\//i.test(href)) { // external link
|
||||
@@ -32,6 +27,10 @@ const handleLink = (link: HTMLAnchorElement, view: HTMLElement) => {
|
||||
} else if (/^file:\/\//i.test(href)) {
|
||||
openPath(decodeURI(href.replace(/^file:\/\//i, '')))
|
||||
return true
|
||||
} else if (link.classList.contains('open')) {
|
||||
const path = link.getAttribute('origin-href') || decodeURI(href)
|
||||
openPath(join(getRepo(fileRepo)?.path || '/', path))
|
||||
return true
|
||||
} else { // relative link
|
||||
// better scrollIntoView
|
||||
const scrollIntoView = (el: HTMLElement) => {
|
||||
|
||||
Reference in New Issue
Block a user