Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: version 2.8.2 #159

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: 修复普通文本代码渲染和深色模式下的问题[#139][#154]
  • Loading branch information
Chanzhaoyu committed Feb 28, 2023
commit 97c70bea3f76f2abbf941baf317dd0c8a5c5aa3a
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dockerhub",
"esno",
"GPTAPI",
"hljs",
"iconify",
"logprobs",
"nodata",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/assets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'highlight.js/styles/xcode.css'
import '@/styles/lib/tailwind.css'
import '@/styles/lib/highlight.less'
import '@/styles/lib/github-markdown.less'
import '@/styles/global.less'

Expand Down
203 changes: 203 additions & 0 deletions src/styles/lib/highlight.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
html.dark {
pre code.hljs {
display: block;
overflow-x: auto;
padding: 1em
}

code.hljs {
padding: 3px 5px
}

.hljs {
color: #abb2bf;
background: #282c34
}

.hljs-keyword,
.hljs-operator,
.hljs-pattern-match {
color: #f92672
}

.hljs-function,
.hljs-pattern-match .hljs-constructor {
color: #61aeee
}

.hljs-function .hljs-params {
color: #a6e22e
}

.hljs-function .hljs-params .hljs-typing {
color: #fd971f
}

.hljs-module-access .hljs-module {
color: #7e57c2
}

.hljs-constructor {
color: #e2b93d
}

.hljs-constructor .hljs-string {
color: #9ccc65
}

.hljs-comment,
.hljs-quote {
color: #b18eb1;
font-style: italic
}

.hljs-doctag,
.hljs-formula {
color: #c678dd
}

.hljs-deletion,
.hljs-name,
.hljs-section,
.hljs-selector-tag,
.hljs-subst {
color: #e06c75
}

.hljs-literal {
color: #56b6c2
}

.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string,
.hljs-regexp,
.hljs-string {
color: #98c379
}

.hljs-built_in,
.hljs-class .hljs-title,
.hljs-title.class_ {
color: #e6c07b
}

.hljs-attr,
.hljs-number,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-pseudo,
.hljs-template-variable,
.hljs-type,
.hljs-variable {
color: #d19a66
}

.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-symbol,
.hljs-title {
color: #61aeee
}

.hljs-emphasis {
font-style: italic
}

.hljs-strong {
font-weight: 700
}

.hljs-link {
text-decoration: underline
}
}

html {
pre code.hljs {
display: block;
overflow-x: auto;
padding: 1em
}

code.hljs {
padding: 3px 5px
}

.hljs {
color: #383a42;
background: #fafafa
}

.hljs-comment,
.hljs-quote {
color: #a0a1a7;
font-style: italic
}

.hljs-doctag,
.hljs-formula,
.hljs-keyword {
color: #a626a4
}

.hljs-deletion,
.hljs-name,
.hljs-section,
.hljs-selector-tag,
.hljs-subst {
color: #e45649
}

.hljs-literal {
color: #0184bb
}

.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string,
.hljs-regexp,
.hljs-string {
color: #50a14f
}

.hljs-attr,
.hljs-number,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-pseudo,
.hljs-template-variable,
.hljs-type,
.hljs-variable {
color: #986801
}

.hljs-bullet,
.hljs-link,
.hljs-meta,
.hljs-selector-id,
.hljs-symbol,
.hljs-title {
color: #4078f2
}

.hljs-built_in,
.hljs-class .hljs-title,
.hljs-title.class_ {
color: #c18401
}

.hljs-emphasis {
font-style: italic
}

.hljs-strong {
font-weight: 700
}

.hljs-link {
text-decoration: underline
}
}
12 changes: 9 additions & 3 deletions src/views/chat/components/Message/Text.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ renderer.html = (html) => {

renderer.code = (code, language) => {
const validLang = !!(language && hljs.getLanguage(language))
const highlighted = validLang ? hljs.highlight(language, code).value : code
return `<pre><code class="hljs ${language}">${highlighted}</code></pre>`
if (validLang)
return `<pre><code class="hljs ${language}">${hljs.highlight(language, code).value}</code></pre>`
return `<pre style="background: none">${hljs.highlightAuto(code).value}</pre>`
}

marked.setOptions({ renderer })
marked.setOptions({
renderer,
highlight(code) {
return hljs.highlightAuto(code).value
},
})

const wrapClass = computed(() => {
return [
Expand Down
17 changes: 10 additions & 7 deletions src/views/chat/components/Message/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
background-color: transparent;
font-size: 14px;

p{
p {
white-space: pre-wrap;
}

Expand All @@ -23,13 +23,16 @@
pre {
background-color: #fff;
}

code.hljs{
padding: 0;
}
}

.dark{
.markdown-body{
.highlight pre,
pre {
background-color: #18181c;
}
html.dark {

.highlight pre,
pre {
background-color: #282c34;
}
}