mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-21 03:44:21 +00:00

* feat: 支持 markdown 格式和图片 * perf: 重载的时候滚动条保持 * chore: version 2.5.2 * feat: 添加文字换行 * chore: 添加新封面 * chore: 更新 cover
22 lines
534 B
TypeScript
22 lines
534 B
TypeScript
import type { App, Directive } from 'vue'
|
|
import hljs from 'highlight.js'
|
|
import includeCode from '@/utils/functions/includeCode'
|
|
|
|
function highlightCode(el: HTMLElement) {
|
|
if (includeCode(el.textContent))
|
|
hljs.highlightBlock(el)
|
|
}
|
|
|
|
export default function setupHighlightDirective(app: App) {
|
|
const highLightDirective: Directive<HTMLElement> = {
|
|
mounted(el: HTMLElement) {
|
|
highlightCode(el)
|
|
},
|
|
updated(el: HTMLElement) {
|
|
highlightCode(el)
|
|
},
|
|
}
|
|
|
|
app.directive('highlight', highLightDirective)
|
|
}
|