File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 161161 bindEvents() {
162162 document.addEventListener('mouseover', (e: MouseEvent) => {
163163 // 检查链接是否在 main 标签内
164- const link = (e.target as HTMLElement)?.closest('article a.inner-link') as HTMLAnchorElement | null
164+ const link = (e.target as HTMLElement)?.closest(
165+ 'article a.inner-link'
166+ ) as HTMLAnchorElement | null
165167 if (!link) return
166168
167169 // 忽略预览窗口内的链接
227229 if (!href) return
228230
229231 this.clearTimers()
230- this.currentHref = href
232+ this.currentHref = href.replace('http://', 'https://');
231233
232234 if (this.gotoButton) {
233235 this.gotoButton.onclick = () => (window.location.href = href)
243245 const isExternalLink = !href.startsWith(window.location.origin) && !href.startsWith('/')
244246 if (isExternalLink) return
245247
246- let contentHtml = await this.getPreviewContent(href)
248+ const contentHtml = await this.getPreviewContent(href)
247249 if (!contentHtml) return
248250
249251 if (this.currentTarget === link && this.content) {
425427
426428 setupThemeObserver() {
427429 // 监听系统主题变化
428- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', async (e: MediaQueryListEvent) => {
429- if (document.documentElement.dataset.theme === 'system') {
430- await this.initializeMermaid()
431- if (this.content) {
432- await this.renderMermaidDiagrams(this.content)
430+ window
431+ .matchMedia('(prefers-color-scheme: dark)')
432+ .addEventListener('change', async (e: MediaQueryListEvent) => {
433+ if (document.documentElement.dataset.theme === 'system') {
434+ await this.initializeMermaid()
435+ if (this.content) {
436+ await this.renderMermaidDiagrams(this.content)
437+ }
433438 }
434- }
435- })
439+ })
436440
437441 // 监听主题切换
438442 const observer = new MutationObserver(async (mutations: MutationRecord[]) => {
You can’t perform that action at this time.
0 commit comments