fix: 修复项目切换时运行时和系统重复初始化问题 (#267)

* feat(editor): 添加 GitHub Discussions 社区论坛功能

* chore: 更新 pnpm-lock.yaml

* chore: 删除测试图片

* refactor: 改用 Imgur 图床上传图片

* fix: 修复项目切换时运行时和系统重复初始化问题

* fix: 修复多个编辑器问题

* feat: 添加脚本编辑器配置和类型定义支持

* feat: 实现资产 .meta 文件自动生成功能
This commit is contained in:
YHH
2025-12-04 14:04:39 +08:00
committed by GitHub
parent 374b26f7c6
commit b4e7ba2abd
20 changed files with 1040 additions and 75 deletions

View File

@@ -70,9 +70,11 @@ export class SettingsService {
}
public addRecentProject(projectPath: string): void {
// 规范化路径,防止双重转义 | Normalize path to prevent double escaping
const normalizedPath = projectPath.replace(/\\\\/g, '\\');
const recentProjects = this.getRecentProjects();
const filtered = recentProjects.filter((p) => p !== projectPath);
const updated = [projectPath, ...filtered].slice(0, 10);
const filtered = recentProjects.filter((p) => p !== normalizedPath);
const updated = [normalizedPath, ...filtered].slice(0, 10);
this.set('recentProjects', updated);
}
@@ -85,4 +87,64 @@ export class SettingsService {
public clearRecentProjects(): void {
this.set('recentProjects', []);
}
// ==================== Script Editor Settings ====================
/**
* 支持的脚本编辑器类型
* Supported script editor types
*/
public static readonly SCRIPT_EDITORS = [
{ id: 'system', name: 'System Default', nameZh: '系统默认', command: '' },
{ id: 'vscode', name: 'Visual Studio Code', nameZh: 'Visual Studio Code', command: 'code' },
{ id: 'cursor', name: 'Cursor', nameZh: 'Cursor', command: 'cursor' },
{ id: 'webstorm', name: 'WebStorm', nameZh: 'WebStorm', command: 'webstorm' },
{ id: 'sublime', name: 'Sublime Text', nameZh: 'Sublime Text', command: 'subl' },
{ id: 'custom', name: 'Custom', nameZh: '自定义', command: '' }
];
/**
* 获取脚本编辑器设置
* Get script editor setting
*/
public getScriptEditor(): string {
return this.get<string>('editor.scriptEditor', 'system');
}
/**
* 设置脚本编辑器
* Set script editor
*/
public setScriptEditor(editorId: string): void {
this.set('editor.scriptEditor', editorId);
}
/**
* 获取自定义脚本编辑器命令
* Get custom script editor command
*/
public getCustomScriptEditorCommand(): string {
return this.get<string>('editor.customScriptEditorCommand', '');
}
/**
* 设置自定义脚本编辑器命令
* Set custom script editor command
*/
public setCustomScriptEditorCommand(command: string): void {
this.set('editor.customScriptEditorCommand', command);
}
/**
* 获取当前脚本编辑器的命令
* Get current script editor command
*/
public getScriptEditorCommand(): string {
const editorId = this.getScriptEditor();
if (editorId === 'custom') {
return this.getCustomScriptEditorCommand();
}
const editor = SettingsService.SCRIPT_EDITORS.find(e => e.id === editorId);
return editor?.command || '';
}
}