git功能已完备
This commit is contained in:
@@ -214,6 +214,9 @@ class ConfigPanel {
|
||||
case 'importGitFile':
|
||||
await this.importGitFile(data.filePath);
|
||||
break;
|
||||
case 'openGitRepoInVSCode':
|
||||
await this.openGitRepoInVSCode(data.repoId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
@@ -1186,17 +1189,25 @@ class ConfigPanel {
|
||||
// 过滤出分支引用 (refs/heads/ 和 refs/remotes/origin/)
|
||||
const branchRefs = refs.filter(ref => ref.ref.startsWith('refs/heads/') || ref.ref.startsWith('refs/remotes/origin/'));
|
||||
console.log('🌿 过滤后的分支引用:', branchRefs);
|
||||
// 构建分支数据
|
||||
// 构建分支数据 - 修复分支名称显示
|
||||
const branches = branchRefs.map(ref => {
|
||||
const isRemote = ref.ref.startsWith('refs/remotes/');
|
||||
const branchName = isRemote
|
||||
? ref.ref.replace('refs/remotes/origin/', '')
|
||||
: ref.ref.replace('refs/heads/', '');
|
||||
let branchName;
|
||||
if (isRemote) {
|
||||
// 远程分支:移除 refs/remotes/origin/ 前缀
|
||||
branchName = ref.ref.replace('refs/remotes/origin/', '');
|
||||
// 可以选择添加远程标识,或者不添加
|
||||
// branchName = `origin/${branchName}`; // 如果需要显示远程标识
|
||||
}
|
||||
else {
|
||||
// 本地分支:移除 refs/heads/ 前缀
|
||||
branchName = ref.ref.replace('refs/heads/', '');
|
||||
}
|
||||
return {
|
||||
name: branchName,
|
||||
isCurrent: branchName === 'main' || branchName === 'master',
|
||||
isRemote: isRemote,
|
||||
selected: branchName === 'main' || branchName === 'master'
|
||||
selected: false // 所有分支默认不选中
|
||||
};
|
||||
});
|
||||
console.log('🎯 最终分支列表:', branches);
|
||||
@@ -1219,7 +1230,7 @@ class ConfigPanel {
|
||||
// 如果方法失败,使用模拟数据
|
||||
console.log('🔄 使用模拟分支数据');
|
||||
const mockBranches = [
|
||||
{ name: 'main', isCurrent: true, isRemote: false, selected: true },
|
||||
{ name: 'main', isCurrent: true, isRemote: false, selected: false },
|
||||
{ name: 'master', isCurrent: false, isRemote: false, selected: false },
|
||||
{ name: 'develop', isCurrent: false, isRemote: false, selected: false },
|
||||
{ name: 'feature/new-feature', isCurrent: false, isRemote: false, selected: false }
|
||||
@@ -1328,6 +1339,38 @@ class ConfigPanel {
|
||||
});
|
||||
}
|
||||
}
|
||||
async openGitRepoInVSCode(repoId) {
|
||||
const repo = this.gitRepos.find(r => r.id === repoId);
|
||||
if (!repo) {
|
||||
vscode.window.showErrorMessage('未找到指定的 Git 仓库');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 检查仓库目录是否存在
|
||||
if (!fs.existsSync(repo.localPath)) {
|
||||
vscode.window.showErrorMessage('Git 仓库目录不存在,请重新克隆');
|
||||
return;
|
||||
}
|
||||
// 使用 VSCode 的文件选择器让用户选择要打开的文件
|
||||
const fileUri = await vscode.window.showOpenDialog({
|
||||
defaultUri: vscode.Uri.file(repo.localPath),
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
openLabel: '选择要打开的文件',
|
||||
title: `在 ${repo.name} 中选择文件`
|
||||
});
|
||||
if (fileUri && fileUri.length > 0) {
|
||||
// 打开选中的文件
|
||||
const document = await vscode.workspace.openTextDocument(fileUri[0]);
|
||||
await vscode.window.showTextDocument(document);
|
||||
vscode.window.showInformationMessage(`已打开文件: ${path.basename(fileUri[0].fsPath)}`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage(`打开 Git 仓库文件失败: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ConfigPanel = ConfigPanel;
|
||||
//# sourceMappingURL=ConfigPanel.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -26,23 +26,29 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
// 生成 Git 仓库列表的 HTML - 以配置文件形式显示
|
||||
const gitReposHtml = gitRepos.map(repo => `
|
||||
// 生成 Git 仓库列表的 HTML - 修改显示方式
|
||||
const gitReposHtml = gitRepos.map(repo => {
|
||||
// 提取仓库名称(从URL中获取或使用name)
|
||||
const repoName = repo.name.split(' (')[0]; // 移除分支名部分
|
||||
// 提取分支名
|
||||
const branchMatch = repo.name.match(/\(([^)]+)\)/);
|
||||
const branchName = branchMatch ? branchMatch[1] : repo.branch;
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="editable">📁 ${repo.name}</span>
|
||||
<span class="editable">📁 ${repoName}</span>
|
||||
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
|
||||
模型1、模型2
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="clickable" onclick="loadGitRepo('${repo.id}')">${repo.url.split('/').pop()}</span>
|
||||
<span class="clickable" onclick="openGitRepoInVSCode('${repo.id}')">${branchName}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
`;
|
||||
}).join('');
|
||||
// 生成分支选择的 HTML
|
||||
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : '';
|
||||
return `<!DOCTYPE html>
|
||||
@@ -225,7 +231,7 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
// Git 仓库删除功能 - 修复版本
|
||||
// Git 仓库删除功能
|
||||
function deleteGitRepo(repoId) {
|
||||
console.log('🗑️ 尝试删除 Git 仓库:', repoId);
|
||||
|
||||
@@ -246,6 +252,15 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
// 新功能:在 VSCode 中打开 Git 仓库
|
||||
function openGitRepoInVSCode(repoId) {
|
||||
console.log('📂 在 VSCode 中打开 Git 仓库:', repoId);
|
||||
vscode.postMessage({
|
||||
type: 'openGitRepoInVSCode',
|
||||
repoId: repoId
|
||||
});
|
||||
}
|
||||
|
||||
function saveConfigFile() {
|
||||
const content = document.getElementById('configContent').value;
|
||||
vscode.postMessage({
|
||||
@@ -370,7 +385,7 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
branchesHtml += (branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\\'' + branch.name + '\\')" style="margin-right: 10px;">';
|
||||
branchesHtml += '<label for="branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-') + '" style="flex: 1; cursor: pointer;">';
|
||||
branchesHtml += (branch.isCurrent ? '⭐ ' : '') + branch.name;
|
||||
branchesHtml += (branch.isRemote ? '(远程)' : '(本地)') + '</label></div>';
|
||||
branchesHtml += '</label></div>';
|
||||
});
|
||||
|
||||
branchesHtml += '</div>';
|
||||
@@ -477,18 +492,9 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化 - 添加调试信息(修复语法错误)
|
||||
// 初始化
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('📄 ConfigView 页面加载完成');
|
||||
console.log('🔍 检查 Git 仓库删除按钮绑定');
|
||||
|
||||
// 检查所有删除按钮
|
||||
const deleteButtons = document.querySelectorAll('.btn-delete');
|
||||
console.log('找到删除按钮数量:', deleteButtons.length);
|
||||
|
||||
deleteButtons.forEach(function(btn, index) {
|
||||
console.log('删除按钮 ' + index + ':', btn);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"ConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/ConfigView.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AA8BtC,MAAa,UAAW,SAAQ,mBAAQ;IACpC,MAAM,CAAC,IAON;QACG,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,EAAE,CAA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AG,MAAM,CAAC,IAAI,GAAG,mCAAmC,CAAC;YAC9H,IAAI,IAAI,cAAc,GAAG,QAAQ,GAAG,sCAAsC,CAAC;YAC3E,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;YACrD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,QAAQ,CAAC;QACjB,IAAI,IAAI,iCAAiC,CAAC;QAC1C,IAAI,IAAI,yGAAyG,CAAC;QAClH,IAAI,IAAI,wEAAwE,CAAC;QACjF,IAAI,IAAI,cAAc,CAAC;QAEvB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAxhBD,gCAwhBC"}
|
||||
@@ -305,6 +305,10 @@ export class ConfigPanel {
|
||||
case 'importGitFile':
|
||||
await this.importGitFile(data.filePath);
|
||||
break;
|
||||
|
||||
case 'openGitRepoInVSCode':
|
||||
await this.openGitRepoInVSCode(data.repoId);
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理 Webview 消息时出错:', error);
|
||||
@@ -1442,18 +1446,26 @@ private async deleteGitRepo(repoId: string): Promise<void> {
|
||||
|
||||
console.log('🌿 过滤后的分支引用:', branchRefs);
|
||||
|
||||
// 构建分支数据
|
||||
// 构建分支数据 - 修复分支名称显示
|
||||
const branches: GitBranch[] = branchRefs.map(ref => {
|
||||
const isRemote = ref.ref.startsWith('refs/remotes/');
|
||||
const branchName = isRemote
|
||||
? ref.ref.replace('refs/remotes/origin/', '')
|
||||
: ref.ref.replace('refs/heads/', '');
|
||||
let branchName: string;
|
||||
|
||||
if (isRemote) {
|
||||
// 远程分支:移除 refs/remotes/origin/ 前缀
|
||||
branchName = ref.ref.replace('refs/remotes/origin/', '');
|
||||
// 可以选择添加远程标识,或者不添加
|
||||
// branchName = `origin/${branchName}`; // 如果需要显示远程标识
|
||||
} else {
|
||||
// 本地分支:移除 refs/heads/ 前缀
|
||||
branchName = ref.ref.replace('refs/heads/', '');
|
||||
}
|
||||
|
||||
return {
|
||||
name: branchName,
|
||||
isCurrent: branchName === 'main' || branchName === 'master',
|
||||
isRemote: isRemote,
|
||||
selected: branchName === 'main' || branchName === 'master'
|
||||
selected: false // 所有分支默认不选中
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1482,7 +1494,7 @@ private async deleteGitRepo(repoId: string): Promise<void> {
|
||||
// 如果方法失败,使用模拟数据
|
||||
console.log('🔄 使用模拟分支数据');
|
||||
const mockBranches = [
|
||||
{ name: 'main', isCurrent: true, isRemote: false, selected: true },
|
||||
{ name: 'main', isCurrent: true, isRemote: false, selected: false },
|
||||
{ name: 'master', isCurrent: false, isRemote: false, selected: false },
|
||||
{ name: 'develop', isCurrent: false, isRemote: false, selected: false },
|
||||
{ name: 'feature/new-feature', isCurrent: false, isRemote: false, selected: false }
|
||||
@@ -1504,7 +1516,7 @@ private async deleteGitRepo(repoId: string): Promise<void> {
|
||||
console.error('❌ 获取分支失败:', error);
|
||||
vscode.window.showErrorMessage(`获取分支失败: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async cloneBranches(url: string, branches: string[]): Promise<void> {
|
||||
try {
|
||||
@@ -1603,4 +1615,39 @@ private async deleteGitRepo(repoId: string): Promise<void> {
|
||||
});
|
||||
}
|
||||
}
|
||||
private async openGitRepoInVSCode(repoId: string): Promise<void> {
|
||||
const repo = this.gitRepos.find(r => r.id === repoId);
|
||||
if (!repo) {
|
||||
vscode.window.showErrorMessage('未找到指定的 Git 仓库');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 检查仓库目录是否存在
|
||||
if (!fs.existsSync(repo.localPath)) {
|
||||
vscode.window.showErrorMessage('Git 仓库目录不存在,请重新克隆');
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用 VSCode 的文件选择器让用户选择要打开的文件
|
||||
const fileUri = await vscode.window.showOpenDialog({
|
||||
defaultUri: vscode.Uri.file(repo.localPath),
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
openLabel: '选择要打开的文件',
|
||||
title: `在 ${repo.name} 中选择文件`
|
||||
});
|
||||
|
||||
if (fileUri && fileUri.length > 0) {
|
||||
// 打开选中的文件
|
||||
const document = await vscode.workspace.openTextDocument(fileUri[0]);
|
||||
await vscode.window.showTextDocument(document);
|
||||
vscode.window.showInformationMessage(`已打开文件: ${path.basename(fileUri[0].fsPath)}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(`打开 Git 仓库文件失败: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,23 +61,30 @@ export class ConfigView extends BaseView {
|
||||
</tr>
|
||||
`).join('');
|
||||
|
||||
// 生成 Git 仓库列表的 HTML - 以配置文件形式显示
|
||||
const gitReposHtml = gitRepos.map(repo => `
|
||||
// 生成 Git 仓库列表的 HTML - 修改显示方式
|
||||
const gitReposHtml = gitRepos.map(repo => {
|
||||
// 提取仓库名称(从URL中获取或使用name)
|
||||
const repoName = repo.name.split(' (')[0]; // 移除分支名部分
|
||||
// 提取分支名
|
||||
const branchMatch = repo.name.match(/\(([^)]+)\)/);
|
||||
const branchName = branchMatch ? branchMatch[1] : repo.branch;
|
||||
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="editable">📁 ${repo.name}</span>
|
||||
<span class="editable">📁 ${repoName}</span>
|
||||
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
|
||||
模型1、模型2
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="clickable" onclick="loadGitRepo('${repo.id}')">${repo.url.split('/').pop()}</span>
|
||||
<span class="clickable" onclick="openGitRepoInVSCode('${repo.id}')">${branchName}</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
// 生成分支选择的 HTML
|
||||
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : '';
|
||||
@@ -262,7 +269,7 @@ export class ConfigView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
// Git 仓库删除功能 - 修复版本
|
||||
// Git 仓库删除功能
|
||||
function deleteGitRepo(repoId) {
|
||||
console.log('🗑️ 尝试删除 Git 仓库:', repoId);
|
||||
|
||||
@@ -283,6 +290,15 @@ export class ConfigView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
// 新功能:在 VSCode 中打开 Git 仓库
|
||||
function openGitRepoInVSCode(repoId) {
|
||||
console.log('📂 在 VSCode 中打开 Git 仓库:', repoId);
|
||||
vscode.postMessage({
|
||||
type: 'openGitRepoInVSCode',
|
||||
repoId: repoId
|
||||
});
|
||||
}
|
||||
|
||||
function saveConfigFile() {
|
||||
const content = document.getElementById('configContent').value;
|
||||
vscode.postMessage({
|
||||
@@ -407,7 +423,7 @@ export class ConfigView extends BaseView {
|
||||
branchesHtml += (branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\\'' + branch.name + '\\')" style="margin-right: 10px;">';
|
||||
branchesHtml += '<label for="branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-') + '" style="flex: 1; cursor: pointer;">';
|
||||
branchesHtml += (branch.isCurrent ? '⭐ ' : '') + branch.name;
|
||||
branchesHtml += (branch.isRemote ? '(远程)' : '(本地)') + '</label></div>';
|
||||
branchesHtml += '</label></div>';
|
||||
});
|
||||
|
||||
branchesHtml += '</div>';
|
||||
@@ -514,18 +530,9 @@ export class ConfigView extends BaseView {
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化 - 添加调试信息(修复语法错误)
|
||||
// 初始化
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('📄 ConfigView 页面加载完成');
|
||||
console.log('🔍 检查 Git 仓库删除按钮绑定');
|
||||
|
||||
// 检查所有删除按钮
|
||||
const deleteButtons = document.querySelectorAll('.btn-delete');
|
||||
console.log('找到删除按钮数量:', deleteButtons.length);
|
||||
|
||||
deleteButtons.forEach(function(btn, index) {
|
||||
console.log('删除按钮 ' + index + ':', btn);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user