0
0

修复了合并的第一个BUG,两个类型文件的命名问题

This commit is contained in:
xubing
2025-11-27 20:22:29 +08:00
parent 97c897962f
commit d0ea028e3e
6 changed files with 118 additions and 76 deletions

View File

@@ -207,7 +207,7 @@ class ConfigPanel {
await this.importGitFile(data.filePath);
break;
case 'openGitRepoInVSCode':
await this.openGitRepoInVSCode(data.repoId);
await this.openTheModuleFolder('git', data.repoId);
break;
case 'openConfigFileInVSCode':
await this.openConfigFileInVSCode(data.configId);
@@ -219,10 +219,13 @@ class ConfigPanel {
await this.deleteMergedFolder(data.folderId);
break;
case 'openMergedFolderInVSCode':
await this.openMergedFolderInVSCode(data.folderId);
await this.openTheModuleFolder('merged', data.folderId);
break;
case 'loadMergedFolder':
await this.loadMergedFolder(data.folderId);
await this.openTheModuleFolder('merged', data.folderId);
break;
case 'openTheModuleFolder':
await this.openTheModuleFolder(data.moduleType, data.id);
break;
}
}
@@ -1504,26 +1507,50 @@ class ConfigPanel {
vscode.window.showErrorMessage(`打开合并文件夹失败: ${error}`);
}
}
async loadMergedFolder(folderId) {
const folder = this.mergedFolders.find(f => f.id === folderId);
if (!folder) {
vscode.window.showErrorMessage('未找到指定的合并文件夹');
/**
* 统一方法:在 VSCode 中打开模块文件夹中的文件
* @param type 模块类型:'git' 或 'merged'
* @param id 模块 ID
*/
async openTheModuleFolder(type, id) {
let folderPath;
let folderName;
if (type === 'git') {
const repo = this.gitRepos.find(r => r.id === id);
if (!repo) {
vscode.window.showErrorMessage('未找到指定的 Git 仓库');
return;
}
folderPath = repo.localPath;
folderName = repo.name;
}
else if (type === 'merged') {
const folder = this.mergedFolders.find(f => f.id === id);
if (!folder) {
vscode.window.showErrorMessage('未找到指定的合并文件夹');
return;
}
folderPath = folder.path;
folderName = folder.displayName;
}
if (!folderPath) {
vscode.window.showErrorMessage('未找到文件夹路径');
return;
}
try {
// 检查文件夹是否存在
if (!fs.existsSync(folder.path)) {
vscode.window.showErrorMessage('合并文件夹目录不存在');
if (!fs.existsSync(folderPath)) {
vscode.window.showErrorMessage(`${type === 'git' ? 'Git 仓库' : '合并文件夹'}目录不存在`);
return;
}
// 使用 VSCode 的文件选择器让用户选择要打开的文件
const fileUri = await vscode.window.showOpenDialog({
defaultUri: vscode.Uri.file(folder.path),
defaultUri: vscode.Uri.file(folderPath),
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
openLabel: '选择要打开的文件',
title: `合并文件夹 ${folder.displayName} 中选择文件`
title: `${folderName} 中选择文件`
});
if (fileUri && fileUri.length > 0) {
// 打开选中的文件
@@ -1533,7 +1560,7 @@ class ConfigPanel {
}
}
catch (error) {
vscode.window.showErrorMessage(`打开合并文件夹文件失败: ${error}`);
vscode.window.showErrorMessage(`打开${type === 'git' ? 'Git 仓库' : '合并文件夹'}文件失败: ${error}`);
}
}
}