mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-08 04:50:45 +08:00
@@ -75,8 +75,8 @@
|
|||||||
<star v-if="!article.rssExcluded" class="featured-icon" />
|
<star v-if="!article.rssExcluded" class="featured-icon" />
|
||||||
{{ article.title }}
|
{{ article.title }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink class="article-item-description main-item">
|
<NuxtLink class="article-item-description main-item" :to="`/posts/${article.id}`">
|
||||||
{{ sanitizeDescription(article.description) }}
|
<div v-html="sanitizeDescription(article.description)"></div>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div class="article-info-container main-item">
|
<div class="article-info-container main-item">
|
||||||
<ArticleCategory :category="article.category" />
|
<ArticleCategory :category="article.category" />
|
||||||
@@ -378,8 +378,27 @@ onBeforeUnmount(() => {
|
|||||||
/** 供 InfiniteLoadMore 重建用的 key:筛选/Tab 改变即重建内部状态 */
|
/** 供 InfiniteLoadMore 重建用的 key:筛选/Tab 改变即重建内部状态 */
|
||||||
const ioKey = computed(() => asyncKey.value.join('::'))
|
const ioKey = computed(() => asyncKey.value.join('::'))
|
||||||
|
|
||||||
/** 其他工具函数 **/
|
// 在首页摘要加载贴吧表情包
|
||||||
const sanitizeDescription = (text) => stripMarkdown(text)
|
const sanitizeDescription = (text) => {
|
||||||
|
if (!text) return ''
|
||||||
|
|
||||||
|
// 1️⃣ 先把 Markdown 转成纯文本
|
||||||
|
const plain = stripMarkdown(text)
|
||||||
|
|
||||||
|
// 2️⃣ 替换 :tieba123: 为 <img>
|
||||||
|
const withEmoji = plain.replace(/:tieba(\d+):/g, (match, num) => {
|
||||||
|
const key = `tieba${num}`
|
||||||
|
const file = tiebaEmoji[key]
|
||||||
|
return file
|
||||||
|
? `<img loading="lazy" class="emoji" src="${file}" alt="${key}">`
|
||||||
|
: match // 没有匹配到图片则保留原样
|
||||||
|
})
|
||||||
|
|
||||||
|
// 3️⃣ 可选:截断纯文本长度(防止撑太长)
|
||||||
|
const truncated = withEmoji.length > 500 ? withEmoji.slice(0, 500) + '…' : withEmoji
|
||||||
|
|
||||||
|
return truncated
|
||||||
|
}
|
||||||
|
|
||||||
// 页面选项同步到全局状态
|
// 页面选项同步到全局状态
|
||||||
watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user