feat: version 2.9.1 (#207)

* feat: i18n

* chore: format

* feat: 补充遗漏翻译

* chore: update deps

* feat: 复制代码块[#196][#197]

* chore: version 2.9.1
This commit is contained in:
Redon
2023-03-02 21:27:20 +08:00
committed by GitHub
parent 21cf1bdd9e
commit f19998d59b
26 changed files with 589 additions and 334 deletions

View File

@@ -4,6 +4,7 @@ import { marked } from 'marked'
import hljs from 'highlight.js'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import { encodeHTML } from '@/utils/format'
import { t } from '@/locales'
interface Props {
inversion?: boolean
@@ -26,8 +27,10 @@ renderer.html = (html) => {
renderer.code = (code, language) => {
const validLang = !!(language && hljs.getLanguage(language))
if (validLang)
return `<pre><code class="hljs ${language}">${hljs.highlight(language, code).value}</code></pre>`
if (validLang) {
const lang = language ?? ''
return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${lang}</span><span class="code-block-header__copy">${t('chat.copyCode')}</span></div><code class="hljs code-block-body ${language}">${hljs.highlight(lang, code).value}</code></pre>`
}
return `<pre style="background: none">${hljs.highlightAuto(code).value}</pre>`
}