mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-10-21 03:11:21 +00:00
add code highlighting
This commit is contained in:
12
src/main.ts
12
src/main.ts
@@ -3,7 +3,8 @@ import App from './App.vue'
|
||||
import { setupAssets } from '@/plugins'
|
||||
import { setupStore } from '@/store'
|
||||
import { setupRouter } from '@/router'
|
||||
|
||||
import hljs from 'highlight.js'
|
||||
import "highlight.js/styles/xcode.css"
|
||||
async function bootstrap() {
|
||||
const app = createApp(App)
|
||||
setupAssets()
|
||||
@@ -12,6 +13,15 @@ async function bootstrap() {
|
||||
|
||||
await setupRouter(app)
|
||||
|
||||
let regexp = /^(?:\s{4}|\t).+/gm
|
||||
app.directive('hljs', {
|
||||
mounted: (el: HTMLElement) => {
|
||||
if (el.textContent?.indexOf(" = ") != -1 || el.textContent.match(regexp)) {
|
||||
hljs.highlightBlock(el)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
app.mount('#app')
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user