Skip to content

Commit 57c392d

Browse files
committed
fix:修正聊天的一些小问题
1 parent 4a3b0c2 commit 57c392d

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/chatPanel.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as vscode from 'vscode';
1+
import * as vscode from 'vscode';
22
import { callDeepSeekApi } from './deepseekApi';
33

44
class WebviewOutputChannel implements vscode.OutputChannel {
@@ -15,7 +15,7 @@ class WebviewOutputChannel implements vscode.OutputChannel {
1515
}
1616

1717
append(value: string): void {
18-
// 将数据通过 Webview 发送出去
18+
// 将数据通过 Webview 发送出去
1919
this._webview.postMessage({ role: 'model', content: value });
2020
}
2121

@@ -24,23 +24,23 @@ class WebviewOutputChannel implements vscode.OutputChannel {
2424
}
2525

2626
clear(): void {
27-
// 清除输出,通常可以通过清空 Webview 来实现
27+
// 清除输出,通常可以通过清空 Webview 来实现
2828
this._webview.postMessage({ role: 'model', content: '' });
2929
}
3030

3131
show(preserveFocus?: boolean): void;
3232
show(column?: vscode.ViewColumn, preserveFocus?: boolean): void;
3333
show(arg1?: boolean | vscode.ViewColumn, arg2?: boolean): void {
3434
if (typeof arg1 === 'boolean') {
35-
// 第一种重载:show(preserveFocus?: boolean)
36-
this._webview.postMessage({ role: 'model', content: 'Webview is now shown' });
35+
// 第一种重载:show(preserveFocus?: boolean)
36+
//this._webview.postMessage({ role: 'model', content: 'Webview is now shown' });
3737
} else {
38-
// 第二种重载:show(column?: ViewColumn, preserveFocus?: boolean)
38+
// 第二种重载:show(column?: ViewColumn, preserveFocus?: boolean)
3939
if (arg1 !== undefined) {
40-
// 根据 column 进行处理(可以自定义逻辑)
41-
console.log(`Showing in column: ${arg1}`);
40+
// 根据 column 进行处理(可以自定义逻辑)
41+
//console.log(`Showing in column: ${arg1}`);
4242
}
43-
this._webview.postMessage({ role: 'model', content: 'Webview is now shown' });
43+
//this._webview.postMessage({ role: 'model', content: 'Webview is now shown' });
4444
}
4545
}
4646
hide(): void {
@@ -52,7 +52,7 @@ class WebviewOutputChannel implements vscode.OutputChannel {
5252
}
5353

5454
replace(value: string): void {
55-
// 替换输出内容
55+
// 替换输出内容
5656
this._webview.postMessage({ role: 'model', content: value });
5757
}
5858
}
@@ -104,24 +104,24 @@ export class ChatPanel {
104104
<meta name="viewport" content="width=device-width, initial-scale=1.0">
105105
<title>Chat with Model</title>
106106
<style>
107-
.user { color: blue; }
108-
.model { color: green; }
109-
#chat {
110-
height: calc(100vh - 150px);
111-
overflow-y: auto;
112-
}
113-
#input-container {
114-
position: fixed;
115-
bottom: 0;
116-
width: 100%;
117-
background-color: white;
118-
padding: 10px;
119-
}
120-
#chat div {
121-
white-space: pre-wrap; /* 关键代码:保留换行符 */
122-
margin-bottom: 8px; /* 段落间距(可选) */
123-
}
124-
</style>
107+
.user { color: blue; }
108+
.model { color: green; }
109+
#chat {
110+
height: calc(100vh - 150px);
111+
overflow-y: auto;
112+
}
113+
#input-container {
114+
position: fixed;
115+
bottom: 0;
116+
width: 100%;
117+
background-color: white;
118+
padding: 10px;
119+
}
120+
#chat div {
121+
white-space: pre-wrap; /* 关键代码:保留换行符 */
122+
margin-bottom: 8px; /* 段落间距(可选) */
123+
}
124+
</style>
125125
</head>
126126
<body>
127127
<div id="chat"></div>
@@ -166,7 +166,7 @@ export class ChatPanel {
166166
const chat = document.getElementById('chat');
167167
const lastChild = chat.lastElementChild;
168168
169-
// 合并到同一角色元素
169+
// 合并到同一角色元素
170170
if (lastChild && lastChild.className === role) {
171171
lastChild.textContent += content;
172172
} else {
@@ -176,7 +176,7 @@ export class ChatPanel {
176176
chat.appendChild(div);
177177
}
178178
179-
// 自动滚动到底部
179+
// 自动滚动到底部
180180
chat.scrollTop = chat.scrollHeight;
181181
});
182182
</script>

0 commit comments

Comments
 (0)