diff --git a/src/views/docs/ExceptionDocsView.vue b/src/views/docs/ExceptionDocsView.vue index f9a705f..26009e2 100644 --- a/src/views/docs/ExceptionDocsView.vue +++ b/src/views/docs/ExceptionDocsView.vue @@ -58,12 +58,19 @@ -
+
+ @@ -96,6 +103,9 @@ const loadError = ref('') const keyword = ref('') const toc = ref([]) const searchSections = ref([]) +const previewVisible = ref(false) +const previewIndex = ref(0) +const previewUrls = computed(() => extractImageUrls(rawMarkdown.value, activeDocPath.value)) const renderedHtml = computed(() => renderMarkdown(rawMarkdown.value, activeDocPath.value)) const level3Toc = computed(() => toc.value.filter((item) => item.level === 3)) @@ -221,7 +231,7 @@ function renderMarkdown(markdown: string, docPath: string) { if (image) { const alt = escapeHtml(image[1]) const src = escapeHtml(resolveDocAsset(docPath, image[2])) - html.push(`
${alt}
${alt}
`) + html.push(`
${alt}
${alt}
`) return } @@ -243,6 +253,14 @@ function resolveDocAsset(docPath: string, assetPath: string) { return `${getDocsBase()}${encodeURI(normalized)}` } +function extractImageUrls(markdown: string, docPath: string) { + return markdown + .split('\n') + .map((line) => /^!\[[^\]]*]\(([^)]+)\)$/.exec(line.trim())?.[1]) + .filter((src): src is string => Boolean(src)) + .map((src) => resolveDocAsset(docPath, src)) +} + function buildHeadingId(text: string, counters: Map) { const base = text .toLowerCase() @@ -282,6 +300,15 @@ function jumpTo(id: string) { document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' }) }) } + +function handleArticleClick(event: MouseEvent) { + const target = event.target + if (!(target instanceof HTMLImageElement)) return + const src = target.dataset.previewSrc + if (!src) return + previewIndex.value = Math.max(previewUrls.value.indexOf(src), 0) + previewVisible.value = true +}