Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 94e23bb

Browse files
authored
chore: version 2.8.2 (#159)
* fix: 修复普通文本代码渲染和深色模式下的问题[#139][#154] * chore: version 2.8.2
1 parent 21fb4f8 commit 94e23bb

File tree

8 files changed

+234
-13
lines changed

8 files changed

+234
-13
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"dockerhub",
3030
"esno",
3131
"GPTAPI",
32+
"hljs",
3233
"iconify",
3334
"logprobs",
3435
"nodata",

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## v2.8.2
2+
3+
`2023-02-28`
4+
### Enhancement
5+
- 代码主题调整为 `One Dark - light|dark` 适配深色模式
6+
### BugFix
7+
- 修复普通文本代码渲染和深色模式下的问题[#139][#154]
8+
19
## v2.8.1
210

311
`2023-02-27`

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ version: '3'
174174

175175
services:
176176
app:
177-
image: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可
177+
image: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可
178178
ports:
179179
- 3002:3002
180180
environment:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chatgpt-web",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"private": false,
55
"description": "ChatGPT Web",
66
"author": "ChenZhaoYu <[email protected]>",

src/plugins/assets.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import 'highlight.js/styles/xcode.css'
21
import '@/styles/lib/tailwind.css'
2+
import '@/styles/lib/highlight.less'
33
import '@/styles/lib/github-markdown.less'
44
import '@/styles/global.less'
55

src/styles/lib/highlight.less

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
html.dark {
2+
pre code.hljs {
3+
display: block;
4+
overflow-x: auto;
5+
padding: 1em
6+
}
7+
8+
code.hljs {
9+
padding: 3px 5px
10+
}
11+
12+
.hljs {
13+
color: #abb2bf;
14+
background: #282c34
15+
}
16+
17+
.hljs-keyword,
18+
.hljs-operator,
19+
.hljs-pattern-match {
20+
color: #f92672
21+
}
22+
23+
.hljs-function,
24+
.hljs-pattern-match .hljs-constructor {
25+
color: #61aeee
26+
}
27+
28+
.hljs-function .hljs-params {
29+
color: #a6e22e
30+
}
31+
32+
.hljs-function .hljs-params .hljs-typing {
33+
color: #fd971f
34+
}
35+
36+
.hljs-module-access .hljs-module {
37+
color: #7e57c2
38+
}
39+
40+
.hljs-constructor {
41+
color: #e2b93d
42+
}
43+
44+
.hljs-constructor .hljs-string {
45+
color: #9ccc65
46+
}
47+
48+
.hljs-comment,
49+
.hljs-quote {
50+
color: #b18eb1;
51+
font-style: italic
52+
}
53+
54+
.hljs-doctag,
55+
.hljs-formula {
56+
color: #c678dd
57+
}
58+
59+
.hljs-deletion,
60+
.hljs-name,
61+
.hljs-section,
62+
.hljs-selector-tag,
63+
.hljs-subst {
64+
color: #e06c75
65+
}
66+
67+
.hljs-literal {
68+
color: #56b6c2
69+
}
70+
71+
.hljs-addition,
72+
.hljs-attribute,
73+
.hljs-meta .hljs-string,
74+
.hljs-regexp,
75+
.hljs-string {
76+
color: #98c379
77+
}
78+
79+
.hljs-built_in,
80+
.hljs-class .hljs-title,
81+
.hljs-title.class_ {
82+
color: #e6c07b
83+
}
84+
85+
.hljs-attr,
86+
.hljs-number,
87+
.hljs-selector-attr,
88+
.hljs-selector-class,
89+
.hljs-selector-pseudo,
90+
.hljs-template-variable,
91+
.hljs-type,
92+
.hljs-variable {
93+
color: #d19a66
94+
}
95+
96+
.hljs-bullet,
97+
.hljs-link,
98+
.hljs-meta,
99+
.hljs-selector-id,
100+
.hljs-symbol,
101+
.hljs-title {
102+
color: #61aeee
103+
}
104+
105+
.hljs-emphasis {
106+
font-style: italic
107+
}
108+
109+
.hljs-strong {
110+
font-weight: 700
111+
}
112+
113+
.hljs-link {
114+
text-decoration: underline
115+
}
116+
}
117+
118+
html {
119+
pre code.hljs {
120+
display: block;
121+
overflow-x: auto;
122+
padding: 1em
123+
}
124+
125+
code.hljs {
126+
padding: 3px 5px
127+
}
128+
129+
.hljs {
130+
color: #383a42;
131+
background: #fafafa
132+
}
133+
134+
.hljs-comment,
135+
.hljs-quote {
136+
color: #a0a1a7;
137+
font-style: italic
138+
}
139+
140+
.hljs-doctag,
141+
.hljs-formula,
142+
.hljs-keyword {
143+
color: #a626a4
144+
}
145+
146+
.hljs-deletion,
147+
.hljs-name,
148+
.hljs-section,
149+
.hljs-selector-tag,
150+
.hljs-subst {
151+
color: #e45649
152+
}
153+
154+
.hljs-literal {
155+
color: #0184bb
156+
}
157+
158+
.hljs-addition,
159+
.hljs-attribute,
160+
.hljs-meta .hljs-string,
161+
.hljs-regexp,
162+
.hljs-string {
163+
color: #50a14f
164+
}
165+
166+
.hljs-attr,
167+
.hljs-number,
168+
.hljs-selector-attr,
169+
.hljs-selector-class,
170+
.hljs-selector-pseudo,
171+
.hljs-template-variable,
172+
.hljs-type,
173+
.hljs-variable {
174+
color: #986801
175+
}
176+
177+
.hljs-bullet,
178+
.hljs-link,
179+
.hljs-meta,
180+
.hljs-selector-id,
181+
.hljs-symbol,
182+
.hljs-title {
183+
color: #4078f2
184+
}
185+
186+
.hljs-built_in,
187+
.hljs-class .hljs-title,
188+
.hljs-title.class_ {
189+
color: #c18401
190+
}
191+
192+
.hljs-emphasis {
193+
font-style: italic
194+
}
195+
196+
.hljs-strong {
197+
font-weight: 700
198+
}
199+
200+
.hljs-link {
201+
text-decoration: underline
202+
}
203+
}

src/views/chat/components/Message/Text.vue

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ renderer.html = (html) => {
2424
2525
renderer.code = (code, language) => {
2626
const validLang = !!(language && hljs.getLanguage(language))
27-
const highlighted = validLang ? hljs.highlight(language, code).value : code
28-
return `<pre><code class="hljs ${language}">${highlighted}</code></pre>`
27+
if (validLang)
28+
return `<pre><code class="hljs ${language}">${hljs.highlight(language, code).value}</code></pre>`
29+
return `<pre style="background: none">${hljs.highlightAuto(code).value}</pre>`
2930
}
3031
31-
marked.setOptions({ renderer })
32+
marked.setOptions({
33+
renderer,
34+
highlight(code) {
35+
return hljs.highlightAuto(code).value
36+
},
37+
})
3238
3339
const wrapClass = computed(() => {
3440
return [

src/views/chat/components/Message/style.less

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
background-color: transparent;
33
font-size: 14px;
44

5-
p{
5+
p {
66
white-space: pre-wrap;
77
}
88

@@ -23,13 +23,16 @@
2323
pre {
2424
background-color: #fff;
2525
}
26+
27+
code.hljs{
28+
padding: 0;
29+
}
2630
}
2731

28-
.dark{
29-
.markdown-body{
30-
.highlight pre,
31-
pre {
32-
background-color: #18181c;
33-
}
32+
html.dark {
33+
34+
.highlight pre,
35+
pre {
36+
background-color: #282c34;
3437
}
3538
}

0 commit comments

Comments
 (0)