fix: add link logo, 以及跳转新窗口

This commit is contained in:
Tim
2025-08-26 10:47:02 +08:00
parent f01e8c942a
commit 6527b3790e
4 changed files with 6 additions and 9 deletions

View File

@@ -106,7 +106,7 @@ const md = new MarkdownIt({
md.use(mentionPlugin)
md.use(tiebaEmojiPlugin)
md.use(linkPlugin) // 添加链接插件
md.use(linkPlugin)
export function renderMarkdown(text) {
return md.render(text || '')

View File

@@ -16,6 +16,7 @@ export function createVditor(editorId, options = {}) {
const { placeholder = '', preview = {}, input, after } = options
const config = useRuntimeConfig()
const API_BASE_URL = config.public.apiBaseUrl
const WEBSITE_BASE_URL = config.public.websiteBaseUrl
const fetchMentions = async (value) => {
if (!value) {
@@ -80,7 +81,7 @@ export function createVditor(editorId, options = {}) {
}))
},
},
vditorPostCitation(API_BASE_URL),
vditorPostCitation(API_BASE_URL, WEBSITE_BASE_URL),
],
},
cdn: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/vditor',

View File

@@ -10,7 +10,7 @@ async function searchPost(apiBaseUrl, keyword) {
})
}
export default (apiBaseUrl) => {
export default (apiBaseUrl, websiteBaseUrl) => {
return {
key: '#',
hint: async (keyword) => {
@@ -22,8 +22,8 @@ export default (apiBaseUrl) => {
let value = ''
return (
body.map((item) => ({
value: `[${item.title}](/posts/${item.id})`,
html: `<div>${item.title}</div>`,
value: `[🔗${item.title}](${websiteBaseUrl}/posts/${item.id})`,
html: `<div><i class="fas fa-link"></i> ${item.title}</div>`,
})) ?? []
)
} else {