feat: v0.8.2 安全纵深补全 · 协议保真 · 断链修复 — 图片SSRF/根MEMORY.md保护根治 · Anthropic thinking回传+pause_turn续传 · 2523 用例全量回归 + E2E 扩充
This commit is contained in:
@@ -8,6 +8,8 @@ import { ipcMain } from 'electron';
|
||||
import { join } from 'path';
|
||||
import type { IPCContext } from './context';
|
||||
import log from 'electron-log';
|
||||
// v0.8.2 P2-5: 工作空间校验文案出层(ui.locale 驱动)
|
||||
import { mt } from '../utils/main-locale';
|
||||
|
||||
export function registerWorkspaceHandlers(ctx: IPCContext): void {
|
||||
const { workspaceService } = ctx;
|
||||
@@ -43,7 +45,7 @@ export function registerWorkspaceHandlers(ctx: IPCContext): void {
|
||||
// 校验工作空间路径:检测路径有效性 + 必需文件状态 + 数据库是否存在
|
||||
ipcMain.handle('workspace:check', async (_event, targetPath: string) => {
|
||||
if (!targetPath || typeof targetPath !== 'string') {
|
||||
return { valid: false, reason: '路径不能为空' };
|
||||
return { valid: false, reason: mt('workspace.reason.empty') };
|
||||
}
|
||||
|
||||
const { existsSync, statSync } = await import('fs');
|
||||
@@ -60,7 +62,7 @@ export function registerWorkspaceHandlers(ctx: IPCContext): void {
|
||||
missingFiles: ['SOUL.md', 'MEMORY.md'],
|
||||
isNewWorkspace: true,
|
||||
dbExists: false,
|
||||
reason: '目录不存在,将在切换后自动创建',
|
||||
reason: mt('workspace.reason.notExists'),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,10 +70,10 @@ export function registerWorkspaceHandlers(ctx: IPCContext): void {
|
||||
try {
|
||||
const stat = statSync(resolvedPath);
|
||||
if (!stat.isDirectory()) {
|
||||
return { valid: false, reason: '路径不是目录' };
|
||||
return { valid: false, reason: mt('workspace.reason.notDirectory') };
|
||||
}
|
||||
} catch {
|
||||
return { valid: false, reason: '无法访问路径' };
|
||||
return { valid: false, reason: mt('workspace.reason.inaccessible') };
|
||||
}
|
||||
|
||||
// 校验 3: 检测 2 个必需文件状态(SOUL.md + MEMORY.md)
|
||||
|
||||
Reference in New Issue
Block a user