fix: 工作空间面板定位、中文乱码、快捷键、帮助文档
- 工作空间面板 top 改用 CSS 变量 --nav-height,JS 动态计算 header+model-bar 实际高度
- Windows 下 spawn 子进程前加 chcp 65001 切换 UTF-8 代码页,修复中文乱码
- 补全 Ctrl+K(知识库)、Ctrl+M(记忆面板)快捷键,防止 Ctrl+M 默认行为冲突
- 帮助弹框内容全面更新,修正工作空间为常驻显示,补充 Ctrl+N、布局说明等
- Token 统计图标从 emoji 🪙 改为内联 SVG,兼容所有 Windows 字体
This commit is contained in:
+24
-8
@@ -88,21 +88,30 @@ export function startProcess(
|
||||
try {
|
||||
const isWin = process.platform === 'win32';
|
||||
const shell = isWin ? 'cmd.exe' : 'bash';
|
||||
const shellArgs = isWin ? ['/c', command] : ['-c', command];
|
||||
// Windows cmd 默认代码页为 GBK/CP936,中文输出会乱码
|
||||
// chcp 65001 切换到 UTF-8 代码页,>nul 抑制 chcp 自身的输出
|
||||
const actualCmd = isWin ? `chcp 65001 >nul && ${command}` : command;
|
||||
const shellArgs = isWin ? ['/c', actualCmd] : ['-c', actualCmd];
|
||||
const proc = spawn(shell, shellArgs, {
|
||||
cwd: workDir,
|
||||
env: { ...process.env, ...(isWin ? {} : { TERM: 'xterm-256color' }) },
|
||||
env: {
|
||||
...process.env,
|
||||
...(isWin ? {} : { TERM: 'xterm-256color' }),
|
||||
LANG: 'en_US.UTF-8',
|
||||
LC_ALL: 'en_US.UTF-8',
|
||||
PYTHONIOENCODING: 'utf-8'
|
||||
},
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
activeProcesses.set(id, proc);
|
||||
|
||||
proc.stdout.on('data', (data: Buffer) => {
|
||||
onOutput('stdout', data.toString());
|
||||
onOutput('stdout', data.toString('utf-8'));
|
||||
});
|
||||
|
||||
proc.stderr.on('data', (data: Buffer) => {
|
||||
onOutput('stderr', data.toString());
|
||||
onOutput('stderr', data.toString('utf-8'));
|
||||
});
|
||||
|
||||
proc.on('close', (code) => {
|
||||
@@ -246,17 +255,24 @@ export function execWorkspaceCommand(
|
||||
try {
|
||||
const isWin = process.platform === 'win32';
|
||||
const shell = isWin ? 'cmd.exe' : 'bash';
|
||||
const shellArgs = isWin ? ['/c', command] : ['-c', command];
|
||||
const actualCmd = isWin ? `chcp 65001 >nul && ${command}` : command;
|
||||
const shellArgs = isWin ? ['/c', actualCmd] : ['-c', actualCmd];
|
||||
const proc = spawn(shell, shellArgs, {
|
||||
cwd: workDir,
|
||||
env: { ...process.env, ...(isWin ? {} : { TERM: 'xterm-256color' }) },
|
||||
env: {
|
||||
...process.env,
|
||||
...(isWin ? {} : { TERM: 'xterm-256color' }),
|
||||
LANG: 'en_US.UTF-8',
|
||||
LC_ALL: 'en_US.UTF-8',
|
||||
PYTHONIOENCODING: 'utf-8'
|
||||
},
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
});
|
||||
|
||||
activeProcesses.set(cmdId, proc);
|
||||
|
||||
proc.stdout.on('data', (data: Buffer) => {
|
||||
const str = data.toString();
|
||||
const str = data.toString('utf-8');
|
||||
if (stdoutBuf.length < MAX_OUTPUT) {
|
||||
stdoutBuf += str;
|
||||
if (stdoutBuf.length > MAX_OUTPUT) {
|
||||
@@ -271,7 +287,7 @@ export function execWorkspaceCommand(
|
||||
});
|
||||
|
||||
proc.stderr.on('data', (data: Buffer) => {
|
||||
const str = data.toString();
|
||||
const str = data.toString('utf-8');
|
||||
if (stderrBuf.length < MAX_OUTPUT) {
|
||||
stderrBuf += str;
|
||||
if (stderrBuf.length > MAX_OUTPUT) {
|
||||
|
||||
Reference in New Issue
Block a user